moleculer icon indicating copy to clipboard operation
moleculer copied to clipboard

List of actions to be excluded from tracing

Open ErmakovSergey opened this issue 4 years ago • 6 comments

Can you add exclude feature for tracing similar to metrics?

ErmakovSergey avatar Apr 16 '20 07:04 ErmakovSergey

+1

intech avatar Apr 16 '20 09:04 intech

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)

synologic avatar Jan 19 '22 19:01 synologic

How this feature would work? Imagine the following scenario: image 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: image

AndreMaz avatar Aug 31 '22 17:08 AndreMaz

@AndreMaz I think it should only be for math.** tracing

intech avatar Aug 31 '22 18:08 intech

So, under the hood, it is still necessary to collect all spans and only when pushing or printing them the mat.** is excluded?

AndreMaz avatar Aug 31 '22 18:08 AndreMaz

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.

intech avatar Aug 31 '22 18:08 intech