-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
stats: Add RemoteAddr and LocalAddr to RPCStats #6897
Comments
Scaling up the RPCStats interface is not what we desire here. I think you should be able to pull out the peer with peer.FromContext, which will have the local address and remote address. Let me triage this though to see if this population of peer comes before all the stats handler callouts (I know some callouts will have it, but I don't know if all will). |
Hello, peer.NewContext (which populates the context with a peer which contains both pieces of this information) comes before the TagConn call on the stats handler. Thus, you can use peer.FromContext to get this information in the stats handler. Let us know if you have any issues with this and we can reopen this issue, but this should work. |
@zasweq |
It works in every HandleRPC call, since it is populated before. |
I think does not for the client's stats handler. Should I create an issue with repro steps? |
Use case(s) - what problem will this feature solve?
A
stats.Handler
implementation needs to capture the peer address in theHandleRPC
.The reason is that I want to add the gRPC client and server addresses as attributes to spans and metrics recorded by a stats handler.
For example imagine you would like to add the remote (peer, client) address as an additional attribute here:
grpc-go/stats/opencensus/trace.go
Lines 81 to 124 in 4f03f3f
Proposed Solution
Add
RemoteAddr
andLocalAddr
fields toRPCStats
.Alternatives Considered
None
Additional Context
The gRPC server address attribute is recommended for all metrics by the current version of OpenTelemetry Semantic Conventions: https://opentelemetry.io/docs/specs/semconv/rpc/rpc-metrics/#attributes
Both the gRPC server and address attributes are recommended for all span by the current version of OpenTelemetry Semantic Conventions: https://opentelemetry.io/docs/specs/semconv/rpc/rpc-spans/
Here are some explorations: open-telemetry/opentelemetry-go-contrib#4539
The text was updated successfully, but these errors were encountered: