diff --git a/common/src/main/java/co/elastic/otel/common/LocalRootSpan.java b/common/src/main/java/co/elastic/otel/common/LocalRootSpan.java index f1924f35..708c41ae 100644 --- a/common/src/main/java/co/elastic/otel/common/LocalRootSpan.java +++ b/common/src/main/java/co/elastic/otel/common/LocalRootSpan.java @@ -108,10 +108,12 @@ public static ReadableSpan getFor(ReadableSpan span) { */ @Nullable public static ReadableSpan getFor(Span span) { - if (span.getSpanContext().isRemote()) { + if (span instanceof ReadableSpan) { + return getFor((ReadableSpan) span); + } else { + // This can happen when invoked for a PropagatedSpan (e.g. Span.fromContext()) return null; } - return getFor((ReadableSpan) span); } /** See {@link LocalRootSpan#getFor(Span)}. */ diff --git a/testing/integration-tests/inferred-spans-test/build.gradle.kts b/testing/integration-tests/inferred-spans-test/build.gradle.kts index e72423a2..c0488658 100644 --- a/testing/integration-tests/inferred-spans-test/build.gradle.kts +++ b/testing/integration-tests/inferred-spans-test/build.gradle.kts @@ -11,6 +11,7 @@ dependencies { tasks.withType() { jvmArgs( //"-Dotel.javaagent.debug=true", + "-Dotel.service.name=testing", "-Delastic.otel.inferred.spans.enabled=true", "-Delastic.otel.inferred.spans.duration=2000ms", "-Delastic.otel.inferred.spans.interval=2000ms",