diff --git a/datastore/datastore/main/main.go b/datastore/datastore/main/main.go index ae19695f..1f78da59 100644 --- a/datastore/datastore/main/main.go +++ b/datastore/datastore/main/main.go @@ -68,7 +68,7 @@ func main() { reg := prometheus.NewRegistry() reg.MustRegister( grpcMetrics, - promservermetrics.ActiveConnections, + promservermetrics.InFlightRequests, promservermetrics.UptimeCounter, promservermetrics.ResponseSizeSummary, collectors.NewGoCollector(), @@ -81,7 +81,7 @@ func main() { server := grpc.NewServer( grpc.ChainUnaryInterceptor( reqTimeLogger, - promservermetrics.ConnectionUnaryInterceptor, + promservermetrics.InFlightRequestInterceptor, promservermetrics.ResponseSizeUnaryInterceptor, grpcMetrics.UnaryServerInterceptor(), ), diff --git a/datastore/datastore/metrics/promservermetrics.go b/datastore/datastore/metrics/promservermetrics.go index f4000431..c7d2cf99 100644 --- a/datastore/datastore/metrics/promservermetrics.go +++ b/datastore/datastore/metrics/promservermetrics.go @@ -14,9 +14,9 @@ var ( Help: "Total uptime of the gRPC server in seconds", }) - ActiveConnections = prometheus.NewGauge(prometheus.GaugeOpts{ - Name: "grpc_active_connections", - Help: "Current number of active gRPC connections", + InFlightRequests = prometheus.NewGauge(prometheus.GaugeOpts{ + Name: "grpc_in_flight_requests", + Help: "Current number of in-flight gRPC requests", }) ResponseSizeSummary = prometheus.NewSummaryVec( @@ -41,9 +41,9 @@ func TrackUptime() { } } -func ConnectionUnaryInterceptor(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error) { - ActiveConnections.Inc() // Increment when a new unary request (connection) is opened - defer ActiveConnections.Dec() // Decrement when the unary request (connection) is completed +func InFlightRequestInterceptor(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error) { + InFlightRequests.Inc() // Increment at the start of the request + defer InFlightRequests.Dec() // Decrement at the end of the request return handler(ctx, req) } diff --git a/grafana/dashboards/grpc-server.json b/grafana/dashboards/grpc-server.json index 22158e5c..6490fc83 100755 --- a/grafana/dashboards/grpc-server.json +++ b/grafana/dashboards/grpc-server.json @@ -1146,14 +1146,14 @@ "uid": "PBFA97CFB590B2093" }, "editorMode": "code", - "expr": "grpc_active_connections", + "expr": "grpc_in_flight_requests", "instant": false, - "legendFormat": "Active gRPC connections", + "legendFormat": "In flight requests", "range": true, "refId": "A" } ], - "title": "Active gRPC connections", + "title": "In flight requests", "type": "timeseries" }, {