opentelemetry-go-contrib
                                
                                 opentelemetry-go-contrib copied to clipboard
                                
                                    opentelemetry-go-contrib copied to clipboard
                            
                            
                            
                        Add metrics instrumentation for google.golang.org/grpc
Background
google.golang.org/grpc is already instrumented with library
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc, but this library only covers trace.
So this issue will try to complete all the metrics for google.golang.org/grpc which are already defined in https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/metrics/semantic_conventions/rpc-metrics.md
Metrics
Instruments
Server
- [x] rpc.server.duration #2700
- [ ] rpc.server.request.size
- [ ] rpc.server.response.size
- [ ] rpc.server.requests_per_rpc
- [ ] rpc.server.responses_per_rpc
Client
- [ ] rpc.client.duration
- [ ] rpc.client.request.size
- [ ] rpc.client.response.size
- [ ] rpc.client.requests_per_rpc
- [ ] rpc.client.responses_per_rpc
Tasks
- Code complete:
- [ ] Comprehensive unit tests.
- [ ] End-to-end integration tests.
- [ ] Tests all passing.
- [ ] Instrumentation functionality verified.
 
- Documented
- [ ] Added to the OpenTelemetry Registry
- [ ] README included for the module describing high-level purpose.
- [ ] Complete documentation of all public API including package documentation.
- [ ] Instrumentation documentation updated.
 
- Examples
- [ ] Dockerfilefile to build example application.
- [ ] docker-compose.ymlto run example in a docker environment to demonstrate instrumentation.
 
- [ ] 
Related: #2782.
I think this issue is now blocked by #197
Anyone mind if I add a metrics implementation to the client interceptors?
I think interceptors are going to be deprecated soon and then removed. https://github.com/open-telemetry/opentelemetry-go-contrib/issues/4318, https://github.com/open-telemetry/opentelemetry-go-contrib/issues/4319. Stats handlers are better - it's hard to do metrics with streaming RPCs as that would require wrapping the stream. It's very clean with stats handlers as gRPC just calls its methods.
I think interceptors are going to be deprecated soon and then removed. #4318, #4319. Stats handlers are better - it's hard to do metrics with streaming RPCs as that would require wrapping the stream. It's very clean with stats handlers as gRPC just calls its methods.
Makes sense, thanks.