Skip to content

Conversation

@realark
Copy link
Contributor

@realark realark commented Dec 1, 2017

  • Add TestHttpServer to aid in unit testing http clients.
  • Alter the ShadowPackageRename test to function without forcing a particular version of guava.
  • Convert httpclient instrumentation to bytebuddy

The dependency on opentracing-apache-contrib has also been removed. Using theses contribs as helper classes was causing LinkageErrors when instrumenting with bytebuddy (details here: https://trello.com/c/96EY75FW/312-instrumentation-may-create-linkage-errors-which-crash-the-users-app).

Tested with client versions 4.3-4.5.3 (latest).

@realark realark added the tag: do not merge Do not merge changes label Dec 1, 2017
@realark realark changed the title Ark/apache http client bytebuddy apache httpclient bytebuddy Dec 1, 2017
@realark realark force-pushed the ark/apache_http_client_bytebuddy branch from 9338c9a to 397864d Compare December 1, 2017 01:09
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is actually why I included ratpack test utilities. Take a look at DDApiTest for examples on how I'm using it. I think it will work under junit+java style tests as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! I'll move my tests over so all tests use the same embedded server.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This class seems a bit complicated. I'm wondering if there is a better way to trace this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree; the instrumentation approach should be revisited (I don't know for sure if there's a better way, but I share your feeling on the matter). However, doing that would delay moving away from byteman.

This is the same instrumentation we were using before (in byteman). I removed the opentracing-contrib dependency and moved the helper into our project.

https://github.com/opentracing-contrib/java-apache-httpclient/blob/master/opentracing-apache-httpclient/src/main/java/io/opentracing/contrib/apache/http/client/TracingClientExec.java

I think it makes sense to separate the bytebuddy migration from the instrumentation approach. Here's what I propose:

  • Keep this PR confined to porting the instrumentation over to bytebuddy
    • Provided this doesn't increase the project's technical debt.
  • Add an issue to the backlog for investigating the overall instrumentation approach and prioritize against other needs.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I didn't realize that was something that was already complicated. I thought that was part of your "new approach". Why did you need to bring it into our repo again?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When we patch HttpClientBuilder (at classload time) we inject our helper classes. TracingHttpClientBuilder extends HttpClientBuilder, which causes a load of HttpClientBuilder while loading HttpClientBuilder, which causes a LinkageError in the user's app.

The only purpose of TracingHttpClientBuilder is to inject TracingClientExec, so I moved TracingClientExec into our project and changed the injection strategy. Since TracingHttpClientBuilder is no longer a helper the circularity error goes away.

@realark realark force-pushed the ark/apache_http_client_bytebuddy branch from 397864d to c7e46f9 Compare December 1, 2017 18:48
@realark realark force-pushed the ark/apache_http_client_bytebuddy branch from c7e46f9 to 6fa3030 Compare December 1, 2017 18:54
@realark realark force-pushed the ark/apache_http_client_bytebuddy branch from 550a5ef to cbd1d3c Compare December 2, 2017 00:39
@realark realark added this to the 0.2.11 milestone Dec 2, 2017
@realark realark added the type: enhancement Enhancements and improvements label Dec 2, 2017
Andrew Kent added 2 commits December 4, 2017 11:42
Forcing guava to version 18 prevented running the embedded ratpack
http server. Using codesource for the shadow test has the same effect
and doesn't require forcing a version of guava.
@realark realark added dev/tooling and removed tag: do not merge Do not merge changes labels Dec 4, 2017
@realark realark requested a review from tylerbenson December 4, 2017 21:29
Copy link
Contributor

@tylerbenson tylerbenson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great. Nice work.

@realark realark merged commit 69c3117 into master Dec 6, 2017
@realark realark deleted the ark/apache_http_client_bytebuddy branch December 6, 2017 01:19
@PerfectSlayer PerfectSlayer added comp: tooling Build & Tooling and removed dev/tooling labels Jun 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp: tooling Build & Tooling type: enhancement Enhancements and improvements

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants