On Thu, 23 Apr 2020 at 10:46, Brian Brazil <[email protected]>
wrote:

> On Wed, 22 Apr 2020 at 22:04, 'Chris Taylor' via Prometheus Developers <
> [email protected]> wrote:
>
>> Dear Prometheans,
>>
>> posting this here because the Github issue template suggested discussing
>> changes on the
>> mailing list first.
>>
>> I just discovered the `promauto.With(Reigsterer)` API[1] today, which
>> looked like a nice way
>> to ensure that metrics are registered with a Registerer when they are
>> created.
>>
>> In my use-case, the code receives the Registerer as a dependency.
>> Since it may be called multiple times, I'd like to be able to register
>> metrics multiple times,
>> As an example, imagine writing a middleware to instrument an HTTP
>> handler, similar to
>> package promhttp:
>>
>
> It sounds like your instrumentation might be at the wrong level, have you
> tried instrumenting this at the http router instead?
>

sorry, I wasn't clear enough. The HTTP handler was just supposed to be a
familiar stand-in for
"some library code that is instrumented with metrics that users instantiate
multiple times".
The concrete use-case I was looking at when I wrote the email related to
service discovery
that can be used in various contexts, but my question really applies to any
time you'd want to
wrap some interface in a version with instrumentation.


>
> Brian
>
>
>>
>> func InstrumentedHandler(r Registerer, next http.Handler) http.Handler {
>>   // register a bunch of metrics on `r` and return a Handler that
>>   // bumps them appropriately
>> }
>>
>> Currently, my code uses prometheus.Register(), and checks whether the
>> returned error is
>> a prometheus.AlreadyRegisteredError to get access to the
>> previously-registered metric and
>> uses that instead.
>>
>> It'd be easy enough to write a "lenient" version of promauto.Filter that
>> uses this logic.
>> Would it make sense to add this to client_golang? If so, what do you
>> think the API should
>> look like?
>>
>> Thanks for your time!
>> Chris
>>
>> [1]:
>> https://pkg.go.dev/github.com/prometheus/[email protected]/prometheus/promauto?tab=doc#With
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Prometheus Developers" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to [email protected].
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/prometheus-developers/97aa0973-1a26-4a16-af27-b1d926971c21%40googlegroups.com
>> <https://groups.google.com/d/msgid/prometheus-developers/97aa0973-1a26-4a16-af27-b1d926971c21%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>
>
> --
> Brian Brazil
> www.robustperception.io
>

-- 
You received this message because you are subscribed to the Google Groups 
"Prometheus Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/prometheus-developers/CACXQWu6fA%2BT8q-0Z8iqj4WOLyjwuH8MNPWf4F-RATzdSpUNh5Q%40mail.gmail.com.

Reply via email to