Deprecate the Tracer API (#4868)

This commit is contained in:
Mateusz Rzeszutek 2021-12-12 21:14:36 +01:00 committed by GitHub
parent 9950c488c8
commit ca2bce9608
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 69 additions and 17 deletions

View File

@ -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);

View File

@ -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();

View File

@ -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}. */

View File

@ -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 {
/**

View File

@ -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";

View File

@ -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);

View File

@ -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() {}

View File

@ -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() {}

View File

@ -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);
}

View File

@ -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"));

View File

@ -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") {