go-grpc-middleware
go-grpc-middleware copied to clipboard
Dynamic labels for go-grpc-prometheus middleware
I hope this is the right place for this issue, as I know the repositories are in-flight.
We're implementing customer-facing metrics, so we'd like to be able to label requests with the customer associated with the request.
My naive suggestion is that the middleware take a callback for calculating additional labels.
@bwplotka recommended a workaround that might be possible: using wrapped registries with the middleware.
I'm not sure I follow exactly, do you have an example or POC PR? I think we're still pretty open to changing things since v2 isn't finalized yet.
The idea would be to have an upstream-blessed way to add additional labels (that may have to be computed) to the metrics exposed by the middleware.
For example, we wanted to add a label "tenant" to the histogram labels so that we could show our users performance graphs of their own requests against our service.
Our solution is that we use this middleware without the histogram metrics, then we implemented our own histogram with the same name and labels (plus tenant) and a middleware which times the request and populates the tenant label with a value from the context.Context.