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

OkHttp3 client instrumentation doesn't respect NetPeerAttributes config #3009

Closed
michaelbannister opened this issue May 16, 2021 · 2 comments · Fixed by #3063
Closed

OkHttp3 client instrumentation doesn't respect NetPeerAttributes config #3009

michaelbannister opened this issue May 16, 2021 · 2 comments · Fixed by #3063
Labels
bug Something isn't working

Comments

@michaelbannister
Copy link
Contributor

michaelbannister commented May 16, 2021

Describe the bug
With javaagent instrumentation, and peer service mapping provided by an environment variable OTEL_INSTRUMENTATION_COMMON_PEER_SERVICE_MAPPING, an OkHttp3 client does not assign the peer.service span attribute.

Steps to reproduce
Described above

What did you expect to see?
Attribute peer.service set on the client span

What did you see instead?
No peer.service attribute set on the client span

What version are you using?
v1.2.0

Environment
Not relevant, AFAICT.

Additional context
The class io.opentelemetry.instrumentation.okhttp.v3_0.OkHttpClientTracer calls super(openTelemetry, new NetPeerAttributes()).

Changing this to super(openTelemetry, NetPeerAttributes.INSTANCE) gives the expected behaviour (tested using a local build with this change made).

The equivalent class for OkHttp 2.2: io.opentelemetry.javaagent.instrumentation.okhttp.v2_2.OkHttpClientTracer does use NetPeerAttributes.INSTANCE.

However, there's the comment below on NetPeerAttributes.INSTANCE which I don't really understand so unsure whether this fix is in the right direction or whether this should be done some other way?

TODO: this should only be used by the javaagent; move to javaagent-api after removing all library usages

If the change I suggest is right, I'm happy to raise a PR (if I can work out how to add a test for this!)

@michaelbannister michaelbannister added the bug Something isn't working label May 16, 2021
@mateuszrzeszutek
Copy link
Member

Hi @michaelbannister,

It's okay to use NetPeerAttributes.INSTANCE, as long as it makes it work it's fine.

We're treating the tracer API as deprecated and trying to migrate to Instrumenters (#2713), so those TODOs in the tracer code can be ignored - we'll be getting rid of it all sooner or later.

@michaelbannister
Copy link
Contributor Author

michaelbannister commented May 21, 2021

Thanks @mateuszrzeszutek, in that case I'll raise a PR with the quick fix in case that makes it into a release any time soon, and then I'll have a look at whether I can figure out how to migrate the OkHttp instrumentation to the Instrumenter API 😄

iNikem pushed a commit that referenced this issue May 23, 2021
This will make it notice the peer-service-mapping settings to set peer.service span attribute

I know this approach is deprecated but I hope to follow this up with another change to use the
new Instrumenter API.

#3009
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.

2 participants