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

Fix netty dependency and class version checking #411

Merged
merged 1 commit into from
Jul 31, 2018

Conversation

tylerbenson
Copy link
Contributor

@tylerbenson tylerbenson commented Jul 27, 2018

Still requires #417 to work all the way.

public static void registerFeature(@Advice.This final Object builder) {
if (builder instanceof ClientBuilder) {
((ClientBuilder) builder).register(ClientTracingFeature.class);
}
Copy link
Contributor

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?

Copy link
Contributor

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.

Copy link
Contributor

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 :)

Copy link
Contributor

@gary-huang gary-huang left a 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()
Copy link
Contributor

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?

Copy link
Contributor

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.

Copy link
Contributor

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.

Copy link
Contributor

@realark realark left a 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.

@realark realark added the tag: do not merge Do not merge changes label Jul 31, 2018
@tylerbenson tylerbenson removed the tag: do not merge Do not merge changes label Jul 31, 2018
@tylerbenson tylerbenson changed the title Remove argument references to classes that might not be loaded Fix netty dependency and class version checking Jul 31, 2018
@tylerbenson
Copy link
Contributor Author

@realark I've removed the overlap with #417, but kept the part of this PR that fixes the dependency and version checking. Should make this a much easier PR to review.

Copy link
Contributor

@gary-huang gary-huang left a 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.
🎉

@tylerbenson tylerbenson merged commit 342b7d4 into master Jul 31, 2018
@tylerbenson tylerbenson deleted the tyler/class-refs branch July 31, 2018 21:29
@tylerbenson tylerbenson added this to the 0.12.0 milestone Aug 1, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants