Class AsyncMetricEntityStateTwoEnums<E1 extends Enum<E1> & VeniceDimensionInterface,E2 extends Enum<E2> & VeniceDimensionInterface>
java.lang.Object
com.linkedin.venice.stats.metrics.AsyncMetricEntityStateTwoEnums<E1,E2>
public class AsyncMetricEntityStateTwoEnums<E1 extends Enum<E1> & VeniceDimensionInterface,E2 extends Enum<E2> & VeniceDimensionInterface>
extends Object
This class is used when the async metric (
MetricType.ASYNC_GAUGE or
MetricType.ASYNC_DOUBLE_GAUGE) has two dynamic dimensions, each of which is an
Enum implementing VeniceDimensionInterface.
For each combination of (E1, E2) enum values, a separate AsyncMetricEntityStateBase
is created with its own callback. The callbacks are pre-registered at construction time.
Callers always provide a BiFunction<E1, E2, DoubleSupplier> callback. The
factory dispatches to the correct OTel instrument type based on the MetricEntity's
MetricType:
ASYNC_GAUGEcreates anObservableLongGauge(value cast to long)ASYNC_DOUBLE_GAUGEcreates anObservableDoubleGauge(value used as-is)
A two-level EnumMap is used for O(1) lookup by (E1, E2) pair, backed by arrays
with no hashing overhead.
-
Method Summary
Modifier and TypeMethodDescriptionstatic <E1 extends Enum<E1> & VeniceDimensionInterface,E2 extends Enum<E2> & VeniceDimensionInterface>
AsyncMetricEntityStateTwoEnums<E1,E2> create(MetricEntity metricEntity, VeniceOpenTelemetryMetricsRepository otelRepository, Map<VeniceMetricsDimensions, String> baseDimensionsMap, Class<E1> enumTypeClass1, Class<E2> enumTypeClass2, BiFunction<E1, E2, DoubleSupplier> callbackProvider) Factory method that accepts aBiFunction<E1, E2, DoubleSupplier>callback for each (E1, E2) combination.booleangetMetricState(E1 e1, E2 e2) Visible for testing
-
Method Details
-
create
public static <E1 extends Enum<E1> & VeniceDimensionInterface,E2 extends Enum<E2> & VeniceDimensionInterface> AsyncMetricEntityStateTwoEnums<E1,E2> create(MetricEntity metricEntity, VeniceOpenTelemetryMetricsRepository otelRepository, Map<VeniceMetricsDimensions, String> baseDimensionsMap, Class<E1> enumTypeClass1, Class<E2> enumTypeClass2, BiFunction<E1, E2, DoubleSupplier> callbackProvider) Factory method that accepts aBiFunction<E1, E2, DoubleSupplier>callback for each (E1, E2) combination. Dispatches to the correct OTel instrument type based onMetricEntity.getMetricType():ASYNC_GAUGEwraps as long (truncation cast), andASYNC_DOUBLE_GAUGEpasses the double directly. -
emitOpenTelemetryMetrics
public boolean emitOpenTelemetryMetrics() -
getMetricState
-
getMetricStatesByEnum
Visible for testing
-