moleculer
moleculer copied to clipboard
List of actions to be excluded from tracing
Can you add exclude feature for tracing similar to metrics?
+1
Fairly simple i believe,
in tracer.js, change spanFinished function:
spanFinished(span) {
if (span.sampled) {
if (this.opts.exclude && this.opts.exclude.length != 0 && this.opts.exclude.indexOf(span.tags.action.name) != -1) return;
this.invokeExporter("spanFinished", [span]);
}
}
then in the tracing config, add an array
exclude : ["action1","action2"]
This will apply for all tracers, same logic can be applied individually.
Alternatively/additionally one can filter by span.name as well (eg this would apply to ApiGw to filter by REST action as span.tags.action.name in ApiGw is api.rest)
How this feature would work?
Imagine the following scenario:
and
excludes
field with ["math.**"
]
In this case the excludes
means that if we call math.random
directly there won't by any tracing?
Or excludes
means that if we call greeter.hello
everything after math.random
, including math.random
, is not part of the span? Like so:
@AndreMaz I think it should only be for math.**
So, under the hood, it is still necessary to collect all spans and only when pushing or printing them the mat.**
is excluded?
Yes, we have discussed this before in discord. In the current implementation, it is not possible. Even if tracing is disabled, it will still collect spans and won't send them. It is now an acceptable solution to get the functionality to look for unnecessary services from the trace.