You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I found myself in a situation where I had to instantiate multiple
instances of a third party library that registered some metrics and
never un-registered them.
In my app's lifecycle I needed to un-register them and then register
them again, but I couldn't achieve that by wrapping the Registerer.
I decided to register that library's metrics in a separate Registry and
register that Registry, but in order to handle multiple instances of the
library, I also needed to wrap it with labels, and while such
functionality existed already as part of the Registerer wrapping, it
wasn't exposed.
This PR just exposes Collector wrapping as a public function.
Signed-off-by: Oleg Zaytsev <[email protected]>
// {"name":"http_requests_info","help":"Information about the received HTTP requests.","type":"COUNTER","metric":[{"label":[{"name":"code","value":"200"},{"name":"method","value":"GET"}],"counter":{"value":42}},{"label":[{"name":"code","value":"404"},{"name":"method","value":"POST"}],"counter":{"value":15}}]}
786
787
}
788
+
789
+
// Using WrapCollectorWith to un-register metrics registered by a third party lib.
790
+
// newThirdPartyLibFoo illustrates a constructor from a third-party lib that does
791
+
// not expose any way to un-register metrics.
792
+
funcExampleWrapCollectorWith() {
793
+
reg:=prometheus.NewRegistry()
794
+
795
+
// We want to create two instances of thirdPartyLibFoo, each one wrapped with
0 commit comments