opentelemetry-js icon indicating copy to clipboard operation
opentelemetry-js copied to clipboard

[api] Implement a delegating no-op MeterProvider

Open pichlermarc opened this issue 2 years ago • 4 comments
trafficstars

Is your feature request related to a problem? Please describe.

Currently when a MeterProvider is registered via metrics.setMeterProvider() after acquiring a metrics.getMeterProivder() elsewhere, the previously acquired MeterProvider will stay no-op forever unless replaced manually. This causes instrumentations that are registered before the creation of an SDK MeterProvider to never provide any metrics.

Describe the solution you'd like

Implementing the same delegating-noop similar to the one in the trace API, where a ProxyTracerProvider and ProxyTracer delegate calls to either the registered SDK instance or a NoopTracerProvider or NoopTracer.

Describe alternatives you've considered

  • providing a hook in the API for instrumentations to update their MeterProvider, Meter, or Instrument instances, once a new MeterProvider is registered. However, this may require significant implementation overhead for anyone who wants to take care of such a case.

Additional context

Related

  • #3609
  • https://github.com/open-telemetry/opentelemetry-specification/issues/3068

pichlermarc avatar Feb 20 '23 16:02 pichlermarc