Class MeterSdkProvider

  • All Implemented Interfaces:
    io.opentelemetry.api.metrics.MeterProvider

    public final class MeterSdkProvider
    extends java.lang.Object
    implements io.opentelemetry.api.metrics.MeterProvider
    Meter provider implementation for MeterProvider.

    This class is not intended to be used in application code and it is used only by OpenTelemetry.

    • Method Detail

      • get

        public io.opentelemetry.sdk.metrics.MeterSdk get​(java.lang.String instrumentationName)
        Specified by:
        get in interface io.opentelemetry.api.metrics.MeterProvider
      • get

        public io.opentelemetry.sdk.metrics.MeterSdk get​(java.lang.String instrumentationName,
                                                         @Nullable
                                                         java.lang.String instrumentationVersion)
        Specified by:
        get in interface io.opentelemetry.api.metrics.MeterProvider
      • getMetricProducer

        public MetricProducer getMetricProducer()
        Returns the MetricProducer that can be used to retrieve metrics from this MeterSdkProvider.

        WARNING: A MetricProducer is stateful. It will only return changes since the last time it was accessed. This means that if more than one MetricExporter has a handle to this MetricProducer, the two exporters will not receive copies of the same metric data to export.

        Returns:
        the MetricProducer that can be used to retrieve metrics from this MeterSdkProvider.
      • registerView

        public void registerView​(InstrumentSelector selector,
                                 AggregationConfiguration specification)
        Register a view with the given InstrumentSelector.

        Example on how to register a view:

        
         // get a handle to the MeterSdkProvider
         MeterSdkProvider meterProvider = OpenTelemetrySdk.getMeterProvider();
        
         // create a selector to select which instruments to customize:
         InstrumentSelector instrumentSelector = InstrumentSelector.newBuilder()
           .instrumentType(InstrumentType.COUNTER)
           .build();
        
         // create a specification of how you want the metrics aggregated:
         AggregationConfiguration viewSpecification =
           AggregationConfiguration.create(Aggregations.minMaxSumCount(), Temporality.DELTA);
        
         //register the view with the MeterSdkProvider
         meterProvider.registerView(instrumentSelector, viewSpecification);
         
        See Also:
        AggregationConfiguration