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

AspNetCore instrumentation: filter out parent span but allow children

Open gao-artur opened this issue 2 years ago • 2 comments

Question

When I configure the AspNetCoreInstrumentationOptions.Filter delegate, if it returns false AspNetCore instrumentation won't create a span and will prevent the creation of any spans within the scope of this request. Is it possible to skip the AspNetCore span but allow child spans? For example, when I have AspNetCore and QraphQL instrumentations enabled, I want the QraphQL instrumentation to filter out queries with the operation name IntrospectionQuery, so I configure it this way. But the AspNetCore instrumentation still creates the span with the /graphql path, which I want to discard.

The question can also be rephrased this way: Can the child span discard the parent span?

gao-artur avatar Feb 19 '23 16:02 gao-artur

Have you considered using AlwaysOnSampler()? --> This will not prevent creation of child activities. The root one can still be filtered out using Filter delegate.

vishweshbankwar avatar Feb 24 '23 02:02 vishweshbankwar

Hey @vishweshbankwar, sorry for the late response. I do want to have a sampling configuration, so AlwaysOnSampler doesn't fit my needs.

gao-artur avatar Mar 14 '23 08:03 gao-artur