opentelemetry-java icon indicating copy to clipboard operation
opentelemetry-java copied to clipboard

Filtering span attributes

Open pavolloffay opened this issue 4 years ago • 4 comments

Is your feature request related to a problem? Please describe.

Our custom build of OTEL Java agent captures more data, to be specific we capture all request and response headers. This ultimately results in data duplication as the OTEL core instrumentation already collects some of that data. We want to use the core instrumentation, but somehow filter duplicated data. The data could be filtered in the collector, however we would like to save network bandwith from the user process to the collector.

Describe the solution you'd like

A pluggable API in the SDK where we could modify span before passing it to the exporter.

Describe alternatives you've considered

Remove duplicated data in the collector, however, if we could remove it directly in the user process it would be better from the network bandwidth perspective.

Additional context None.

pavolloffay avatar Nov 13 '20 16:11 pavolloffay

Hi @pavolloffay . Can you have an exporter wrapper that updates the SpanData to filter out what you don't want? Or, alternatively, have a SpanProcessor wrapper that does the same thing?

We have some SpanData wrapping options in the opentelemetry-sdk-extension-tracing-incubator module to help with this, as well.

jkwatson avatar Nov 13 '20 17:11 jkwatson

@pavolloffay last chance to respond or I will close this as not needed at this time.

jkwatson avatar Aug 25 '21 22:08 jkwatson

I'm having this same issue. The SpanProcessor extension is not sufficient since I need to remove or add attributes and events onEnd, but the onEnd method only exposes a ReadableSpan interface.

FrankSpitulski avatar Oct 08 '21 20:10 FrankSpitulski

@FrankSpitulski I recommend doing this in an exporter, rather than trying to do it in a SpanProcessor. That interface was not designed for mutating spans when they end.

jkwatson avatar Oct 08 '21 21:10 jkwatson