-
Notifications
You must be signed in to change notification settings - Fork 843
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 Span#addLink, for adding link after span start #6084
Conversation
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## main #6084 +/- ##
============================================
- Coverage 91.06% 91.01% -0.05%
- Complexity 5671 5676 +5
============================================
Files 620 621 +1
Lines 16553 16580 +27
Branches 1689 1693 +4
============================================
+ Hits 15074 15091 +17
- Misses 993 998 +5
- Partials 486 491 +5 ☔ View full report in Codecov by Sentry. |
sdk/trace/src/main/java/io/opentelemetry/sdk/trace/SdkSpan.java
Outdated
Show resolved
Hide resolved
@jkwatson any additional comments? Thanks! |
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.
🚢 tiny javadoc suggestion, but nothing major
Co-authored-by: John Watson <[email protected]>
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.
Looks good overall, but had a couple of ideas about the interface.
@@ -35,7 +36,7 @@ | |||
|
|||
/** Implementation for the {@link Span} class that records trace events. */ | |||
@ThreadSafe | |||
final class SdkSpan implements ReadWriteSpan { | |||
final class SdkSpan implements ReadWriteSpan, ExtendedSpan { |
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.
Something about this gives me pause -- because it is implementing two interfaces both of which extend a common parent interface. Seems weird to me. Maybe it's nothing, but it seems like a smell to me.
Immediately makes me question whether or not ExtendedSpan
really needs to extend Span
.
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.
Initially I switched ReadWriteSpan to extend ExtendedSpan instead of Span, but that doesn't work because ReadWriteSpan is part of the public API, and we can't have experimental surface area exposed in the stable API.
We have a long history of doing non-ideal things to be able to incubate things without committing to the stable API. While this is a smell, it will be short lived as it goes away as soon as the spec stabilizes and these methods are promoted to span.
Immediately makes me question whether or not ExtendedSpan really needs to extend Span.
Any other ideas?
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.
We have a long history of doing non-ideal things to be able to incubate things without committing to the stable API.
👍
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.
Immediately makes me question whether or not ExtendedSpan really needs to extend Span.
Any other ideas?
What if it just didn't? It can be its own stand-alone interface, right? And it's only used by the single implementation.
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.
Well the idea is that a user casts spans to ExtendedSpan to access the the combination of stable and experimental methods:
ExtendedSpan span = (ExtendedSpan) tracer.spanBuilder("name").startSpan();
span.setAttribute("key", "value");
span.addLink(spanContext);
If ExtenedSpan doesn't extend Span, then its more awkward to use:
Span span = tracer.spanBuilder("name").startSpan();
span.setAttribute("key", "value");
// Cast span to ExtendedSpan just to access #addLink
((ExtendedSpan) span).addLink(spanContext);
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.
Yeah ok, I get it. Thanks for clarifying.
Implementation of new spec requirement to support adding links after span start, defined in: open-telemetry/opentelemetry-specification#3678