go-grpc-middleware icon indicating copy to clipboard operation
go-grpc-middleware copied to clipboard

Support for WithSubsystem()

Open rohsaini opened this issue 2 years ago • 5 comments

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.

rohsaini avatar Sep 06 '23 05:09 rohsaini

What is a subsystem? I'm not a prometheus expert, could you elaborate on the problem and use case you have?

johanbrandhorst avatar Sep 07 '23 18:09 johanbrandhorst

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.

rohsaini avatar Sep 14 '23 04:09 rohsaini

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?

johanbrandhorst avatar Sep 14 '23 23:09 johanbrandhorst

Thanks Johan. Raised https://github.com/grpc-ecosystem/go-grpc-middleware/pull/639

rohsaini avatar Sep 15 '23 09:09 rohsaini

@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.

rohsaini avatar Sep 18 '23 08:09 rohsaini