diff --git a/dd-java-agent/agent-otel/otel-shim/src/main/java/datadog/opentelemetry/shim/trace/OtelSpan.java b/dd-java-agent/agent-otel/otel-shim/src/main/java/datadog/opentelemetry/shim/trace/OtelSpan.java index 4fddc5f5aa8..c002b2fc3f6 100644 --- a/dd-java-agent/agent-otel/otel-shim/src/main/java/datadog/opentelemetry/shim/trace/OtelSpan.java +++ b/dd-java-agent/agent-otel/otel-shim/src/main/java/datadog/opentelemetry/shim/trace/OtelSpan.java @@ -112,13 +112,13 @@ public Span setStatus(StatusCode statusCode, String description) { } /** - * Records information about the Throwable as a span event - * exception.escaped cannot be determined by this function and therefore is not automatically recorded. Record this manually using additionalAttributes - * See: ... + * Records information about the Throwable as a span event exception.escaped cannot be determined + * by this function and therefore is not automatically recorded. Record this manually using + * additionalAttributes See: ... * * @param exception the Throwable to record * @param additionalAttributes the additional attributes to record - * */ @Override public Span recordException(Throwable exception, Attributes additionalAttributes) { diff --git a/dd-java-agent/agent-otel/otel-shim/src/main/java/datadog/opentelemetry/shim/trace/SpanEvent.java b/dd-java-agent/agent-otel/otel-shim/src/main/java/datadog/opentelemetry/shim/trace/SpanEvent.java index eac9b71c5bc..96ac09aeb39 100644 --- a/dd-java-agent/agent-otel/otel-shim/src/main/java/datadog/opentelemetry/shim/trace/SpanEvent.java +++ b/dd-java-agent/agent-otel/otel-shim/src/main/java/datadog/opentelemetry/shim/trace/SpanEvent.java @@ -1,15 +1,13 @@ package datadog.opentelemetry.shim.trace; +import datadog.trace.api.time.SystemTimeSource; +import datadog.trace.api.time.TimeSource; import datadog.trace.bootstrap.instrumentation.api.AgentSpan; import datadog.trace.bootstrap.instrumentation.api.SpanAttributes; import edu.umd.cs.findbugs.annotations.NonNull; import io.opentelemetry.api.common.Attributes; - -import java.sql.Time; import java.util.List; import java.util.concurrent.TimeUnit; -import datadog.trace.api.time.SystemTimeSource; -import datadog.trace.api.time.TimeSource; public class SpanEvent { diff --git a/dd-java-agent/instrumentation/opentelemetry/opentelemetry-1.4/src/test/groovy/OpenTelemetry14Test.groovy b/dd-java-agent/instrumentation/opentelemetry/opentelemetry-1.4/src/test/groovy/OpenTelemetry14Test.groovy index b37e9b86afb..c3d86465104 100644 --- a/dd-java-agent/instrumentation/opentelemetry/opentelemetry-1.4/src/test/groovy/OpenTelemetry14Test.groovy +++ b/dd-java-agent/instrumentation/opentelemetry/opentelemetry-1.4/src/test/groovy/OpenTelemetry14Test.groovy @@ -257,37 +257,37 @@ class OpenTelemetry14Test extends AgentTestRunner { } } - def "test add event no timestamp"() { - setup: - def builder = tracer.spanBuilder("some-name") - def timeSource = new ControllableTimeSource(); - timeSource.set(1000); - SpanEvent.setTimeSource(timeSource); - - when: - def result = builder.startSpan() - result.addEvent("evt", null, ) - result.end() - - then: - def expectedEventTag = """ + def "test add event no timestamp"() { + setup: + def builder = tracer.spanBuilder("some-name") + def timeSource = new ControllableTimeSource() + timeSource.set(1000) + SpanEvent.setTimeSource(timeSource) + + when: + def result = builder.startSpan() + result.addEvent("evt", null, ) + result.end() + + then: + def expectedEventTag = """ [ { "time_unix_nano": ${timeSource.getCurrentTimeNanos()}, "name": "evt" } ]""" - assertTraces(1) { - trace(1) { - span { - tags { - defaultTags() - "$SPAN_KIND" "$SPAN_KIND_INTERNAL" - tag("events", { JSONAssert.assertEquals(expectedEventTag, it as String, false); return true }) - } - } + assertTraces(1) { + trace(1) { + span { + tags { + defaultTags() + "$SPAN_KIND" "$SPAN_KIND_INTERNAL" + tag("events", { JSONAssert.assertEquals(expectedEventTag, it as String, false); return true }) } } } + } + } def "test simple span links"() { setup: