-
Notifications
You must be signed in to change notification settings - Fork 845
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
Move static access of current span to Span. #1795
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1795 +/- ##
=========================================
Coverage 85.53% 85.53%
- Complexity 1374 1375 +1
=========================================
Files 166 166
Lines 5308 5309 +1
Branches 549 549
=========================================
+ Hits 4540 4541 +1
Misses 569 569
Partials 199 199
Continue to review full report at Codecov.
|
It seems to contradict this spec issue
|
I think that is a spec wording issue and should be fixed there. IMHO the spec just wants these methods to not require a Span/Tracer instance as parameters (e.g. implicit |
* @since 0.3.0 | ||
*/ | ||
public static Span getCurrentSpan() { | ||
static Span getCurrentSpan() { | ||
return getSpan(io.opentelemetry.context.Context.current()); |
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.
odd fully-qualified class here. might cleaning it up while you're here?
No, we also want to reduce the places where we expose this functionality. That being said, whether we keep this functionality ( |
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'm definitely not a fan of TCU, so this seems like a good change to me. Would love @carlosalberto to comment, as well.
But this is not adding more places? |
Yes! And that's why I'd be fine with a single shortcut (or, well, none). The idea is that Spec change is to not have all duplicated (at this moment we have many operations all over the place). |
We had some discussion about this during the SIG meeting this morning. The request from @bogdandrutu , which I think everyone agreed with, is possibly an end-state-describing issue that can track all the work on this cleanup, so we can have a good handle on where you/we are headed. For instance, we all like having So, the ask is for a little bit of design work to describe where you see the end-state of the API (this might tie into the instance/global work, additionally, if you feel they are related). |
Thanks, summarized in #1807 |
@@ -35,7 +35,7 @@ public static Tracer getInstance() { | |||
|
|||
@Override | |||
public Span getCurrentSpan() { | |||
return TracingContextUtils.getCurrentSpan(); | |||
return Span.current(); |
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.
Given that TracingContextUtils
still is the root, I'd be happier with using that one instead (users and instrumentation are free to use whatever they want of course ;) )
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.
this is gone from the Tracer now, so probably not relevant. :)
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.
Disagree - we want to use whatever the root is. Otherwise, let's simply move the logic to Span
;) (although the Spec may not allow that).
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'm just saying that this method is no longer on the Tracer on the main branch, so this comment can't apply without adding it back to the Tracer.
@@ -24,7 +24,7 @@ | |||
|
|||
@Override | |||
public Span getCurrentSpan() { | |||
return TracingContextUtils.getCurrentSpan(); |
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.
Likewise.
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.
same
Proposing for the moment to close this PR and update or create a new PR with the latest discussion from #1807 |
@bogdandrutu Fine by me to close this PR while we discuss our options. |
I was thinking of talking about this after changes like #1753 and #1737 (after which I'm thinking of moving context interaction to
OpenTelemetry
) but figured it doesn't hurt to split this out as an idea.I think getting the current span is a very common operation, especially for javaagent users. They will rarely create spans, or deal with tracers. But adding attributes to a span is very common for anyone.
We are also toying with the idea of having static methods on
Tracer
For simple usage, which is common for accessing the current span since when you have a tracer, you usually also will have created a span from it to track yourself, the former feels more intuitive and looks like better code from a user perspective to me. Tracer is a very important concept for instrumentation authors, but not so important for end users.