mirror of https://github.com/hashicorp/consul
pre register new rpc metric, rename metric (#12582)
parent
69c10dfcba
commit
e5ebc47a94
|
@ -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")
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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
|
||||||
}
|
}
|
||||||
|
|
|
@ -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?
|
||||||
|
|
Loading…
Reference in New Issue