-
Notifications
You must be signed in to change notification settings - Fork 277
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
Fix netty dependency and class version checking #411
Conversation
8155233
to
781bea7
Compare
781bea7
to
7577eb9
Compare
public static void registerFeature(@Advice.This final Object builder) { | ||
if (builder instanceof ClientBuilder) { | ||
((ClientBuilder) builder).register(ClientTracingFeature.class); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tylerbenson could you explain why this is helpful: how instrumented class may not be present when its method is called?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tylerbenson and I were looking into this yesterday, and it seems that when @Advice.This
is used with a specific class (i.e. ClientBuilder
in this case), that class must to be already loaded at transformation time. Or ByteBuddy would throw the Cannot resolve type description
error.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for explaining!
To me this seems like a problem on bytebuddy side (or on the way we run it) - and it makes our code much uglier than it should be in my opinion. Also as @ark mentions there are probably other places where same problem should arise but apparently doesn't. I hope there might be better way to fix this ran manually casting all advice's parameters :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only a minor concern about JMS2MessageProducerInstrumentation
.
Also, are these instrumentations the only ones affected? Other than Netty, are these changes necessary or are they just precautions?
@@ -83,11 +83,11 @@ public static Scope startSpan( | |||
GlobalTracer.get() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's an @Advice.This
here for the MessageProducer
in ProducerAdvice
's startSpan
, should this be an Object
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would this be okay if the This param is an interface and the instrumentation applies to its implementations? Missing the full context here, but that type of pattern is okay for other types of advice/classloading issues.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That was the issue that we were seeing with Netty: https://github.com/DataDog/dd-trace-java/blob/master/dd-java-agent/instrumentation/netty-4.1/src/main/java/datadog/trace/instrumentation/netty41/NettyChannelPipelineInstrumentation.java#L100
Where for the @Advice.This
param, ChannelPipeline
is an interface, and the implementation being instrumented is DefaultChannelPipeline
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Is it possible to fix this at the bytebuddy level? Can we tell bytebuddy to not attempt to load classes in the method sig?
- Why doesn't this affect other method params as well? For example, we're also referencing the
ChannelHandler
class in the netty instrumentation. I would expect the same classloading gotchas to apply.
7577eb9
to
9a6efe6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Confirmed this works with #417 applied for Spring boot 2.
🎉
Still requires #417 to work all the way.