Open carlpett opened 6 years ago
In my opinion, I would let the library have it's own requirement to prom-client
and then create all their metrics in a custom registry. Then in the main application, I would merge the global one and the one that exists in the library.
Sounds reasonable, thanks! Perhaps this should be suggested in the documentation? Or is the use-case of including metrics in libraries not wide-spread enough that it warrants mention?
We should most definitely document this.
At work we have prom-client
as a peerDependency
to ensure there is only one in the entire application. We have been playing around with an idea using either some global variable as registry, bein purely event based, or have each module expose a stream of standardized metrics you can pipe together and feed into prom-client
at the top.
Would love to find a good solution to this
We're building a library that will be used by teams inside our organization, and inside this library we want to expose metrics. However, from what I can deduce (as a very novice node.js developer), if our library has a dependency on
prom-client
, we receive our own "copy" of everything, including registries?What is the suggested pattern in this case? Should the main application pass in the registry as part of initialization of each library, or is there some way to actually not get copies everywhere?