pre register new rpc metric, rename metric (#12582)

This commit is contained in:
FFMMM 2022-03-21 17:26:32 -07:00 committed by GitHub
parent a714b7cf3b
commit 08f2838b78
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 2 deletions

View File

@ -92,7 +92,7 @@ func TestAgent_NewRPCMetrics(t *testing.T) {
respRec := httptest.NewRecorder() respRec := httptest.NewRecorder()
recordPromMetrics(t, a, respRec) recordPromMetrics(t, a, respRec)
assertMetricExists(t, respRec, metricsPrefix+"_rpc_server_request") assertMetricExists(t, respRec, metricsPrefix+"_rpc_server_call")
}) })
} }

View File

@ -6,6 +6,7 @@ import (
"time" "time"
"github.com/armon/go-metrics" "github.com/armon/go-metrics"
"github.com/armon/go-metrics/prometheus"
"github.com/hashicorp/consul-net-rpc/net/rpc" "github.com/hashicorp/consul-net-rpc/net/rpc"
"github.com/hashicorp/go-hclog" "github.com/hashicorp/go-hclog"
) )
@ -19,9 +20,16 @@ import (
// used for this historically is "RPC", so we continue to use that here. // used for this historically is "RPC", so we continue to use that here.
const RPCTypeInternal = "internal" const RPCTypeInternal = "internal"
var metricRPCRequest = []string{"rpc", "server", "request"} var metricRPCRequest = []string{"rpc", "server", "call"}
var requestLogName = "rpc.server.request" var requestLogName = "rpc.server.request"
var NewRPCCounters = []prometheus.CounterDefinition{
{
Name: metricRPCRequest,
Help: "Increments when a server makes an RPC service call. The labels on the metric have more information",
},
}
type RequestRecorder struct { type RequestRecorder struct {
Logger hclog.Logger Logger hclog.Logger
} }

View File

@ -25,6 +25,7 @@ import (
"github.com/hashicorp/consul/agent/local" "github.com/hashicorp/consul/agent/local"
"github.com/hashicorp/consul/agent/pool" "github.com/hashicorp/consul/agent/pool"
"github.com/hashicorp/consul/agent/router" "github.com/hashicorp/consul/agent/router"
"github.com/hashicorp/consul/agent/rpc/middleware"
"github.com/hashicorp/consul/agent/submatview" "github.com/hashicorp/consul/agent/submatview"
"github.com/hashicorp/consul/agent/token" "github.com/hashicorp/consul/agent/token"
"github.com/hashicorp/consul/agent/xds" "github.com/hashicorp/consul/agent/xds"
@ -264,6 +265,7 @@ func getPrometheusDefs(cfg lib.TelemetryConfig, isServer bool) ([]prometheus.Gau
grpc.StatsCounters, grpc.StatsCounters,
local.StateCounters, local.StateCounters,
raftCounters, raftCounters,
middleware.NewRPCCounters,
} }
// Flatten definitions // Flatten definitions
// NOTE(kit): Do we actually want to create a set here so we can ensure definition names are unique? // NOTE(kit): Do we actually want to create a set here so we can ensure definition names are unique?