-
Notifications
You must be signed in to change notification settings - Fork 849
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
Remove DefaultSpan from public API. #1791
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,6 +23,26 @@ | |
@ThreadSafe | ||
public interface Span { | ||
|
||
/** | ||
* Returns an invalid {@link Span}. An invalid {@link Span} is used when tracing is disabled, | ||
* usually because there is no OpenTelemetry SDK installed. | ||
*/ | ||
static Span getInvalid() { | ||
return PropagatedSpan.INVALID; | ||
} | ||
|
||
/** | ||
* Returns a non-recording {@link Span} that holds the provided {@link SpanContext} but has no | ||
* functionality. It will not be exported and all tracing operations are no-op, but it can be used | ||
* to propagate a valid {@link SpanContext} downstream. | ||
*/ | ||
static Span getPropagated(SpanContext spanContext) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. s/getPropagated/toPropagated? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this should be called There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think we are safe against behavior change, this needs to always propagate the SC. But +1 for the name |
||
if (spanContext == null || !spanContext.isValid()) { | ||
return getInvalid(); | ||
} | ||
return new PropagatedSpan(spanContext); | ||
} | ||
|
||
/** | ||
* Type of span. Can be used to specify additional relationships between spans in addition to a | ||
* parent/child relationship. | ||
|
@@ -304,6 +324,15 @@ default void setAttribute(AttributeKey<Long> key, int value) { | |
*/ | ||
boolean isRecording(); | ||
|
||
/** | ||
* Returns whether this {@link Span} is valid. | ||
* | ||
* @see Span#getInvalid() | ||
*/ | ||
default boolean isValid() { | ||
return getContext().isValid(); | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this change is unrelated with the PR description and purpose, consider to not add "secondary" changes to a PR. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure makes sense |
||
|
||
/** | ||
* {@link Builder} is used to construct {@link Span} instances which define arbitrary scopes of | ||
* code that are sampled for distributed tracing as a single atomic unit. | ||
|
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 a nice cleanup. much tighter and clearer.