From c9ebbc1228735a060ebb35c0d6393cadbeb10250 Mon Sep 17 00:00:00 2001 From: Lauri Tulmin Date: Sun, 23 Oct 2022 12:56:17 +0300 Subject: [PATCH] restore comment --- .../rocketmqclient/v4_8/TracingConsumeMessageHookImpl.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/instrumentation/rocketmq/rocketmq-client/rocketmq-client-4.8/library/src/main/java/io/opentelemetry/instrumentation/rocketmqclient/v4_8/TracingConsumeMessageHookImpl.java b/instrumentation/rocketmq/rocketmq-client/rocketmq-client-4.8/library/src/main/java/io/opentelemetry/instrumentation/rocketmqclient/v4_8/TracingConsumeMessageHookImpl.java index a1e307019bc5..be6e328bdc37 100644 --- a/instrumentation/rocketmq/rocketmq-client/rocketmq-client-4.8/library/src/main/java/io/opentelemetry/instrumentation/rocketmqclient/v4_8/TracingConsumeMessageHookImpl.java +++ b/instrumentation/rocketmq/rocketmq-client/rocketmq-client-4.8/library/src/main/java/io/opentelemetry/instrumentation/rocketmqclient/v4_8/TracingConsumeMessageHookImpl.java @@ -34,6 +34,10 @@ public void consumeMessageBefore(ConsumeMessageContext context) { Context parentContext = Context.current(); Context newContext = instrumenter.start(parentContext, context.getMsgList()); + // it's safe to store the scope in the rocketMq message context, both before() and after() + // methods are always called from the same thread; see: + // - ConsumeMessageConcurrentlyService$ConsumeRequest#run() + // - ConsumeMessageOrderlyService$ConsumeRequest#run() if (newContext != parentContext) { contextAndScopeField.set( context, ContextAndScope.create(newContext, newContext.makeCurrent()));