Skip to content

Commit c1ea8b0

Browse files
authored
Review fixes for rabbitmq-2.7:javaagent (#17615)
Co-authored-by: otelbot <197425009+otelbot@users.noreply.github.com>
1 parent 4ee0241 commit c1ea8b0

4 files changed

Lines changed: 15 additions & 9 deletions

File tree

instrumentation/rabbitmq-2.7/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/rabbitmq/RabbitChannelInstrumentation.java

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ public static ChannelMethodAdviceScope start(
129129
return new ChannelMethodAdviceScope(callDepth, context, context.makeCurrent(), request);
130130
}
131131

132-
public void end(Throwable throwable) {
132+
public void end(@Nullable Throwable throwable) {
133133
if (callDepth.decrementAndGet() > 0) {
134134
return;
135135
}
@@ -144,7 +144,7 @@ public void end(Throwable throwable) {
144144
}
145145
}
146146

147-
@Advice.OnMethodEnter
147+
@Advice.OnMethodEnter(suppress = Throwable.class)
148148
public static ChannelMethodAdviceScope onEnter(
149149
@Advice.This Channel channel, @Advice.Origin("Channel.#m") String method) {
150150
return ChannelMethodAdviceScope.start(CallDepth.forClass(Channel.class), channel, method);
@@ -231,7 +231,11 @@ public static ChannelGetAdviceScope start() {
231231
return new ChannelGetAdviceScope(callDepth, timer);
232232
}
233233

234-
public void end(Channel channel, String queue, GetResponse response, Throwable throwable) {
234+
public void end(
235+
Channel channel,
236+
String queue,
237+
@Nullable GetResponse response,
238+
@Nullable Throwable throwable) {
235239
if (callDepth.decrementAndGet() > 0) {
236240
return;
237241
}
@@ -255,7 +259,7 @@ public void end(Channel channel, String queue, GetResponse response, Throwable t
255259
}
256260
}
257261

258-
@Advice.OnMethodEnter
262+
@Advice.OnMethodEnter(suppress = Throwable.class)
259263
public static ChannelGetAdviceScope takeTimestamp() {
260264
return ChannelGetAdviceScope.start();
261265
}
@@ -264,8 +268,8 @@ public static ChannelGetAdviceScope takeTimestamp() {
264268
public static void extractAndStartSpan(
265269
@Advice.This Channel channel,
266270
@Advice.Argument(0) String queue,
267-
@Advice.Return GetResponse response,
268-
@Advice.Thrown Throwable throwable,
271+
@Advice.Return @Nullable GetResponse response,
272+
@Advice.Thrown @Nullable Throwable throwable,
269273
@Advice.Enter ChannelGetAdviceScope adviceScope) {
270274
adviceScope.end(channel, queue, response, throwable);
271275
}

instrumentation/rabbitmq-2.7/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/rabbitmq/RabbitCommandInstrumentation.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ private SpanHolder() {}
4949
@SuppressWarnings("unused")
5050
public static class CommandConstructorAdvice {
5151

52-
@Advice.OnMethodExit
52+
@Advice.OnMethodExit(suppress = Throwable.class)
5353
public static void setSpanNameAddHeaders(@Advice.This Command command) {
5454

5555
Context context = CURRENT_RABBIT_CONTEXT.get();

instrumentation/rabbitmq-2.7/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/rabbitmq/RabbitSingletons.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import io.opentelemetry.javaagent.bootstrap.internal.ExperimentalConfig;
2424
import java.util.ArrayList;
2525
import java.util.List;
26+
import javax.annotation.Nullable;
2627

2728
public class RabbitSingletons {
2829

@@ -109,7 +110,7 @@ private static Instrumenter<DeliveryRequest, Void> createDeliverInstrumenter() {
109110
}
110111

111112
private static <T, V> AttributesExtractor<T, V> buildMessagingAttributesExtractor(
112-
MessagingAttributesGetter<T, V> getter, MessageOperation operation) {
113+
MessagingAttributesGetter<T, V> getter, @Nullable MessageOperation operation) {
113114
return MessagingAttributesExtractor.builder(getter, operation)
114115
.setCapturedHeaders(ExperimentalConfig.get().getMessagingHeaders())
115116
.build();

instrumentation/rabbitmq-2.7/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/rabbitmq/ReceiveRequest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313
@AutoValue
1414
public abstract class ReceiveRequest {
1515

16-
public static ReceiveRequest create(String queue, GetResponse response, Connection connection) {
16+
public static ReceiveRequest create(
17+
String queue, @Nullable GetResponse response, Connection connection) {
1718
return new AutoValue_ReceiveRequest(queue, response, connection);
1819
}
1920

0 commit comments

Comments
 (0)