Skip to content

Commit

Permalink
v3rpc: add gRPC active streamsGauge
Browse files Browse the repository at this point in the history
  • Loading branch information
gyuho committed Nov 4, 2016
1 parent 2745942 commit 67082e5
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions Documentation/metrics.md
Original file line number Diff line number Diff line change
Expand Up @@ -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) |


Expand Down
2 changes: 2 additions & 0 deletions etcdserver/api/v3rpc/interceptor.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
Expand Down
9 changes: 9 additions & 0 deletions etcdserver/api/v3rpc/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -60,6 +68,7 @@ var (
func init() {
prometheus.MustRegister(receivedCounter)
prometheus.MustRegister(failedCounter)
prometheus.MustRegister(streamsGauage)
prometheus.MustRegister(handlingDuration)

prometheus.MustRegister(sentBytes)
Expand Down

0 comments on commit 67082e5

Please sign in to comment.