Remove deprecated end() & endExceptionally() methods from BaseTracer
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
@@ -195,16 +195,6 @@ public abstract class BaseTracer {
end(Span.fromContext(context), endTimeNanos);
}
- /**
- * End span.
- *
- * @deprecated Use {@link #end(Context)} instead.
- */
- @Deprecated
- public void end(Span span) {
- end(span, -1);
- }
-
private void end(Span span, long endTimeNanos) {
if (endTimeNanos > 0) {
span.end(endTimeNanos, TimeUnit.NANOSECONDS);
@@ -221,16 +211,6 @@ public abstract class BaseTracer {
endExceptionally(Span.fromContext(context), throwable, endTimeNanos);
}
- /**
- * End span.
- *
- * @deprecated Use {@link #endExceptionally(Context, Throwable)} instead.
- */
- @Deprecated
- public void endExceptionally(Span span, Throwable throwable) {
- endExceptionally(span, throwable, -1);
- }
-
private void endExceptionally(Span span, Throwable throwable, long endTimeNanos) {
span.setStatus(StatusCode.ERROR);
onError(span, unwrapThrowable(throwable));

MODIFY
instrumentation/elasticsearch/elasticsearch-transport-5.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/elasticsearch/transport/v5_0/TransportActionListener.java
instrumentation/elasticsearch/elasticsearch-transport-5.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/elasticsearch/transport/v5_0/TransportActionListener.java
@@ -36,7 +36,7 @@ public class TransportActionListener<T extends ActionResponse> implements Action
private final Context context;
public TransportActionListener(
- ActionRequest actionRequest, ActionListener<T> listener, Context context) {
+ ActionRequest<?> actionRequest, ActionListener<T> listener, Context context) {
this.listener = listener;
this.context = context;
onRequest(actionRequest);
@@ -123,7 +123,7 @@ public class TransportActionListener<T extends ActionResponse> implements Action
}
}
- tracer().end(span);
+ tracer().end(context);
listener.onResponse(response);
}

MODIFY
instrumentation/elasticsearch/elasticsearch-transport-5.3/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/elasticsearch/transport/v5_3/TransportActionListener.java
instrumentation/elasticsearch/elasticsearch-transport-5.3/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/elasticsearch/transport/v5_3/TransportActionListener.java
@@ -124,7 +124,7 @@ public class TransportActionListener<T extends ActionResponse> implements Action
}
}
- tracer().end(span);
+ tracer().end(context);
listener.onResponse(response);
}

MODIFY
instrumentation/geode-1.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/geode/GeodeInstrumentationModule.java
instrumentation/geode-1.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/geode/GeodeInstrumentationModule.java
@@ -15,7 +15,7 @@ import static net.bytebuddy.matcher.ElementMatchers.named;
import static net.bytebuddy.matcher.ElementMatchers.takesArgument;
import com.google.auto.service.AutoService;
-import io.opentelemetry.api.trace.Span;
+import io.opentelemetry.context.Context;
import io.opentelemetry.context.Scope;
import io.opentelemetry.javaagent.instrumentation.api.CallDepthThreadLocalMap;
import io.opentelemetry.javaagent.tooling.InstrumentationModule;
@@ -85,19 +85,19 @@ public class GeodeInstrumentationModule extends InstrumentationModule {
public static void onEnter(
@Advice.This Region<?, ?> thiz,
@Advice.Origin Method method,
- @Advice.Local("otelSpan") Span span,
+ @Advice.Local("otelContext") Context context,
@Advice.Local("otelScope") Scope scope) {
if (CallDepthThreadLocalMap.incrementCallDepth(Region.class) > 0) {
return;
}
- span = tracer().startSpan(method.getName(), thiz, null);
- scope = span.makeCurrent();
+ context = tracer().startSpan(method.getName(), thiz, null);
+ scope = context.makeCurrent();
}
@Advice.OnMethodExit(onThrowable = Throwable.class, suppress = Throwable.class)
public static void stopSpan(
@Advice.Thrown Throwable throwable,
- @Advice.Local("otelSpan") Span span,
+ @Advice.Local("otelContext") Context context,
@Advice.Local("otelScope") Scope scope) {
if (scope == null) {
return;
@@ -106,9 +106,9 @@ public class GeodeInstrumentationModule extends InstrumentationModule {
CallDepthThreadLocalMap.reset(Region.class);
if (throwable != null) {
- tracer().endExceptionally(span, throwable);
+ tracer().endExceptionally(context, throwable);
} else {
- tracer().end(span);
+ tracer().end(context);
}
}
}
@@ -119,19 +119,19 @@ public class GeodeInstrumentationModule extends InstrumentationModule {
@Advice.This Region<?, ?> thiz,
@Advice.Origin Method method,
@Advice.Argument(0) String query,
- @Advice.Local("otelSpan") Span span,
+ @Advice.Local("otelContext") Context context,
@Advice.Local("otelScope") Scope scope) {
if (CallDepthThreadLocalMap.incrementCallDepth(Region.class) > 0) {
return;
}
- span = tracer().startSpan(method.getName(), thiz, query);
- scope = span.makeCurrent();
+ context = tracer().startSpan(method.getName(), thiz, query);
+ scope = context.makeCurrent();
}
@Advice.OnMethodExit(onThrowable = Throwable.class, suppress = Throwable.class)
public static void stopSpan(
@Advice.Thrown Throwable throwable,
- @Advice.Local("otelSpan") Span span,
+ @Advice.Local("otelContext") Context context,
@Advice.Local("otelScope") Scope scope) {
if (scope == null) {
return;
@@ -140,9 +140,9 @@ public class GeodeInstrumentationModule extends InstrumentationModule {
CallDepthThreadLocalMap.reset(Region.class);
if (throwable != null) {
- tracer().endExceptionally(span, throwable);
+ tracer().endExceptionally(context, throwable);
} else {
- tracer().end(span);
+ tracer().end(context);
}
}
}

MODIFY
instrumentation/geode-1.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/geode/GeodeTracer.java
instrumentation/geode-1.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/geode/GeodeTracer.java
@@ -7,8 +7,8 @@ package io.opentelemetry.javaagent.instrumentation.geode;
import static io.opentelemetry.api.trace.SpanKind.CLIENT;
-import io.opentelemetry.api.trace.Span;
import io.opentelemetry.api.trace.SpanBuilder;
+import io.opentelemetry.context.Context;
import io.opentelemetry.instrumentation.api.tracer.DatabaseClientTracer;
import io.opentelemetry.javaagent.instrumentation.api.db.SqlStatementInfo;
import io.opentelemetry.javaagent.instrumentation.api.db.SqlStatementSanitizer;
@@ -23,7 +23,7 @@ public class GeodeTracer extends DatabaseClientTracer<Region<?, ?>, String, SqlS
return TRACER;
}
- public Span startSpan(String operation, Region<?, ?> connection, String query) {
+ public Context startSpan(String operation, Region<?, ?> connection, String query) {
SqlStatementInfo sanitizedStatement = sanitizeStatement(query);
SpanBuilder span =
@@ -37,7 +37,7 @@ public class GeodeTracer extends DatabaseClientTracer<Region<?, ?>, String, SqlS
setNetSemanticConvention(span, connection);
onStatement(span, connection, query, sanitizedStatement);
- return span.startSpan();
+ return Context.current().with(span.startSpan());
}
@Override

MODIFY
instrumentation/lettuce/lettuce-5.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/lettuce/v5_0/rx/LettuceFluxTerminationRunnable.java
instrumentation/lettuce/lettuce-5.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/lettuce/v5_0/rx/LettuceFluxTerminationRunnable.java
@@ -38,22 +38,22 @@ public class LettuceFluxTerminationRunnable implements Consumer<Signal<?>>, Runn
private void finishSpan(boolean isCommandCancelled, Throwable throwable) {
if (context != null) {
- Span span = Span.fromContext(context);
if (CAPTURE_EXPERIMENTAL_SPAN_ATTRIBUTES) {
+ Span span = Span.fromContext(context);
span.setAttribute("lettuce.command.results.count", numResults);
if (isCommandCancelled) {
span.setAttribute("lettuce.command.cancelled", true);
}
}
if (throwable == null) {
- tracer().end(span);
+ tracer().end(context);
} else {
- tracer().endExceptionally(span, throwable);
+ tracer().endExceptionally(context, throwable);
}
} else {
LoggerFactory.getLogger(Flux.class)
.error(
- "Failed to finish this.span, LettuceFluxTerminationRunnable cannot find this.span "
+ "Failed to end this.context, LettuceFluxTerminationRunnable cannot find this.context "
+ "because it probably wasn't started.");
}
}

MODIFY
instrumentation/spymemcached-2.12/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/spymemcached/CompletionListener.java
instrumentation/spymemcached-2.12/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/spymemcached/CompletionListener.java
@@ -49,17 +49,17 @@ public abstract class CompletionListener<T> {
span.setAttribute(DB_COMMAND_CANCELLED, true);
}
} else {
- tracer().endExceptionally(span, e);
+ tracer().endExceptionally(context, e);
}
} catch (InterruptedException e) {
// Avoid swallowing InterruptedException
- tracer().endExceptionally(span, e);
+ tracer().endExceptionally(context, e);
Thread.currentThread().interrupt();
} catch (Exception e) {
// This should never happen, just in case to make sure we cover all unexpected exceptions
- tracer().endExceptionally(span, e);
+ tracer().endExceptionally(context, e);
} finally {
- tracer().end(span);
+ tracer().end(context);
}
}

Remove deprecated end() & endExceptionally() methods from BaseTracer (#2424)