From c39854de78b28975fcb782991d14bd4850feec79 Mon Sep 17 00:00:00 2001 From: FFMMM Date: Thu, 24 Mar 2022 14:41:30 -0700 Subject: [PATCH] fix bad oss sync, use gauges not counters (#12611) --- agent/metrics_test.go | 24 ------------------------ agent/rpc/middleware/interceptors.go | 2 +- agent/setup.go | 2 ++ 3 files changed, 3 insertions(+), 25 deletions(-) diff --git a/agent/metrics_test.go b/agent/metrics_test.go index e0d088cfaa..b530eda250 100644 --- a/agent/metrics_test.go +++ b/agent/metrics_test.go @@ -94,30 +94,6 @@ func TestAgent_NewRPCMetrics(t *testing.T) { assertMetricExists(t, respRec, metricsPrefix+"_rpc_server_call") }) - - t.Run("Check that new rpc metrics can be filtered out", func(t *testing.T) { - metricsPrefix := "new_rpc_metrics_2" - hcl := fmt.Sprintf(` - telemetry = { - prometheus_retention_time = "5s" - disable_hostname = true - metrics_prefix = "%s" - prefix_filter = ["-%s.rpc.server.call"] - } - `, metricsPrefix, metricsPrefix) - - a := StartTestAgent(t, TestAgent{HCL: hcl}) - defer a.Shutdown() - - var out struct{} - err := a.RPC("Status.Ping", struct{}{}, &out) - require.NoError(t, err) - - respRec := httptest.NewRecorder() - recordPromMetrics(t, a, respRec) - - assertMetricNotExists(t, respRec, metricsPrefix+"_rpc_server_call") - }) } // TestHTTPHandlers_AgentMetrics_ConsulAutopilot_Prometheus adds testing around diff --git a/agent/rpc/middleware/interceptors.go b/agent/rpc/middleware/interceptors.go index d52999e76f..a5ee26f4e7 100644 --- a/agent/rpc/middleware/interceptors.go +++ b/agent/rpc/middleware/interceptors.go @@ -24,7 +24,7 @@ const RPCTypeNetRPC = "net/rpc" var metricRPCRequest = []string{"rpc", "server", "call"} var requestLogName = "rpc.server.request" -var NewRPCCounters = []prometheus.CounterDefinition{ +var NewRPCGauges = []prometheus.GaugeDefinition{ { Name: metricRPCRequest, Help: "Increments when a server makes an RPC service call. The labels on the metric have more information", diff --git a/agent/setup.go b/agent/setup.go index bf67c0360f..4921a42d89 100644 --- a/agent/setup.go +++ b/agent/setup.go @@ -25,6 +25,7 @@ import ( "github.com/hashicorp/consul/agent/local" "github.com/hashicorp/consul/agent/pool" "github.com/hashicorp/consul/agent/router" + "github.com/hashicorp/consul/agent/rpc/middleware" "github.com/hashicorp/consul/agent/submatview" "github.com/hashicorp/consul/agent/token" "github.com/hashicorp/consul/agent/xds" @@ -214,6 +215,7 @@ func getPrometheusDefs(cfg lib.TelemetryConfig, isServer bool) ([]prometheus.Gau CertExpirationGauges, Gauges, raftGauges, + middleware.NewRPCGauges, } // TODO(ffmmm): conditionally add only leader specific metrics to gauges, counters, summaries, etc