mirror of
https://github.com/hanzoai/tasks.git
synced 2026-10-04 02:04:03 +00:00
## 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.
37 lines
772 B
Go
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)
|
|
}
|
|
}
|