Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rocketmq hook exception #6934

Closed
kelystor opened this issue Oct 21, 2022 · 0 comments · Fixed by #6940
Closed

rocketmq hook exception #6934

kelystor opened this issue Oct 21, 2022 · 0 comments · Fixed by #6940
Labels
bug Something isn't working

Comments

@kelystor
Copy link

open telemetry trace rocketmq via register hook, e.g: TracingSendMessageHookImpl.

In some scenes, rocketmq will register own hook (ConsumeMessageHook/SendMessageHook), e.g: SendMessageTraceHookImpl (SendMessageHook) , or user may register his custom hook. And it may conflict with open telemetry's hook, eg: TracingSendMessageHookImpl, there is an exception when hooks execute

failed to executeSendMessageHookAfter
java.lang.ClassCastException: io.opentelemetry.javaagent.shaded.io.opentelemetry.context.ArrayBasedContext cannot be cast to org.apache.rocketmq.client.trace.TraceContext

for example, SendMessageHook:

SendMessageTraceHookImpl.sendMessageBefore -> context.setMqTraceContext(tuxeContext);	//  set mqTraceContext field  a TraceContext variable
TracingSendMessageHookImpl.sendMessageBefore -> context.setMqTraceContext(instrumenter.start(parentContext, context));	// open telemtry override hook context MqTraceContext field

SendMessageTraceHookImpl.sendMessageAfter -> TraceContext tuxeContext = (TraceContext)context.getMqTraceContext();	// mqTraceContext is not TraceContext type, and throw 'can not be cast to TraceContext' exception
TracingSendMessageHookImpl.sendMessageAfter -> ContextAndScope contextAndScope = (ContextAndScope) context.getMqTraceContext();	// open telemetry get mqTraceContext and do something

maybe add virtual field to hook context is a better solution?

@kelystor kelystor added the bug Something isn't working label Oct 21, 2022
trask pushed a commit that referenced this issue Oct 23, 2022
Resolves
#6934
As described in the linked issue our usage of rocketmq trace context can
conflict with other hooks that also use `setMqTraceContext`.
LironKS pushed a commit to helios/opentelemetry-java-instrumentation that referenced this issue Oct 31, 2022
Resolves
open-telemetry#6934
As described in the linked issue our usage of rocketmq trace context can
conflict with other hooks that also use `setMqTraceContext`.
LironKS pushed a commit to helios/opentelemetry-java-instrumentation that referenced this issue Dec 4, 2022
Resolves
open-telemetry#6934
As described in the linked issue our usage of rocketmq trace context can
conflict with other hooks that also use `setMqTraceContext`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant