Skip to content
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 @@ -327,8 +327,15 @@ public <REQUEST, RESPONSE> Context suppressSpan(
Instrumenter<REQUEST, RESPONSE> instrumenter,
Context parentContext,
REQUEST request) {
SpanKind spanKind = instrumenter.spanKindExtractor.extract(request);
return suppressSpan(
instrumenter, parentContext, instrumenter.spanKindExtractor.extract(request));
}

@Override
public <REQUEST, RESPONSE> Context suppressSpan(
Instrumenter<REQUEST, RESPONSE> instrumenter,
Context parentContext,
SpanKind spanKind) {
return instrumenter.spanSuppressor.storeInContext(
parentContext, spanKind, Span.getInvalid());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

package io.opentelemetry.instrumentation.api.internal;

import io.opentelemetry.api.trace.SpanKind;
import io.opentelemetry.context.Context;
import io.opentelemetry.instrumentation.api.instrumenter.Instrumenter;
import java.time.Instant;
Expand All @@ -27,4 +28,7 @@ <REQUEST, RESPONSE> Context startAndEnd(

<REQUEST, RESPONSE> Context suppressSpan(
Instrumenter<REQUEST, RESPONSE> instrumenter, Context parentContext, REQUEST request);

<REQUEST, RESPONSE> Context suppressSpan(
Instrumenter<REQUEST, RESPONSE> instrumenter, Context parentContext, SpanKind spanKind);
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
package io.opentelemetry.instrumentation.api.internal;

import com.google.errorprone.annotations.CanIgnoreReturnValue;
import io.opentelemetry.api.trace.SpanKind;
import io.opentelemetry.context.Context;
import io.opentelemetry.context.propagation.TextMapGetter;
import io.opentelemetry.context.propagation.TextMapSetter;
Expand Down Expand Up @@ -53,6 +54,11 @@ public static <REQUEST, RESPONSE> Context suppressSpan(
return instrumenterAccess.suppressSpan(instrumenter, parentContext, request);
}

public static <REQUEST, RESPONSE> Context suppressSpan(
Instrumenter<REQUEST, RESPONSE> instrumenter, Context parentContext, SpanKind spanKind) {
return instrumenterAccess.suppressSpan(instrumenter, parentContext, spanKind);
}

public static <REQUEST, RESPONSE> Instrumenter<REQUEST, RESPONSE> buildUpstreamInstrumenter(
InstrumenterBuilder<REQUEST, RESPONSE> builder,
TextMapGetter<REQUEST> getter,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
package io.opentelemetry.javaagent.instrumentation.jms;

import com.google.auto.value.AutoValue;
import javax.annotation.Nullable;

@AutoValue
public abstract class MessageWithDestination {
Expand All @@ -20,7 +21,7 @@ public abstract class MessageWithDestination {
public abstract boolean isTemporaryDestination();

public static MessageWithDestination create(
MessageAdapter message, DestinationAdapter fallbackDestination) {
MessageAdapter message, @Nullable DestinationAdapter fallbackDestination) {
DestinationAdapter jmsDestination = null;
try {
jmsDestination = message.getJmsDestination();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
plugins {
id("otel.javaagent-instrumentation")
id("otel.nullaway-conventions")
}

muzzle {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import io.opentelemetry.javaagent.bootstrap.jms.JmsReceiveContextHolder;
import io.opentelemetry.javaagent.extension.instrumentation.TypeInstrumentation;
import io.opentelemetry.javaagent.extension.instrumentation.TypeTransformer;
import javax.annotation.Nullable;
import net.bytebuddy.asm.Advice;
import net.bytebuddy.description.type.TypeDescription;
import net.bytebuddy.matcher.ElementMatcher;
Expand All @@ -34,6 +35,7 @@ public void transform(TypeTransformer transformer) {
public static class ReceiveAndExecuteAdvice {

@Advice.OnMethodEnter(suppress = Throwable.class)
@Nullable
public static Scope onEnter() {
if (isReceiveTelemetryEnabled()) {
Context context = JmsReceiveContextHolder.init(Java8BytecodeBridge.currentContext());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,14 @@
import static net.bytebuddy.matcher.ElementMatchers.named;
import static net.bytebuddy.matcher.ElementMatchers.returns;

import io.opentelemetry.api.trace.SpanKind;
import io.opentelemetry.context.Context;
import io.opentelemetry.context.Scope;
import io.opentelemetry.instrumentation.api.internal.InstrumenterUtil;
import io.opentelemetry.javaagent.bootstrap.Java8BytecodeBridge;
import io.opentelemetry.javaagent.extension.instrumentation.TypeInstrumentation;
import io.opentelemetry.javaagent.extension.instrumentation.TypeTransformer;
import javax.annotation.Nullable;
import net.bytebuddy.asm.Advice;
import net.bytebuddy.description.type.TypeDescription;
import net.bytebuddy.matcher.ElementMatcher;
Expand All @@ -37,14 +39,15 @@ public void transform(TypeTransformer transformer) {
public static class ReceiveAdvice {

@Advice.OnMethodEnter(suppress = Throwable.class)
@Nullable
public static Scope onEnter() {
if (isReceiveTelemetryEnabled()) {
return null;
}
// suppress receive span creation in jms instrumentation
Context context =
InstrumenterUtil.suppressSpan(
receiveInstrumenter(), Java8BytecodeBridge.currentContext(), null);
receiveInstrumenter(), Java8BytecodeBridge.currentContext(), SpanKind.CONSUMER);
return context.makeCurrent();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,14 @@ public static AdviceScope enter(Message message) {
return new AdviceScope(request, context, context.makeCurrent());
}

public void exit(Throwable throwable) {
public void exit(@Nullable Throwable throwable) {
scope.close();
listenerInstrumenter().end(context, request, null, throwable);
}
}

@Advice.OnMethodEnter(suppress = Throwable.class)
@Nullable
public static AdviceScope onEnter(@Advice.Argument(0) Message message) {
return AdviceScope.enter(message);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
plugins {
id("otel.javaagent-instrumentation")
id("otel.nullaway-conventions")
}

muzzle {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import io.opentelemetry.javaagent.bootstrap.jms.JmsReceiveContextHolder;
import io.opentelemetry.javaagent.extension.instrumentation.TypeInstrumentation;
import io.opentelemetry.javaagent.extension.instrumentation.TypeTransformer;
import javax.annotation.Nullable;
import net.bytebuddy.asm.Advice;
import net.bytebuddy.description.type.TypeDescription;
import net.bytebuddy.matcher.ElementMatcher;
Expand All @@ -34,6 +35,7 @@ public void transform(TypeTransformer transformer) {
public static class ReceiveAndExecuteAdvice {

@Advice.OnMethodEnter(suppress = Throwable.class)
@Nullable
public static Scope onEnter() {
if (isReceiveTelemetryEnabled()) {
Context context = JmsReceiveContextHolder.init(Java8BytecodeBridge.currentContext());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,14 @@
import static net.bytebuddy.matcher.ElementMatchers.named;
import static net.bytebuddy.matcher.ElementMatchers.returns;

import io.opentelemetry.api.trace.SpanKind;
import io.opentelemetry.context.Context;
import io.opentelemetry.context.Scope;
import io.opentelemetry.instrumentation.api.internal.InstrumenterUtil;
import io.opentelemetry.javaagent.bootstrap.Java8BytecodeBridge;
import io.opentelemetry.javaagent.extension.instrumentation.TypeInstrumentation;
import io.opentelemetry.javaagent.extension.instrumentation.TypeTransformer;
import javax.annotation.Nullable;
import net.bytebuddy.asm.Advice;
import net.bytebuddy.description.type.TypeDescription;
import net.bytebuddy.matcher.ElementMatcher;
Expand All @@ -37,14 +39,15 @@ public void transform(TypeTransformer transformer) {
public static class ReceiveAdvice {

@Advice.OnMethodEnter(suppress = Throwable.class)
@Nullable
public static Scope onEnter() {
if (isReceiveTelemetryEnabled()) {
return null;
}
// suppress receive span creation in jms instrumentation
Context context =
InstrumenterUtil.suppressSpan(
receiveInstrumenter(), Java8BytecodeBridge.currentContext(), null);
receiveInstrumenter(), Java8BytecodeBridge.currentContext(), SpanKind.CONSUMER);
return context.makeCurrent();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public static AdviceScope enter(Message message) {
return new AdviceScope(request, context, context.makeCurrent());
}

public void exit(Throwable throwable) {
public void exit(@Nullable Throwable throwable) {
scope.close();
listenerInstrumenter().end(context, request, null, throwable);
}
Expand Down
Loading