agent/grpc: rename metrics

These new names should make it easier to add counter metics with similar prefixes
This commit is contained in:
Daniel Nephin 2020-10-15 16:29:09 -04:00
parent 72430b9125
commit 64284ed91a
2 changed files with 7 additions and 7 deletions

View File

@ -60,7 +60,7 @@ func (c *statsHandler) HandleConn(_ context.Context, s stats.ConnStats) {
// Decrement!
count = atomic.AddUint64(&c.activeConns, ^uint64(0))
}
c.metrics.SetGauge([]string{"grpc", label, "active_conns"}, float32(count))
c.metrics.SetGauge([]string{"grpc", label, "connections"}, float32(count))
}
type activeStreamCounter struct {
@ -79,10 +79,10 @@ func (i *activeStreamCounter) Intercept(
handler grpc.StreamHandler,
) error {
count := atomic.AddUint64(&i.count, 1)
i.metrics.SetGauge([]string{"grpc", "server", "active_streams"}, float32(count))
i.metrics.SetGauge([]string{"grpc", "server", "streams"}, float32(count))
defer func() {
count := atomic.AddUint64(&i.count, ^uint64(0))
i.metrics.SetGauge([]string{"grpc", "server", "active_streams"}, float32(count))
i.metrics.SetGauge([]string{"grpc", "server", "streams"}, float32(count))
}()
return handler(srv, ss)

View File

@ -80,10 +80,10 @@ func TestHandler_EmitsStats(t *testing.T) {
cmpMetricCalls := cmp.AllowUnexported(metricCall{})
expectedGauge := []metricCall{
{key: []string{"testing", "grpc", "server", "active_conns"}, val: 1},
{key: []string{"testing", "grpc", "server", "active_streams"}, val: 1},
{key: []string{"testing", "grpc", "server", "active_conns"}, val: 0},
{key: []string{"testing", "grpc", "server", "active_streams"}, val: 0},
{key: []string{"testing", "grpc", "server", "connections"}, val: 1},
{key: []string{"testing", "grpc", "server", "streams"}, val: 1},
{key: []string{"testing", "grpc", "server", "connections"}, val: 0},
{key: []string{"testing", "grpc", "server", "streams"}, val: 0},
}
assertDeepEqual(t, expectedGauge, sink.gaugeCalls, cmpMetricCalls)