Remove deprecated end() & endExceptionally() methods from BaseTracer (#2424)
This commit is contained in:
parent
d8e630a0a8
commit
163062d13e
|
@ -195,16 +195,6 @@ public abstract class BaseTracer {
|
||||||
end(Span.fromContext(context), endTimeNanos);
|
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) {
|
private void end(Span span, long endTimeNanos) {
|
||||||
if (endTimeNanos > 0) {
|
if (endTimeNanos > 0) {
|
||||||
span.end(endTimeNanos, TimeUnit.NANOSECONDS);
|
span.end(endTimeNanos, TimeUnit.NANOSECONDS);
|
||||||
|
@ -221,16 +211,6 @@ public abstract class BaseTracer {
|
||||||
endExceptionally(Span.fromContext(context), throwable, endTimeNanos);
|
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) {
|
private void endExceptionally(Span span, Throwable throwable, long endTimeNanos) {
|
||||||
span.setStatus(StatusCode.ERROR);
|
span.setStatus(StatusCode.ERROR);
|
||||||
onError(span, unwrapThrowable(throwable));
|
onError(span, unwrapThrowable(throwable));
|
||||||
|
|
|
@ -36,7 +36,7 @@ public class TransportActionListener<T extends ActionResponse> implements Action
|
||||||
private final Context context;
|
private final Context context;
|
||||||
|
|
||||||
public TransportActionListener(
|
public TransportActionListener(
|
||||||
ActionRequest actionRequest, ActionListener<T> listener, Context context) {
|
ActionRequest<?> actionRequest, ActionListener<T> listener, Context context) {
|
||||||
this.listener = listener;
|
this.listener = listener;
|
||||||
this.context = context;
|
this.context = context;
|
||||||
onRequest(actionRequest);
|
onRequest(actionRequest);
|
||||||
|
@ -123,7 +123,7 @@ public class TransportActionListener<T extends ActionResponse> implements Action
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tracer().end(span);
|
tracer().end(context);
|
||||||
listener.onResponse(response);
|
listener.onResponse(response);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -124,7 +124,7 @@ public class TransportActionListener<T extends ActionResponse> implements Action
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tracer().end(span);
|
tracer().end(context);
|
||||||
listener.onResponse(response);
|
listener.onResponse(response);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,7 @@ import static net.bytebuddy.matcher.ElementMatchers.named;
|
||||||
import static net.bytebuddy.matcher.ElementMatchers.takesArgument;
|
import static net.bytebuddy.matcher.ElementMatchers.takesArgument;
|
||||||
|
|
||||||
import com.google.auto.service.AutoService;
|
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.context.Scope;
|
||||||
import io.opentelemetry.javaagent.instrumentation.api.CallDepthThreadLocalMap;
|
import io.opentelemetry.javaagent.instrumentation.api.CallDepthThreadLocalMap;
|
||||||
import io.opentelemetry.javaagent.tooling.InstrumentationModule;
|
import io.opentelemetry.javaagent.tooling.InstrumentationModule;
|
||||||
|
@ -85,19 +85,19 @@ public class GeodeInstrumentationModule extends InstrumentationModule {
|
||||||
public static void onEnter(
|
public static void onEnter(
|
||||||
@Advice.This Region<?, ?> thiz,
|
@Advice.This Region<?, ?> thiz,
|
||||||
@Advice.Origin Method method,
|
@Advice.Origin Method method,
|
||||||
@Advice.Local("otelSpan") Span span,
|
@Advice.Local("otelContext") Context context,
|
||||||
@Advice.Local("otelScope") Scope scope) {
|
@Advice.Local("otelScope") Scope scope) {
|
||||||
if (CallDepthThreadLocalMap.incrementCallDepth(Region.class) > 0) {
|
if (CallDepthThreadLocalMap.incrementCallDepth(Region.class) > 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
span = tracer().startSpan(method.getName(), thiz, null);
|
context = tracer().startSpan(method.getName(), thiz, null);
|
||||||
scope = span.makeCurrent();
|
scope = context.makeCurrent();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Advice.OnMethodExit(onThrowable = Throwable.class, suppress = Throwable.class)
|
@Advice.OnMethodExit(onThrowable = Throwable.class, suppress = Throwable.class)
|
||||||
public static void stopSpan(
|
public static void stopSpan(
|
||||||
@Advice.Thrown Throwable throwable,
|
@Advice.Thrown Throwable throwable,
|
||||||
@Advice.Local("otelSpan") Span span,
|
@Advice.Local("otelContext") Context context,
|
||||||
@Advice.Local("otelScope") Scope scope) {
|
@Advice.Local("otelScope") Scope scope) {
|
||||||
if (scope == null) {
|
if (scope == null) {
|
||||||
return;
|
return;
|
||||||
|
@ -106,9 +106,9 @@ public class GeodeInstrumentationModule extends InstrumentationModule {
|
||||||
|
|
||||||
CallDepthThreadLocalMap.reset(Region.class);
|
CallDepthThreadLocalMap.reset(Region.class);
|
||||||
if (throwable != null) {
|
if (throwable != null) {
|
||||||
tracer().endExceptionally(span, throwable);
|
tracer().endExceptionally(context, throwable);
|
||||||
} else {
|
} else {
|
||||||
tracer().end(span);
|
tracer().end(context);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -119,19 +119,19 @@ public class GeodeInstrumentationModule extends InstrumentationModule {
|
||||||
@Advice.This Region<?, ?> thiz,
|
@Advice.This Region<?, ?> thiz,
|
||||||
@Advice.Origin Method method,
|
@Advice.Origin Method method,
|
||||||
@Advice.Argument(0) String query,
|
@Advice.Argument(0) String query,
|
||||||
@Advice.Local("otelSpan") Span span,
|
@Advice.Local("otelContext") Context context,
|
||||||
@Advice.Local("otelScope") Scope scope) {
|
@Advice.Local("otelScope") Scope scope) {
|
||||||
if (CallDepthThreadLocalMap.incrementCallDepth(Region.class) > 0) {
|
if (CallDepthThreadLocalMap.incrementCallDepth(Region.class) > 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
span = tracer().startSpan(method.getName(), thiz, query);
|
context = tracer().startSpan(method.getName(), thiz, query);
|
||||||
scope = span.makeCurrent();
|
scope = context.makeCurrent();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Advice.OnMethodExit(onThrowable = Throwable.class, suppress = Throwable.class)
|
@Advice.OnMethodExit(onThrowable = Throwable.class, suppress = Throwable.class)
|
||||||
public static void stopSpan(
|
public static void stopSpan(
|
||||||
@Advice.Thrown Throwable throwable,
|
@Advice.Thrown Throwable throwable,
|
||||||
@Advice.Local("otelSpan") Span span,
|
@Advice.Local("otelContext") Context context,
|
||||||
@Advice.Local("otelScope") Scope scope) {
|
@Advice.Local("otelScope") Scope scope) {
|
||||||
if (scope == null) {
|
if (scope == null) {
|
||||||
return;
|
return;
|
||||||
|
@ -140,9 +140,9 @@ public class GeodeInstrumentationModule extends InstrumentationModule {
|
||||||
|
|
||||||
CallDepthThreadLocalMap.reset(Region.class);
|
CallDepthThreadLocalMap.reset(Region.class);
|
||||||
if (throwable != null) {
|
if (throwable != null) {
|
||||||
tracer().endExceptionally(span, throwable);
|
tracer().endExceptionally(context, throwable);
|
||||||
} else {
|
} else {
|
||||||
tracer().end(span);
|
tracer().end(context);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,8 +7,8 @@ package io.opentelemetry.javaagent.instrumentation.geode;
|
||||||
|
|
||||||
import static io.opentelemetry.api.trace.SpanKind.CLIENT;
|
import static io.opentelemetry.api.trace.SpanKind.CLIENT;
|
||||||
|
|
||||||
import io.opentelemetry.api.trace.Span;
|
|
||||||
import io.opentelemetry.api.trace.SpanBuilder;
|
import io.opentelemetry.api.trace.SpanBuilder;
|
||||||
|
import io.opentelemetry.context.Context;
|
||||||
import io.opentelemetry.instrumentation.api.tracer.DatabaseClientTracer;
|
import io.opentelemetry.instrumentation.api.tracer.DatabaseClientTracer;
|
||||||
import io.opentelemetry.javaagent.instrumentation.api.db.SqlStatementInfo;
|
import io.opentelemetry.javaagent.instrumentation.api.db.SqlStatementInfo;
|
||||||
import io.opentelemetry.javaagent.instrumentation.api.db.SqlStatementSanitizer;
|
import io.opentelemetry.javaagent.instrumentation.api.db.SqlStatementSanitizer;
|
||||||
|
@ -23,7 +23,7 @@ public class GeodeTracer extends DatabaseClientTracer<Region<?, ?>, String, SqlS
|
||||||
return TRACER;
|
return TRACER;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Span startSpan(String operation, Region<?, ?> connection, String query) {
|
public Context startSpan(String operation, Region<?, ?> connection, String query) {
|
||||||
SqlStatementInfo sanitizedStatement = sanitizeStatement(query);
|
SqlStatementInfo sanitizedStatement = sanitizeStatement(query);
|
||||||
|
|
||||||
SpanBuilder span =
|
SpanBuilder span =
|
||||||
|
@ -37,7 +37,7 @@ public class GeodeTracer extends DatabaseClientTracer<Region<?, ?>, String, SqlS
|
||||||
setNetSemanticConvention(span, connection);
|
setNetSemanticConvention(span, connection);
|
||||||
onStatement(span, connection, query, sanitizedStatement);
|
onStatement(span, connection, query, sanitizedStatement);
|
||||||
|
|
||||||
return span.startSpan();
|
return Context.current().with(span.startSpan());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -38,22 +38,22 @@ public class LettuceFluxTerminationRunnable implements Consumer<Signal<?>>, Runn
|
||||||
|
|
||||||
private void finishSpan(boolean isCommandCancelled, Throwable throwable) {
|
private void finishSpan(boolean isCommandCancelled, Throwable throwable) {
|
||||||
if (context != null) {
|
if (context != null) {
|
||||||
Span span = Span.fromContext(context);
|
|
||||||
if (CAPTURE_EXPERIMENTAL_SPAN_ATTRIBUTES) {
|
if (CAPTURE_EXPERIMENTAL_SPAN_ATTRIBUTES) {
|
||||||
|
Span span = Span.fromContext(context);
|
||||||
span.setAttribute("lettuce.command.results.count", numResults);
|
span.setAttribute("lettuce.command.results.count", numResults);
|
||||||
if (isCommandCancelled) {
|
if (isCommandCancelled) {
|
||||||
span.setAttribute("lettuce.command.cancelled", true);
|
span.setAttribute("lettuce.command.cancelled", true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (throwable == null) {
|
if (throwable == null) {
|
||||||
tracer().end(span);
|
tracer().end(context);
|
||||||
} else {
|
} else {
|
||||||
tracer().endExceptionally(span, throwable);
|
tracer().endExceptionally(context, throwable);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
LoggerFactory.getLogger(Flux.class)
|
LoggerFactory.getLogger(Flux.class)
|
||||||
.error(
|
.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.");
|
+ "because it probably wasn't started.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,17 +49,17 @@ public abstract class CompletionListener<T> {
|
||||||
span.setAttribute(DB_COMMAND_CANCELLED, true);
|
span.setAttribute(DB_COMMAND_CANCELLED, true);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
tracer().endExceptionally(span, e);
|
tracer().endExceptionally(context, e);
|
||||||
}
|
}
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
// Avoid swallowing InterruptedException
|
// Avoid swallowing InterruptedException
|
||||||
tracer().endExceptionally(span, e);
|
tracer().endExceptionally(context, e);
|
||||||
Thread.currentThread().interrupt();
|
Thread.currentThread().interrupt();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
// This should never happen, just in case to make sure we cover all unexpected exceptions
|
// This should never happen, just in case to make sure we cover all unexpected exceptions
|
||||||
tracer().endExceptionally(span, e);
|
tracer().endExceptionally(context, e);
|
||||||
} finally {
|
} finally {
|
||||||
tracer().end(span);
|
tracer().end(context);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue