Reads metrics from the SDK. Implementations MUST follow the Metric Reader Specification as well as the requirements listed in this interface. Consider extending MetricReader to get a specification-compliant base implementation of this interface

interface IMetricReader {
    collect(
        options?: CommonReaderOptions,
    ): Promise<metrics.CollectionResult>;
    forceFlush(options?: CommonReaderOptions): Promise<void>;
    selectAggregation(
        instrumentType: metrics.InstrumentType,
    ): metrics.AggregationOption;
    selectAggregationTemporality(
        instrumentType: metrics.InstrumentType,
    ): metrics.AggregationTemporality;
    selectCardinalityLimit(instrumentType: metrics.InstrumentType): number;
    setMetricProducer(metricProducer: metrics.MetricProducer): void;
    shutdown(options?: CommonReaderOptions): Promise<void>;
}

Implemented by

Methods

  • Flushes metrics read by this reader, the promise will reject after the optional timeout or resolve after completion.

    NOTE: this operation MAY continue even after the promise rejects due to a timeout.

    Parameters

    • Optionaloptions: CommonReaderOptions

      options with timeout.

    Returns Promise<void>

  • Select the cardinality limit for the given InstrumentType for this reader.

    NOTE: implementations MUST be pure

    Parameters

    Returns number

  • Set the MetricProducer used by this instance. This should only be called once by the SDK and should be considered internal.

    NOTE: implementations MUST throw when called more than once

    Parameters

    Returns void

  • Shuts down the metric reader, the promise will reject after the optional timeout or resolve after completion.

    NOTE: this operation MAY continue even after the promise rejects due to a timeout.

    Parameters

    • Optionaloptions: CommonReaderOptions

      options with timeout.

    Returns Promise<void>