Skip to content

Commit

Permalink
Rever to using non-defaulted key for TracingContextUtils.
Browse files Browse the repository at this point in the history
  • Loading branch information
carlosalberto committed Mar 20, 2020
1 parent 7a3cbeb commit 16b8020
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
@Immutable
public final class TracingContextUtils {
private static final Context.Key<Span> CONTEXT_SPAN_KEY =
Context.<Span>keyWithDefault("opentelemetry-trace-span-key", DefaultSpan.getInvalid());
Context.<Span>key("opentelemetry-trace-span-key");

/**
* Returns the {@link Span} from the current {@code Context}, falling back to a default, no-op
Expand Down Expand Up @@ -64,7 +64,8 @@ public static Context withSpan(Span span, Context context) {
* @since 0.3.0
*/
public static Span getSpan(Context context) {
return CONTEXT_SPAN_KEY.get(context);
Span span = CONTEXT_SPAN_KEY.get(context);
return span == null ? DefaultSpan.getInvalid() : span;
}

/**
Expand All @@ -77,8 +78,7 @@ public static Span getSpan(Context context) {
*/
@Nullable
public static Span getSpanWithoutDefault(Context context) {
Span span = CONTEXT_SPAN_KEY.get(context);
return DefaultSpan.getInvalid().equals(span) ? null : span;
return CONTEXT_SPAN_KEY.get(context);
}

/**
Expand Down

0 comments on commit 16b8020

Please sign in to comment.