Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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 @@ -45,7 +45,7 @@ public Scope makeCurrent() {
public <V> V get(ContextKey<V> key) {
if (OTEL_CONTEXT_SPAN_KEY.equals(key.toString())) {
AgentSpan span = AgentSpan.fromContext(delegate);
if (span != null) {
if (span != null && span.isValid()) {
return (V) toOtelSpan(span);
}
// fall-through and check for non-datadog span data
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import datadog.trace.agent.test.InstrumentationSpecification
import datadog.trace.api.DDSpanId
import datadog.trace.api.DDTraceId
import io.opentelemetry.api.GlobalOpenTelemetry
import io.opentelemetry.api.trace.Span
import io.opentelemetry.context.Context
import io.opentelemetry.context.ThreadLocalContextStorage
import io.opentelemetry.context.propagation.TextMapPropagator
Expand Down Expand Up @@ -102,6 +103,14 @@ abstract class AbstractPropagatorTest extends InstrumentationSpecification {
(headers, traceId, spanId, sampling) = values
}

def "extraction on missing tracecontext should return an empty context"() {
when:
def headers = ["User-Agent":"test"]
def context = propagator().extract(Context.root(), headers, TextMap.INSTANCE)
then:
assert Span.fromContextOrNull(context) == null : "Should not have a tracing context"
}

def expectedTraceId(String traceId) {
return DDTraceId.fromHex(traceId)
}
Expand Down