diff --git a/dd-java-agent/agent-otel/otel-shim/src/main/java/datadog/opentelemetry/shim/trace/OtelConventions.java b/dd-java-agent/agent-otel/otel-shim/src/main/java/datadog/opentelemetry/shim/trace/OtelConventions.java index af1b2954b92..6c6bfa1bc8c 100644 --- a/dd-java-agent/agent-otel/otel-shim/src/main/java/datadog/opentelemetry/shim/trace/OtelConventions.java +++ b/dd-java-agent/agent-otel/otel-shim/src/main/java/datadog/opentelemetry/shim/trace/OtelConventions.java @@ -15,10 +15,10 @@ import static java.util.Locale.ROOT; import datadog.trace.bootstrap.instrumentation.api.AgentSpan; -import datadog.trace.bootstrap.instrumentation.api.AgentSpanAttributes; import datadog.trace.bootstrap.instrumentation.api.SpanAttributes; import datadog.trace.bootstrap.instrumentation.api.Tags; import io.opentelemetry.api.common.AttributeKey; +import io.opentelemetry.api.common.Attributes; import io.opentelemetry.api.trace.SpanKind; import java.util.List; import javax.annotation.Nullable; @@ -228,8 +228,7 @@ private static String getStringAttribute(AgentSpan span, String key) { return (String) tag; } - public static AgentSpanAttributes convertAttributes( - io.opentelemetry.api.common.Attributes attributes) { + public static AgentSpan.Attributes convertAttributes(Attributes attributes) { if (attributes.isEmpty()) { return SpanAttributes.EMPTY; } diff --git a/dd-trace-core/src/main/java/datadog/trace/core/DDSpanLink.java b/dd-trace-core/src/main/java/datadog/trace/core/DDSpanLink.java index 2740123fb80..527bed62d01 100644 --- a/dd-trace-core/src/main/java/datadog/trace/core/DDSpanLink.java +++ b/dd-trace-core/src/main/java/datadog/trace/core/DDSpanLink.java @@ -8,7 +8,7 @@ import com.squareup.moshi.ToJson; import datadog.trace.api.DDSpanId; import datadog.trace.api.DDTraceId; -import datadog.trace.bootstrap.instrumentation.api.AgentSpanAttributes; +import datadog.trace.bootstrap.instrumentation.api.AgentSpan; import datadog.trace.bootstrap.instrumentation.api.AgentSpanLink; import datadog.trace.bootstrap.instrumentation.api.SpanAttributes; import datadog.trace.bootstrap.instrumentation.api.SpanLink; @@ -30,7 +30,7 @@ protected DDSpanLink( long spanId, byte traceFlags, String traceState, - AgentSpanAttributes attributes) { + AgentSpan.Attributes attributes) { super(traceId, spanId, traceFlags, traceState, attributes); } @@ -53,7 +53,7 @@ public static SpanLink from(ExtractedContext context) { * @param attributes The span link attributes. * @return A span link to the given context with custom attributes. */ - public static SpanLink from(ExtractedContext context, AgentSpanAttributes attributes) { + public static SpanLink from(ExtractedContext context, AgentSpan.Attributes attributes) { byte traceFlags = context.getSamplingPriority() > 0 ? SAMPLED_FLAG : DEFAULT_FLAGS; String traceState = context.getPropagationTags() == null diff --git a/internal-api/src/main/java/datadog/trace/bootstrap/instrumentation/api/AgentSpan.java b/internal-api/src/main/java/datadog/trace/bootstrap/instrumentation/api/AgentSpan.java index f523eb265e2..480d60791a1 100644 --- a/internal-api/src/main/java/datadog/trace/bootstrap/instrumentation/api/AgentSpan.java +++ b/internal-api/src/main/java/datadog/trace/bootstrap/instrumentation/api/AgentSpan.java @@ -228,4 +228,20 @@ interface Extracted extends Context { String getCustomIpHeader(); } } + + public interface Attributes { + /** + * Gets the attributes as an immutable map. + * + * @return The attributes as an immutable map. + */ + Map asMap(); + + /** + * Checks whether the attributes are empty. + * + * @return {@code true} if the attributes are empty, {@code false} otherwise. + */ + boolean isEmpty(); + } } diff --git a/internal-api/src/main/java/datadog/trace/bootstrap/instrumentation/api/AgentSpanAttributes.java b/internal-api/src/main/java/datadog/trace/bootstrap/instrumentation/api/AgentSpanAttributes.java deleted file mode 100644 index 4ab2cc37c94..00000000000 --- a/internal-api/src/main/java/datadog/trace/bootstrap/instrumentation/api/AgentSpanAttributes.java +++ /dev/null @@ -1,19 +0,0 @@ -package datadog.trace.bootstrap.instrumentation.api; - -import java.util.Map; - -public interface AgentSpanAttributes { - /** - * Gets the attributes as an immutable map. - * - * @return The attributes as an immutable map. - */ - Map asMap(); - - /** - * Checks whether the attributes are empty. - * - * @return {@code true} if the attributes are empty, {@code false} otherwise. - */ - boolean isEmpty(); -} diff --git a/internal-api/src/main/java/datadog/trace/bootstrap/instrumentation/api/AgentSpanLink.java b/internal-api/src/main/java/datadog/trace/bootstrap/instrumentation/api/AgentSpanLink.java index 2c59dc0be93..589bbcb1850 100644 --- a/internal-api/src/main/java/datadog/trace/bootstrap/instrumentation/api/AgentSpanLink.java +++ b/internal-api/src/main/java/datadog/trace/bootstrap/instrumentation/api/AgentSpanLink.java @@ -49,5 +49,5 @@ public interface AgentSpanLink { * * @return The link attributes. */ - AgentSpanAttributes attributes(); + AgentSpan.Attributes attributes(); } diff --git a/internal-api/src/main/java/datadog/trace/bootstrap/instrumentation/api/SpanAttributes.java b/internal-api/src/main/java/datadog/trace/bootstrap/instrumentation/api/SpanAttributes.java index a614fffe541..247f2574b3a 100644 --- a/internal-api/src/main/java/datadog/trace/bootstrap/instrumentation/api/SpanAttributes.java +++ b/internal-api/src/main/java/datadog/trace/bootstrap/instrumentation/api/SpanAttributes.java @@ -8,9 +8,10 @@ import java.util.Map; /** This class is a base implementation of {@link AgentSpanAttributes}. */ -public class SpanAttributes implements AgentSpanAttributes { +// TODO: How to link to AgentSpan.Attributes? +public class SpanAttributes implements AgentSpan.Attributes { /** Represent an empty attributes. */ - public static final AgentSpanAttributes EMPTY = new SpanAttributes(Collections.emptyMap()); + public static final AgentSpan.Attributes EMPTY = new SpanAttributes(Collections.emptyMap()); private final Map attributes; @@ -114,7 +115,7 @@ protected Builder putArray(String key, List array) { return this; } - public AgentSpanAttributes build() { + public AgentSpan.Attributes build() { return new SpanAttributes(this.attributes); } } diff --git a/internal-api/src/main/java/datadog/trace/bootstrap/instrumentation/api/SpanLink.java b/internal-api/src/main/java/datadog/trace/bootstrap/instrumentation/api/SpanLink.java index 820d28f5ee2..0a0ded3a61c 100644 --- a/internal-api/src/main/java/datadog/trace/bootstrap/instrumentation/api/SpanLink.java +++ b/internal-api/src/main/java/datadog/trace/bootstrap/instrumentation/api/SpanLink.java @@ -10,14 +10,14 @@ public class SpanLink implements AgentSpanLink { private final long spanId; private final byte traceFlags; private final String traceState; - private final AgentSpanAttributes attributes; + private final AgentSpan.Attributes attributes; protected SpanLink( DDTraceId traceId, long spanId, byte traceFlags, String traceState, - AgentSpanAttributes attributes) { + AgentSpan.Attributes attributes) { this.traceId = traceId == null ? DDTraceId.ZERO : traceId; this.spanId = spanId; this.traceFlags = traceFlags; @@ -50,7 +50,7 @@ public static SpanLink from( AgentSpan.Context context, byte traceFlags, String traceState, - AgentSpanAttributes attributes) { + AgentSpan.Attributes attributes) { if (context.getSamplingPriority() > 0) { traceFlags = (byte) (traceFlags | SAMPLED_FLAG); } @@ -79,7 +79,7 @@ public String traceState() { } @Override - public AgentSpanAttributes attributes() { + public AgentSpan.Attributes attributes() { return this.attributes; }