New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Exporters should not be sent "is_sampled=false" spans #870
Comments
Yeah, I think this is a regression that happened when we switch to async exporters. Good catch!
in So I think we can simply check the spans before it sends to the internal queues in span processors. |
That's a trait, though. Third-party exporters like https://github.com/ramosbugs/opentelemetry-honeycomb-rs implement both Also, simply filtering in the two built-in |
Yeah the idea is people can bring their own exporter and those exporter will be able to work with BatchSpanProcessor or SimpleSpanProcessor in SDK.
Haven't look into that repo much but I think the reason they build their own Processor is to have a custom function before span starts.
In the spec, if a span is If a span is not I think that the reason this bug stays undetected is even if we export it to the backend most of them just gonna drop the span without a sample flag |
Yeah looks like this was a regression at some point. Thanks for the detailed report @fasterthanlime! |
I think this actually is the commonly accepted solution (see the go impl, java impl, etc), so that's the patch I submitted in #871 to get this working properly again. |
Happy to keep investigating less footguy-y solutions as well, but would be good to get this fixed for the upcoming 0.18.x release so at least the sdk provided processors have the correct behavior. |
I have a custom
ShouldSample
implemetation. I ran into #800 and am glad to see #839 is almost there.But there's a remaining problem afaict. As per the opentelemetry spec:
The problem is that, in the
opentelemetry
crate, span exporters are simply span processors.Span::ensure_ended_and_exported
sends export data to all processors unconditionally:opentelemetry-rust/opentelemetry-sdk/src/trace/span.rs
Lines 186 to 208 in 043e4b7
(..unless the span was already exported, or the provider was shut down). It doesn't check for
self.span_context().is_sampled()
, and can't tell the difference between exporters and other span processors anyway.Here's what happens whe installing a simple exporter:
opentelemetry-rust/opentelemetry-sdk/src/trace/provider.rs
Lines 154 to 160 in c92a1ad
The
SimpleSpanProcessor
unconditionally sends to its internal channel:opentelemetry-rust/opentelemetry-sdk/src/trace/span_processor.rs
Lines 143 to 147 in c92a1ad
Which unconditionally calls
exporter.export
:opentelemetry-rust/opentelemetry-sdk/src/trace/span_processor.rs
Lines 116 to 118 in c92a1ad
So, this seems like another departure from the spec (which was very surprising to me).
A bad fix for this is to teach both the "simple" and "batched" exporters to ignore spans where
is_sampled=false
. This is bad for a bunch of reasons:build_export_data
is not free, calling it for a non-sampled span is wastefulAnother fix is to not send the span to any processor if it's not sampled - ie, to return early from
ensure_ended_and_exported
ifis_sampled=false
. This also seems bad because what if there's processors that aren't exporters?Again, the spec says:
is_recording=true
, regardless ofis_sampled
is_recording=true && is_sampled=true
It seems like the actual fix is to either:
SpanProcessor
- this seems expensive for no good reasonEither way this seems like a breaking change.
The text was updated successfully, but these errors were encountered: