fix bad oss sync, use gauges not counters (#12611)

This commit is contained in:
FFMMM 2022-03-24 14:41:30 -07:00 committed by GitHub
parent 3b736d6a0c
commit c39854de78
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 3 additions and 25 deletions

View File

@ -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

View File

@ -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",

View File

@ -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