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

Don't create spans for HttpUrlConnection requests from agent classloader #4642

Closed
anuraaga opened this issue Nov 15, 2021 · 3 comments
Closed
Labels
contribution welcome Request makes sense, maintainers probably won't have time, contribution would be welcome enhancement New feature or request stale

Comments

@anuraaga
Copy link
Contributor

I have a feeling there isn't a good solution to this but would be nice if there were. Because HttpUrlConnection is in bootstrap classloader, requests made from the agent classloader, such as a remote sampler, end up getting traced. Ideally this didn't happen and otherwise requires workarounds like adding the sampler's requests into that remote sampler configuration itself.

@anuraaga anuraaga added the enhancement New feature or request label Nov 15, 2021
@anuraaga anuraaga changed the title Not creating spans for HttpUrlConnection requests from agent classloader Don't create spans for HttpUrlConnection requests from agent classloader Nov 15, 2021
@laurit
Copy link
Contributor

laurit commented Nov 17, 2021

While I believe it is possible to figure out whether call was made from agent class loader with StackWalker or SecurityManager.getClassContext I'm not convinced that it is a reasonable thing to do. How would we use it, find a class at some fixed offset like sun.reflect.Reflection.getCallerClass(int) used to do, or scan the whole call stack?
Perhaps it would make more sense to find an alternative way. For example if such usages of HttpUrlConnection happen only from one of the agent threads then perhaps we could make all agent threads be in one group and when current thread is in that group automatically suppress spans. Or we could add something around the usage of HttpUrlConnection in our code that suppresses the spans. If I remember correctly then besides HttpUrlConnection executor instrumentation has also had issues where context is propagated into agent thread somehow.

@iNikem
Copy link
Contributor

iNikem commented Nov 18, 2021

I like the idea of agent's thread group

@anuraaga
Copy link
Contributor Author

While I think this is an interesting topic, I was able to workaround it for the x-ray sampler case specifically

open-telemetry/opentelemetry-java-contrib#135

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contribution welcome Request makes sense, maintainers probably won't have time, contribution would be welcome enhancement New feature or request stale
Projects
None yet
Development

No branches or pull requests

4 participants