All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.apache.rocketmq.shaded.io.opentelemetry.sdk.metrics.export.AggregationTemporalitySelector Maven / Gradle / Ivy

There is a newer version: 5.0.7
Show newest version
/*
 * Copyright The OpenTelemetry Authors
 * SPDX-License-Identifier: Apache-2.0
 */

package org.apache.rocketmq.shaded.io.opentelemetry.sdk.metrics.export;

import org.apache.rocketmq.shaded.io.opentelemetry.sdk.metrics.InstrumentType;
import org.apache.rocketmq.shaded.io.opentelemetry.sdk.metrics.data.AggregationTemporality;

/**
 * A functional interface that selects {@link AggregationTemporality} based on {@link
 * InstrumentType}.
 */
@FunctionalInterface
public interface AggregationTemporalitySelector {

  /**
   * A common implementation of {@link AggregationTemporalitySelector} which returns {@link
   * AggregationTemporality#CUMULATIVE} for all instruments.
   */
  static AggregationTemporalitySelector alwaysCumulative() {
    return instrumentType -> AggregationTemporality.CUMULATIVE;
  }

  /**
   * A common implementation of {@link AggregationTemporalitySelector} which indicates delta
   * preference.
   *
   * 

{@link AggregationTemporality#DELTA} is returned for {@link InstrumentType#COUNTER}, {@link * InstrumentType#OBSERVABLE_COUNTER}, and {@link InstrumentType#HISTOGRAM}. {@link * AggregationTemporality#CUMULATIVE} is returned for {@link InstrumentType#UP_DOWN_COUNTER} and * {@link InstrumentType#OBSERVABLE_UP_DOWN_COUNTER}. */ static AggregationTemporalitySelector deltaPreferred() { return instrumentType -> { switch (instrumentType) { case UP_DOWN_COUNTER: case OBSERVABLE_UP_DOWN_COUNTER: return AggregationTemporality.CUMULATIVE; case COUNTER: case OBSERVABLE_COUNTER: case HISTOGRAM: default: return AggregationTemporality.DELTA; } }; } /** Return the aggregation temporality for the {@link InstrumentType}. */ AggregationTemporality getAggregationTemporality(InstrumentType instrumentType); }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy