open-telemetry / opentelemetry-java-instrumentation

OpenTelemetry auto-instrumentation and instrumentation libraries for Java
https://opentelemetry.io
Apache License 2.0
1.88k stars 823 forks source link

How to accurately get the downstream service name in the upstream as its own `peer.service` #6495

Closed CoderPoet closed 1 year ago

CoderPoet commented 2 years ago

Is your feature request related to a problem? Please describe. How to accurately get the downstream service name in the upstream as its own peer.service, so as to implement accurate service topology metrics

Assuming that a -> b, the following metrics can be generated: service_topology{service_name="b", peer_service="a", kind="server"}

Describe the solution you'd like Can we pass the service.name in the downstream resource attribute to the upstream through the propagation protocol?

For example, propagating the service.name in the resource attributes through the http header

Describe alternatives you've considered Is there a suitable protocol specification

CoderPoet commented 2 years ago

For client calls, it may be possible to use the peer.service mapping mechanism, but that requires the user to manually configure a mapping, which is not very friendly

mateuszrzeszutek commented 2 years ago

Hi @CoderPoet ,

Can we pass the service.name in the downstream resource attribute to the upstream through the propagation protocol?

For example, propagating the service.name in the resource attributes through the http header

This should be doable in the agent, but this kind of feature should probably go through the spec process first. (Also, it's worth noting that there already was a similar request before: https://github.com/open-telemetry/opentelemetry-java-instrumentation/issues/5353 -- implementation-wise, it'd be good to have a common, extensible mechanism for supplementing HTTP response headers across all server instrumentations)

trask commented 1 year ago

http response headers can be populated now using https://github.com/open-telemetry/opentelemetry-java-instrumentation/blob/main/javaagent-extension-api/src/main/java/io/opentelemetry/javaagent/bootstrap/http/HttpServerResponseCustomizer.java

this could probably be used to implement something like this in an agent extension

github-actions[bot] commented 1 year ago

This has been automatically marked as stale because it has been marked as needing author feedback and has not had any activity for 7 days. It will be closed automatically if there is no response from the author within 7 additional days from this comment.