Skip to content
Open
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 @@ -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 @@ -16,6 +16,7 @@
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,11 +38,13 @@ 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
@SuppressWarnings("NullAway") // request is typed as Void
Copy link
Member

@jaydeluca jaydeluca Nov 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i wonder if it would make sense to add @Nullable to the parameter in suppressSpan (and all the other downstream effects of that) to avoid having to suppress this?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried that - and it's not working (have to look up the details if required)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you check? I'm asking because the reason "request is typed as Void" doesn't really seem correct here. Rather the reason seems that the method really does accept Nullable.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

InstrumenterUtil.suppressSpan() calls spanKindExtractor.extract(request) which doesn't accept a null request. Here it works because the instrumenter uses SpanKindExtractor.alwaysConsumer() that doesn't use the request.
The comment // request is typed as Void is misleading as here request is MessageWithDestination and the response is Void.

Context context =
InstrumenterUtil.suppressSpan(
receiveInstrumenter(), Java8BytecodeBridge.currentContext(), null);
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 @@ -16,6 +16,7 @@
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,11 +38,13 @@ 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
@SuppressWarnings("NullAway") // request is typed as Void
Context context =
InstrumenterUtil.suppressSpan(
receiveInstrumenter(), Java8BytecodeBridge.currentContext(), null);
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