Skip to content

Commit 805a570

Browse files
committed
Avoid creating new consumer variable
1 parent d1479af commit 805a570

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

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

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -283,13 +283,11 @@ public static Object wrapConsumer(
283283
@Advice.Argument(0) String queue,
284284
@Advice.Argument(6) Consumer consumer) {
285285
// We have to save off the queue name here because it isn't available to the consumer later.
286-
Consumer modifiedConsumer = consumer;
287-
if (modifiedConsumer != null && !(modifiedConsumer instanceof TracedDelegatingConsumer)) {
288-
modifiedConsumer =
289-
new TracedDelegatingConsumer(queue, modifiedConsumer, channel.getConnection());
286+
if (consumer != null && !(consumer instanceof TracedDelegatingConsumer)) {
287+
return new TracedDelegatingConsumer(queue, consumer, channel.getConnection());
290288
}
291289

292-
return modifiedConsumer;
290+
return consumer;
293291
}
294292
}
295293
}

0 commit comments

Comments
 (0)