Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add safetyTags property to tracer exporters #1052

Merged
merged 2 commits into from
Jan 8, 2022
Merged

Conversation

icebob
Copy link
Member

@icebob icebob commented Jan 4, 2022

📝 Description

Option 1

A common problem is that developers or external modules send non-serializable parameters (e.g. http request, socket instance, stream instance...etc) in ctx.params or ctx.meta. If tracing is enabled, the tracer exporters try to convert these parameters in flattenTags methods which is flattening the given object recursively, which causes maximum call stack error.

To avoid it, we added a safetyTags option to the exporter options. If it is true, the exporters remove the cyclic properties before flattening the tags in the spans. This option is available in all built-in exporters.

Please note, this enabled option affects the performance, this is the reason why it's not enabled by default.

// moleculer.config.js
{
    tracing: {
        exporter: [{
            type: "Zipkin",
            options: {
                safetyTags: true,
                baseURL: "http://127.0.0.1:9411"
            }
        }]
    }
}

Option 2

To avoid that all action span tags will be converted because only just a few are affected by the problem, you can enable this function at action-level as well.

broker.createService({
    name: "greeter",
    actions: {
        hello: {
            tracing: {
                safetyTags: true
            },
            handler(ctx) {
                return `Hello!`;
            }
        }
    }
});

🎯 Relevant issues

Resolves #777, #908

💎 Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

@icebob icebob requested a review from AndreMaz January 4, 2022 18:53
@icebob icebob linked an issue Jan 4, 2022 that may be closed by this pull request
4 tasks
@icebob icebob added this to the 0.14.x milestone Jan 4, 2022
@ghost
Copy link

ghost commented Jan 4, 2022

CodeSee Review Map:

Review these changes using an interactive CodeSee Map

Review in an interactive map

View more CodeSee Maps

Legend

CodeSee Map Legend

@icebob icebob merged commit 633817e into master Jan 8, 2022
@icebob icebob deleted the tracing_flattenTags branch January 8, 2022 10:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants