From 5319ba02b0c685d3f79c419cbf28d4631e9f9ba8 Mon Sep 17 00:00:00 2001 From: Daniel Nephin Date: Thu, 15 Oct 2020 16:29:09 -0400 Subject: [PATCH] agent/grpc: rename metrics These new names should make it easier to add counter metics with similar prefixes --- agent/grpc/stats.go | 6 +++--- agent/grpc/stats_test.go | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/agent/grpc/stats.go b/agent/grpc/stats.go index 16961e7f0a..c37d1f9bf6 100644 --- a/agent/grpc/stats.go +++ b/agent/grpc/stats.go @@ -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) diff --git a/agent/grpc/stats_test.go b/agent/grpc/stats_test.go index ea4cb70b24..9d4772142a 100644 --- a/agent/grpc/stats_test.go +++ b/agent/grpc/stats_test.go @@ -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)