opentelemetry-js-contrib icon indicating copy to clipboard operation
opentelemetry-js-contrib copied to clipboard

feat(koa): Adds support to ignore a span by its layer name

Open MrFabio opened this issue 1 year ago • 7 comments

Which problem is this PR solving?

  • Adds ignoreLayersName option to instrumentation constructor config to allow layers to be ignored by its name.
  • Currently we have the ignoreLayersType config, this new one will run after this check.
  • It is useful if we want to ignore some layers like logger, allowedMethods, and some ones with no name. It also helps with reducing the number of spans.

Short description of the changes

  • Defines KoaInstrumentationConfig with ignoreLayersName which is an array of string (layer names):
  • Utils module with isLayerNameIgnored to check if a layer should be ignored by the name
  • Modifies _patchLayer to check if the layer is ignored by the config

MrFabio avatar Mar 20 '24 19:03 MrFabio

Did you consider using a SpanProcessor for this?

laurit avatar Mar 10 '23 20:03 laurit

@laurit good suggestion, I wasn't aware of that

adamleantech avatar Mar 15 '23 15:03 adamleantech

@laurit updated PR as per your suggestion. I've realised that there is probably an issue with my previous PR for logback MDC in that the "baggage." prefix should be on the key not the value

adamleantech avatar Mar 16 '23 12:03 adamleantech

@adamleantech thanks for reporting, I'll fix it

laurit avatar Mar 16 '23 13:03 laurit

I wonder if otel.javaagent.span.add-baggage should take a list of baggage to add (or * for all), this would match otel.instrumentation.logback-appender.experimental.capture-mdc-attributes

and maybe we should do the same for otel.instrumentation.logback-mdc.add-baggage?

trask avatar Apr 13 '23 14:04 trask

I'm interested in this same functionality but for use as an AutoConfigureSpi addition to a manually instrumented program (which uses the AutoConfigure SDK extension).

Is there anything which ties AgentTracerProviderConfigurer to the java agent (other than the name?).

Not for this PR obviously, but I wonder if this and AddThreadDetailsSpanProcessor could be relocated into the https://github.com/open-telemetry/opentelemetry-java repo as some sort of sdk-extension-customizer artifact?

evantorrie avatar Apr 28 '23 07:04 evantorrie

Is there anything which ties AgentTracerProviderConfigurer to the java agent (other than the name?).

Yeah, this configurer is coupled to the agent through the AgentConfig as well...but I think there's room for that to be a separate responsibility (separate PR).

Not for this PR obviously, but I wonder if this and AddThreadDetailsSpanProcessor could be relocated into the https://github.com/open-telemetry/opentelemetry-java repo as some sort of sdk-extension-customizer artifact?

I am liking this idea. @jack-berg and @jkwatson what do you think? Is there room for add-on processors like this in the core repo, or would you prefer to see it as a contrib addition, or something else?

breedx-splk avatar Jul 10 '23 20:07 breedx-splk

Contrib is the appropriate place for this. If such a processor were to occur in the spec, we could promote that component the core repo.

jack-berg avatar Jul 10 '23 21:07 jack-berg

Has this been contributed to the contrib repo / exists on the java agent?

galbash avatar Nov 19 '23 11:11 galbash

Has this been contributed to the contrib repo / exists on the java agent?

not yet

trask avatar Nov 28 '23 02:11 trask