grpc-spring-boot-starter
grpc-spring-boot-starter copied to clipboard
Expose Metric Counter for Number of Received/Sent Stream Messages
When using GRPC streams, it’s interesting to see how many messages are sent/received on the stream(s). It would be great if this starter offered such a metric by default. Ideally, this would work analogous to how the grpc.server.calls
timer is constructed For example, the new metrics should also consult RequestAwareGRpcMetricsTagsContributor
. There should probably also be an analogous ResponseAwareGRpcMetricsTagsContributor
.
From my point of view, the new counters will only be necessary on client stream, server stream and bidi requests. For unary requests, the counter of grpc.server.call
already gives the number of transfered requests and responses. Hence, the new metrics could be called something like grpc.server.stream.messages.received
and grpc.server.stream.messages.sent
.
There already is a MetricCollectingServerInterceptor
from Micrometer. However, I suspect re-using that will be more complicated than rolling a custom one in this repository.
However, I suspect re-using that will be more complicated than rolling a custom one in this repository.
Have you tried to simply add it as a @Bean @GRpcGlobalInterceptor
:
@Configuration
public class MyConfig{
@Bean
@GRpcGlobalInterceptor
public ServerInterceptor metricsInterceptor(MeterRegistry registry){
return new MetricCollectingServerInterceptor(registry);
}
}
I have. This is what we are currently using and it is providing metrics. However, we want to add tags depending on the request or response. This is not possible with the Micrometer interceptor
Hence our requirement to integrate with RequestAwareGRpcMetricsTagsContributor
s.