From fd29dbe4c8f8910dfbe521d9c89ec99f8077c413 Mon Sep 17 00:00:00 2001 From: Michael Crosby Date: Fri, 5 Jan 2018 15:03:15 -0500 Subject: [PATCH] Enable grpc timing histograms This enables the grpc timing histograms via a config option as they are metrics of high cardinality. This is useful for perf testing and debugging but should not be the default on production systems unless needed. ```toml [metrics] grpc_histogram = true ``` Signed-off-by: Michael Crosby --- server/config.go | 3 ++- server/server.go | 6 ++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/server/config.go b/server/config.go index f056c7b83..9fcde3be3 100644 --- a/server/config.go +++ b/server/config.go @@ -50,7 +50,8 @@ type Debug struct { // MetricsConfig provides metrics configuration type MetricsConfig struct { - Address string `toml:"address"` + Address string `toml:"address"` + GRPCHistogram bool `toml:"grpc_histogram"` } // CgroupConfig provides cgroup configuration diff --git a/server/server.go b/server/server.go index 6af6df073..6053a1bdd 100644 --- a/server/server.go +++ b/server/server.go @@ -70,6 +70,7 @@ func New(ctx context.Context, config *Config) (*Server, error) { s = &Server{ rpc: rpc, events: exchange.NewExchange(), + config: config, } initialized = plugin.NewPluginSet() ) @@ -127,10 +128,15 @@ func New(ctx context.Context, config *Config) (*Server, error) { type Server struct { rpc *grpc.Server events *exchange.Exchange + config *Config } // ServeGRPC provides the containerd grpc APIs on the provided listener func (s *Server) ServeGRPC(l net.Listener) error { + if s.config.Metrics.GRPCHistogram { + // enable grpc time histograms to measure rpc latencies + grpc_prometheus.EnableHandlingTimeHistogram() + } // before we start serving the grpc API regster the grpc_prometheus metrics // handler. This needs to be the last service registered so that it can collect // metrics for every other service