Deprecate the Tracer API
MODIFY
instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/tracer/AttributeSetter.java
instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/tracer/AttributeSetter.java
@@ -9,7 +9,12 @@ import io.opentelemetry.api.common.AttributeKey;
import io.opentelemetry.api.trace.Span;
import io.opentelemetry.api.trace.SpanBuilder;
-/** This helper interface allows setting attributes on both {@link Span} and {@link SpanBuilder}. */
+/**
+ * This helper interface allows setting attributes on both {@link Span} and {@link SpanBuilder}.
+ *
+ * @deprecated Use {@link io.opentelemetry.instrumentation.api.instrumenter.Instrumenter} instead.
+ */
+@Deprecated
@FunctionalInterface
public interface AttributeSetter {
<T> void setAttribute(AttributeKey<T> key, T value);

MODIFY
instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/tracer/BaseTracer.java
instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/tracer/BaseTracer.java
@@ -44,7 +44,10 @@ import javax.annotation.Nullable;
* <p>When constructing {@link Span}s tracers should set all attributes available during
* construction on a {@link SpanBuilder} instead of a {@link Span}. This way {@code SpanProcessor}s
* are able to see those attributes in the {@code onStart()} method and can freely read/modify them.
+ *
+ * @deprecated Use {@link io.opentelemetry.instrumentation.api.instrumenter.Instrumenter} instead.
*/
+@Deprecated
public abstract class BaseTracer {
private static final SupportabilityMetrics supportability = SupportabilityMetrics.instance();

MODIFY
instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/tracer/ClientSpan.java
instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/tracer/ClientSpan.java
@@ -14,7 +14,11 @@ import javax.annotation.Nullable;
/**
* This class encapsulates the context key for storing the current {@link SpanKind#CLIENT} span in
* the {@link Context}.
+ *
+ * @deprecated This class should not be used directly; it's functionality is encapsulated inside the
+ * {@linkplain io.opentelemetry.instrumentation.api.instrumenter.Instrumenter Instrumenter API}.
*/
+@Deprecated
public final class ClientSpan {
/** Returns true when a {@link SpanKind#CLIENT} span is present in the passed {@code context}. */

MODIFY
instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/tracer/ConsumerSpan.java
instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/tracer/ConsumerSpan.java
@@ -14,7 +14,11 @@ import javax.annotation.Nullable;
/**
* This class encapsulates the context key for storing the current {@link SpanKind#CONSUMER} span in
* the {@link Context}.
+ *
+ * @deprecated This class should not be used directly; it's functionality is encapsulated inside the
+ * {@linkplain io.opentelemetry.instrumentation.api.instrumenter.Instrumenter Instrumenter API}.
*/
+@Deprecated
public final class ConsumerSpan {
/**

MODIFY
instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/tracer/DatabaseClientTracer.java
instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/tracer/DatabaseClientTracer.java
@@ -21,7 +21,11 @@ import javax.annotation.Nullable;
* @param <CONNECTION> type of the database connection.
* @param <STATEMENT> type of the database statement being executed.
* @param <SANITIZEDSTATEMENT> type of the database statement after sanitization.
+ * @deprecated Use {@link io.opentelemetry.instrumentation.api.instrumenter.Instrumenter} and
+ * {@linkplain io.opentelemetry.instrumentation.api.instrumenter.db the database semantic
+ * convention utilities package} instead.
*/
+@Deprecated
public abstract class DatabaseClientTracer<CONNECTION, STATEMENT, SANITIZEDSTATEMENT>
extends BaseTracer {
private static final String DB_QUERY = "DB Query";

MODIFY
instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/tracer/HttpClientTracer.java
instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/tracer/HttpClientTracer.java
@@ -24,6 +24,14 @@ import javax.annotation.Nullable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+/**
+ * Base class for implementing Tracers for HTTP clients.
+ *
+ * @deprecated Use {@link io.opentelemetry.instrumentation.api.instrumenter.Instrumenter} and
+ * {@linkplain io.opentelemetry.instrumentation.api.instrumenter.http the HTTP semantic
+ * convention utilities package} instead.
+ */
+@Deprecated
public abstract class HttpClientTracer<REQUEST, CARRIER, RESPONSE> extends BaseTracer {
private static final Logger logger = LoggerFactory.getLogger(HttpClientTracer.class);

MODIFY
instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/tracer/RpcClientTracer.java
instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/tracer/RpcClientTracer.java
@@ -7,6 +7,14 @@ package io.opentelemetry.instrumentation.api.tracer;
import io.opentelemetry.api.OpenTelemetry;
+/**
+ * Base class for implementing Tracers for RPC clients.
+ *
+ * @deprecated Use {@link io.opentelemetry.instrumentation.api.instrumenter.Instrumenter} and
+ * {@linkplain io.opentelemetry.instrumentation.api.instrumenter.rpc the RPC semantic convention
+ * utilities package} instead.
+ */
+@Deprecated
public abstract class RpcClientTracer extends BaseTracer {
protected RpcClientTracer() {}

MODIFY
instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/tracer/RpcServerTracer.java
instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/tracer/RpcServerTracer.java
@@ -8,6 +8,14 @@ package io.opentelemetry.instrumentation.api.tracer;
import io.opentelemetry.api.OpenTelemetry;
import io.opentelemetry.context.propagation.TextMapGetter;
+/**
+ * Base class for implementing Tracers for RPC servers.
+ *
+ * @deprecated Use {@link io.opentelemetry.instrumentation.api.instrumenter.Instrumenter} and
+ * {@linkplain io.opentelemetry.instrumentation.api.instrumenter.rpc the RPC semantic convention
+ * utilities package} instead.
+ */
+@Deprecated
public abstract class RpcServerTracer<REQUEST> extends BaseTracer {
protected RpcServerTracer() {}

MODIFY
instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/tracer/ServerSpan.java
instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/tracer/ServerSpan.java
@@ -17,7 +17,14 @@ import javax.annotation.Nullable;
*/
public final class ServerSpan {
- /** Returns true when a {@link SpanKind#SERVER} span is present in the passed {@code context}. */
+ /**
+ * Returns true when a {@link SpanKind#SERVER} span is present in the passed {@code context}.
+ *
+ * @deprecated This method should not be used directly; it's functionality is encapsulated inside
+ * the {@linkplain io.opentelemetry.instrumentation.api.instrumenter.Instrumenter Instrumenter
+ * API}.
+ */
+ @Deprecated
public static boolean exists(Context context) {
return fromContextOrNull(context) != null;
}
@@ -31,6 +38,14 @@ public final class ServerSpan {
return SpanKey.SERVER.fromContextOrNull(context);
}
+ /**
+ * Marks the span as the server span in the passed context.
+ *
+ * @deprecated This method should not be used directly; it's functionality is encapsulated inside
+ * the {@linkplain io.opentelemetry.instrumentation.api.instrumenter.Instrumenter Instrumenter
+ * API}.
+ */
+ @Deprecated
public static Context with(Context context, Span serverSpan) {
return SpanKey.SERVER.storeInContext(context, serverSpan);
}

MODIFY
instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/tracer/net/NetPeerAttributes.java
instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/tracer/net/NetPeerAttributes.java
@@ -16,11 +16,16 @@ import java.util.Collections;
import java.util.Map;
import javax.annotation.Nullable;
+/**
+ * Utility class settings the {@code net.peer.*} attributes.
+ *
+ * @deprecated Use {@link io.opentelemetry.instrumentation.api.instrumenter.Instrumenter} and
+ * {@linkplain io.opentelemetry.instrumentation.api.instrumenter.net the net semantic convention
+ * utilities package} instead.
+ */
+@Deprecated
public final class NetPeerAttributes {
- // TODO: this should only be used by the javaagent; move to javaagent-instrumentation-api after
- // removing all
- // library usages
public static final NetPeerAttributes INSTANCE =
new NetPeerAttributes(
Config.get().getMap("otel.instrumentation.common.peer-service-mapping"));

MODIFY
instrumentation/opentelemetry-api/opentelemetry-api-1.0/javaagent/src/test/groovy/ContextBridgeTest.groovy
instrumentation/opentelemetry-api/opentelemetry-api-1.0/javaagent/src/test/groovy/ContextBridgeTest.groovy
@@ -10,7 +10,6 @@ import io.opentelemetry.context.Context
import io.opentelemetry.context.ContextKey
import io.opentelemetry.extension.annotations.WithSpan
import io.opentelemetry.instrumentation.api.instrumenter.SpanKey
-import io.opentelemetry.instrumentation.api.tracer.ClientSpan
import io.opentelemetry.instrumentation.api.tracer.ServerSpan
import io.opentelemetry.instrumentation.test.AgentInstrumentationSpecification
@@ -160,17 +159,6 @@ class ContextBridgeTest extends AgentInstrumentationSpecification {
}
}
- def "test client span bridge"() {
- expect:
- AgentSpanTesting.runWithClientSpan("client") {
- assert Span.current() != null
- assert ClientSpan.fromContextOrNull(Context.current()) != null
- runWithSpan("internal") {
- assert ClientSpan.fromContextOrNull(Context.current()) != null
- }
- }
- }
-
def "test span key bridge"() {
expect:
AgentSpanTesting.runWithAllSpanKeys("parent") {

Deprecate the Tracer API (#4868)