Is your feature request related to a problem?
The PrometheusMetricReader currently hard-codes use of the global REGISTRY instance. That makes it incompatible with programs that construct (and expect to use) a fresh CollectorRegistry for each test (for example, to check that the published metrics accurately reflect the calls expected to occur during the test).
Describe the solution you'd like
Ideally:
PrometheusMetricReader.__init__() should accept a keyword argument for the CollectorRegistry to use (still defaulting to the global REGISTRY), and
- it should be possible to call
metrics.set_meter_provider repeated in the same program to change the configured MeterProvider.
Describe alternatives you've considered
- The program can currently monkey-patch
opentelemetry.exporter.prometheus.REGISTRY prior to creating its PrometheusMetricsReader.
- This approach is viable but extremely hacky.
- Or, the user can refactor all of their tests to run each test that needs a fresh
CollectorRegistry as a subprocess.
- This approach is not viable, because it requires global refactoring to accommodate an arbitrary (local) design decision within the
opentelemetry-python library.
Is your feature request related to a problem?
The
PrometheusMetricReadercurrently hard-codes use of the globalREGISTRYinstance. That makes it incompatible with programs that construct (and expect to use) a freshCollectorRegistryfor each test (for example, to check that the published metrics accurately reflect the calls expected to occur during the test).Describe the solution you'd like
Ideally:
PrometheusMetricReader.__init__()should accept a keyword argument for theCollectorRegistryto use (still defaulting to the globalREGISTRY), andmetrics.set_meter_providerrepeated in the same program to change the configuredMeterProvider.Describe alternatives you've considered
opentelemetry.exporter.prometheus.REGISTRYprior to creating itsPrometheusMetricsReader.CollectorRegistryas a subprocess.opentelemetry-pythonlibrary.