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

org.apache.rocketmq.shaded.io.opentelemetry.sdk.metrics.internal.view.LastValueAggregation 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.internal.view;

import org.apache.rocketmq.shaded.io.opentelemetry.sdk.metrics.Aggregation;
import org.apache.rocketmq.shaded.io.opentelemetry.sdk.metrics.InstrumentType;
import org.apache.rocketmq.shaded.io.opentelemetry.sdk.metrics.data.ExemplarData;
import org.apache.rocketmq.shaded.io.opentelemetry.sdk.metrics.internal.aggregator.Aggregator;
import org.apache.rocketmq.shaded.io.opentelemetry.sdk.metrics.internal.aggregator.AggregatorFactory;
import org.apache.rocketmq.shaded.io.opentelemetry.sdk.metrics.internal.aggregator.DoubleLastValueAggregator;
import org.apache.rocketmq.shaded.io.opentelemetry.sdk.metrics.internal.aggregator.LongLastValueAggregator;
import org.apache.rocketmq.shaded.io.opentelemetry.sdk.metrics.internal.descriptor.InstrumentDescriptor;
import org.apache.rocketmq.shaded.io.opentelemetry.sdk.metrics.internal.exemplar.ExemplarFilter;
import org.apache.rocketmq.shaded.io.opentelemetry.sdk.metrics.internal.exemplar.ExemplarReservoir;

/**
 * Last-value aggregation configuration.
 *
 * 

This class is internal and is hence not for public use. Its APIs are unstable and can change * at any time. */ public final class LastValueAggregation implements Aggregation, AggregatorFactory { private static final Aggregation INSTANCE = new LastValueAggregation(); public static Aggregation getInstance() { return INSTANCE; } private LastValueAggregation() {} @Override @SuppressWarnings("unchecked") public Aggregator createAggregator( InstrumentDescriptor instrumentDescriptor, ExemplarFilter exemplarFilter) { // For the initial version we do not sample exemplars on gauges. switch (instrumentDescriptor.getValueType()) { case LONG: return (Aggregator) new LongLastValueAggregator(ExemplarReservoir::longNoSamples); case DOUBLE: return (Aggregator) new DoubleLastValueAggregator(ExemplarReservoir::doubleNoSamples); } throw new IllegalArgumentException("Invalid instrument value type"); } @Override public boolean isCompatibleWithInstrument(InstrumentDescriptor instrumentDescriptor) { return instrumentDescriptor.getType() == InstrumentType.OBSERVABLE_GAUGE; } @Override public String toString() { return "LastValueAggregation"; } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy