Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ public TypeConverter(final LogHandler logHandler) {
}

public AgentSpan toAgentSpan(final Span span) {
if (span instanceof OTSpan) {
if (span == null) {
return null;
} else if (span instanceof OTSpan) {
return ((OTSpan) span).getDelegate();
} else {
// NOOP Span
Expand All @@ -33,7 +35,9 @@ public AgentSpan toAgentSpan(final Span span) {
}

public Span toSpan(final AgentSpan agentSpan) {
if (agentSpan instanceof DDSpan) {
if (agentSpan == null) {
return null;
} else if (agentSpan instanceof DDSpan) {
return new OTSpan((DDSpan) agentSpan, this, logHandler);
} else {
// NOOP AgentSpans
Expand All @@ -45,7 +49,9 @@ public Span toSpan(final AgentSpan agentSpan) {
// That fact that some methods return AgentScope and other TraceScope even though its the same
// underlying object needs to be cleaned up
public Scope toScope(final Object scope) {
if (scope instanceof CustomScopeManagerWrapper.CustomScopeManagerScope) {
if (scope == null) {
return null;
} else if (scope instanceof CustomScopeManagerWrapper.CustomScopeManagerScope) {
return ((CustomScopeManagerWrapper.CustomScopeManagerScope) scope).getDelegate();
} else if (scope instanceof TraceScope) {
return new OTScopeManager.OTTraceScope((TraceScope) scope, this);
Expand All @@ -59,7 +65,9 @@ public SpanContext toSpanContext(final DDSpanContext context) {
}

public SpanContext toSpanContext(final TagContext tagContext) {
if (tagContext instanceof ExtractedContext) {
if (tagContext == null) {
return null;
} else if (tagContext instanceof ExtractedContext) {
return new OTExtractedContext((ExtractedContext) tagContext);
} else {
return new OTTagContext(tagContext);
Expand All @@ -69,7 +77,9 @@ public SpanContext toSpanContext(final TagContext tagContext) {
public AgentSpan.Context toContext(final SpanContext spanContext) {
// FIXME: [API] DDSpanContext, ExtractedContext, TagContext, AgentSpan.Context
// don't share a meaningful hierarchy
if (spanContext instanceof OTGenericContext) {
if (spanContext == null) {
return null;
} else if (spanContext instanceof OTGenericContext) {
return ((OTGenericContext) spanContext).getDelegate();
} else if (spanContext instanceof OTExtractedContext) {
return ((OTExtractedContext) spanContext).getDelegate();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,18 @@ class OpenTracingAPITest extends DDSpecification {
def scopeListener = Mock(ScopeListener)

def setup() {
assert tracer.scopeManager().active() == null
tracer.addTraceInterceptor(traceInterceptor)
tracer.addScopeListener(scopeListener)
}

def "tracer/scopeManager returns null for no active span"() {
expect:
tracer.activeSpan() == null
tracer.scopeManager().active() == null
tracer.scopeManager().activeSpan() == null
}

def "single span"() {
when:
Scope scope
Expand Down