grpc-ecosystem / go-grpc-prometheus

Prometheus monitoring for your gRPC Go servers.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Client Time Histogram for bidi_stream

davejohnston opened this issue · comments

It looks like after adding EnableClientHandlingTimeHistogram() I can collect counters for unary rpc messages, but there is not reporting on bidirectional streams.

Is this intentional, or a bug?

A bi-directional stream should by definition always be long lasting, what would the histogram reflect?

I was hoping to be able to use it to calculate the average number of messages sent over the stream per second, over a period of time.

I think that's reasonable, but that would be accomplished with a counter, as you use the rate function over the monotonically increasing counter value, thus yielding the messages per second. This is already available with these metrics:

clientStreamMsgReceived: prom.NewCounterVec(
opts.apply(prom.CounterOpts{
Name: "grpc_client_msg_received_total",
Help: "Total number of RPC stream messages received by the client.",
}), []string{"grpc_type", "grpc_service", "grpc_method"}),
clientStreamMsgSent: prom.NewCounterVec(
opts.apply(prom.CounterOpts{
Name: "grpc_client_msg_sent_total",
Help: "Total number of gRPC stream messages sent by the client.",
}), []string{"grpc_type", "grpc_service", "grpc_method"}),

Thanks - looks like the irate() function with the above counter solves my issue.