Support sharing a data context during PIT data collection
oliversalzburg opened this issue · 2 comments
In a registry with many gauge metrics that are supposed to collect point-in-time data, we rely on pulling that data from an external API. Some of our metrics depend on API responses from the exact same call. As our solution stands today, this incurs duplicate API calls.
We can solve this by creating a context ourselves before we call await register.metrics()
, and then provide and maintain it during the collection process, but this seems not ideal.
I feel like it would be great if prom-client could itself provide means for deduplication of resource acquisition in a collection run, or at least provide means to pass a temporary object into the collection run, so that users have an easy entrypoint to implement deduplication strategies and data sharing in general during a collection run.