v3rpc: add gRPC active streamsGauge

This commit is contained in:
Gyu-Ho Lee 2016-11-04 10:37:17 -07:00
parent 27459425fa
commit 67082e5bd1
3 changed files with 12 additions and 0 deletions

View File

@ -90,6 +90,7 @@ All these metrics are prefixed with `etcd_grpc_`
|--------------------------------|-------------------------------------------------------------------------------------|------------------------|
| requests_total | Total number of received requests | Counter(method) |
| requests_failed_total | Total number of failed requests.   | Counter(method,error) |
| active_streams | Total number of active streams.   | Gauge(method) |
| unary_requests_duration_seconds | Bucketed handling duration of the requests. | Histogram(method) |

View File

@ -110,7 +110,9 @@ func metricsStreamInterceptor(srv interface{}, ss grpc.ServerStream, info *grpc.
service, method := splitMethodName(info.FullMethod)
receivedCounter.WithLabelValues(service, method).Inc()
streamsGauage.WithLabelValues(service, method).Inc()
err := handler(srv, ss)
streamsGauage.WithLabelValues(service, method).Dec()
if err != nil {
failedCounter.WithLabelValues(service, method, grpc.Code(err).String()).Inc()
}

View File

@ -33,6 +33,14 @@ var (
Help: "Counter of failed requests.",
}, []string{"grpc_service", "grpc_method", "grpc_code"})
streamsGauage = prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Namespace: "etcd",
Subsystem: "grpc",
Name: "active_streams",
Help: "Number of active streams.",
}, []string{"grpc_service", "grpc_method"})
handlingDuration = prometheus.NewHistogramVec(
prometheus.HistogramOpts{
Namespace: "etcd",
@ -60,6 +68,7 @@ var (
func init() {
prometheus.MustRegister(receivedCounter)
prometheus.MustRegister(failedCounter)
prometheus.MustRegister(streamsGauage)
prometheus.MustRegister(handlingDuration)
prometheus.MustRegister(sentBytes)