go-grpc-middleware
go-grpc-middleware copied to clipboard
Support for WithSubsystem()
Similar to WithConstLabels(), can we also have WithSubsystem() in github.com/grpc-ecosystem/go-grpc-middleware/providers/prometheus? This will help to rename grpc metrics across different processes. Without this, it causes confusion and difficulty in understanding.
What is a subsystem? I'm not a prometheus expert, could you elaborate on the problem and use case you have?
Hello, Sorry for the delayed response.
Similar to ConstLabels, prometheus.CounterOpts, GaugeOpts, etc also accepts a parameter "Subsystem". As per github.com/prometheus/client_golang/prometheus, Namespace, Subsystem, and Name are components of the fully-qualified name of the Metric (created by joining these components with "_"). Only Name is mandatory, the others merely help structuring the name.
Use case: I have different microservices in my system. All expose metrics along with subsystem name. subsystem name is the identity/name of microservice. ex: SUB1_metricname, SUB2_metricname
So, this helps in readability and debuggability to understand which system component was the source of metric without even looking at metric instance label.
This is the reason for seeking subsystem support for grpc metrics also.
OK, so the proposal is for a new WithSubsystem(subsystem string) option when insantiating the prometheus provider? That sounds reasonable to me. Are you interested in helping to implement this?
Thanks Johan. Raised https://github.com/grpc-ecosystem/go-grpc-middleware/pull/639
@johanbrandhorst Raised new PR https://github.com/grpc-ecosystem/go-grpc-middleware/pull/643 . I had to close earlier one due to some CLA issues.