-
Notifications
You must be signed in to change notification settings - Fork 850
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
Add option to export unsampled spans from span processors #6057
Add option to export unsampled spans from span processors #6057
Conversation
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## main #6057 +/- ##
============================================
- Coverage 90.99% 90.98% -0.02%
- Complexity 5687 5701 +14
============================================
Files 628 630 +2
Lines 16675 16708 +33
Branches 1654 1656 +2
============================================
+ Hits 15174 15202 +28
- Misses 1047 1049 +2
- Partials 454 457 +3 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I support some version of this change. We talked in the TC about whether the spec needs to explicitly allow all SDK configuration options with normative "MAY" language, and agreed that the answer is no. Maintainers should be careful about adding options that obviously conflict with the spec, and about adding surface area which is hard to maintain, but there is plenty of precedent for language implementations adding options which are not explicitly defined in the spec.
In this case, I've heard this type of issue discussed a number of times. I think its easy to accommodate and maintain, and conceptually makes sense.
* Sets whether unsampled spans should be exported. If unset, unsampled spans will not be | ||
* exported. | ||
*/ | ||
public BatchSpanProcessorBuilder exportUnsampledSpans(boolean exportUnsampledSpans) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was thinking about this.. I think it would be more flexible / future proof to allow the user to set an optional predicate for deciding whether or not a span is exported. Signature might be one of the following:
// allow user to make decision using full span
public BatchSpanProcessorBuilder setExportPredicate(Predicate<ReadableSpan>)
// allow user to make decision using full span context
public BatchSpanProcessorBuilder setExportPredicate(Predicate<SpanContext>)
Was originally thinking the predicate should accept SamplingDecision
, but SamplingDecision
ins't available in BatchSpanProcessor#onEnd
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hah, I started with a Predicate<ReadableSpan>
and backed away from that thinking it would be considered too complicated. I'd be happy with that approach.
I was also thinking we'd want the processor to always drop unrecorded spans? That'd be indicated by an invalid span context, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was also thinking we'd want the processor to always drop unrecorded spans? That'd be indicated by an invalid span context, right?
Yeah, the span never makes it the span processor if its not recorded (see SdkSpanBuilder) so no way for the span processor to influence this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I support 👍
sdk/trace/src/main/java/io/opentelemetry/sdk/trace/export/SimpleSpanProcessorBuilder.java
Outdated
Show resolved
Hide resolved
I slightly prefer the name |
@open-telemetry/java-approvers can you take a look at this? Would be good to get this in before the 1.34.0 release. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
any thoughts on how to this would/could work with autoconfigure?
There's obviously no spec'd env var for this type of thing. We could add a java specific env variable, but I'm reluctant to do that because this isn't a java specific problem. Could use the new |
sounds like a good path forward if/when we want 👍 |
the generalization of this PR to |
You're saying that you can accomplish the same thing by using |
ya, sorry, I was asking what you thought about limiting this PR to just a configurable (boolean) flag on BatchSpanProcessor that determines whether it drops unsampled spans. if you want a more complex filter you can use |
I get what you're saying now: if we only exposed a boolean to indicate that batch span processor should export unsampled spans, then you can effectively accomplish the more general Its a good point and I agree. @HaloFour can you revert to the original boolean option you started with before I derailed you in this convo? If not, I'm happy to it. |
Shame, I kinda like the power afforded by the general filter. How does |
Nevermind, I get it. With the I am curious as to how one would be expected to do this with the autoconfigure API, though. Unless a generic |
…leSpanProcessorBuilder.java Co-authored-by: jack-berg <34418638+jack-berg@users.noreply.github.com>
ack, rebase fail |
25c30f8
to
89a0f04
Compare
Yup I came up with the same set of options 🙂 (see comment). I prefer adding a
|
Want me to add |
I'd say in a followup, unless you know you need to use autoconfigure for your use case. |
Adds an option to the
SimpleSpanProcessor
andBatchSpanProcessor
which allows unsampled spans to be exported.