Files
tasks/common/rpc/multistats.go
Stephan BehnkeandGitHub ee57d3af87 gRPC connection metrics (#8237)
## What changed?

Added gRPC connection metrics.

## Why?

To gain insights into gRPC connections for operational purposes.

## How did you test it?
- [x] built
- [ ] run locally and tested manually
- [ ] covered by existing tests
- [ ] added new unit test(s)
- [ ] added new functional test(s)

I'll be looking at the metric in our nightly pipeline to verify.
2025-08-28 18:41:15 +00:00

37 lines
772 B
Go

package rpc
import (
"context"
"google.golang.org/grpc/stats"
)
// MultiStatsHandler forwards stats to multiple stats.Handlers.
type MultiStatsHandler []stats.Handler
func (m MultiStatsHandler) TagConn(ctx context.Context, info *stats.ConnTagInfo) context.Context {
for _, h := range m {
ctx = h.TagConn(ctx, info)
}
return ctx
}
func (m MultiStatsHandler) HandleConn(ctx context.Context, cs stats.ConnStats) {
for _, h := range m {
h.HandleConn(ctx, cs)
}
}
func (m MultiStatsHandler) TagRPC(ctx context.Context, info *stats.RPCTagInfo) context.Context {
for _, h := range m {
ctx = h.TagRPC(ctx, info)
}
return ctx
}
func (m MultiStatsHandler) HandleRPC(ctx context.Context, rs stats.RPCStats) {
for _, h := range m {
h.HandleRPC(ctx, rs)
}
}