Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate the Tracer API #4868

Merged
merged 1 commit into from
Dec 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,12 @@
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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,10 @@
* <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();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@
/**
* 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}. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@
/**
* 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 {

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,11 @@
* @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";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,14 @@
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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,14 @@
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() {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,14 @@
*/
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;
}
Expand All @@ -31,6 +38,14 @@ public static Span fromContextOrNull(Context context) {
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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,16 @@
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"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

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