Interface MetricProducer


@ThreadSafe public interface MetricProducer
MetricProducer is the interface that is used to make metric data available to the MetricReaders. The primary implementation is provided by SdkMeterProvider.

Alternative MetricProducer implementations can be used to bridge aggregated metrics from other frameworks, and are registered with SdkMeterProviderBuilder.registerMetricProducer(MetricProducer). NOTE: When possible, metrics from other frameworks SHOULD be bridged using the metric API, normally with asynchronous instruments which observe the aggregated state of the other framework. However, MetricProducer exists to accommodate scenarios where the metric API is insufficient. It should be used with caution as it requires the bridge to take a dependency on opentelemetry-sdk-metrics, which is generally not advised.

Implementations must be thread-safe.

Since:
1.31.0
  • Method Summary

    Modifier and Type
    Method
    Description
    produce(io.opentelemetry.sdk.resources.Resource resource)
    Returns a collection of produced MetricDatas to be exported.
  • Method Details

    • produce

      Collection<MetricData> produce(io.opentelemetry.sdk.resources.Resource resource)
      Returns a collection of produced MetricDatas to be exported. This will only be those metrics that have been produced since the last time this method was called.
      Returns:
      a collection of produced MetricDatas to be exported.