Class AsyncMetricEntityStateOneEnum<E extends Enum<E> & VeniceDimensionInterface>
java.lang.Object
com.linkedin.venice.stats.metrics.AsyncMetricEntityStateOneEnum<E>
public class AsyncMetricEntityStateOneEnum<E extends Enum<E> & VeniceDimensionInterface>
extends Object
This class is used when the async metric (
MetricType.ASYNC_GAUGE or
MetricType.ASYNC_DOUBLE_GAUGE) has one dynamic dimension which is an
Enum implementing VeniceDimensionInterface.
For each enum value, a separate AsyncMetricEntityStateBase is created with its own callback.
This allows polling different values based on the dimension (e.g., different VersionRole values).
Callers always provide a 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)
EnumMap is used here as it is more efficient than HashMap as it is backed by an array and does
not require hashing of the keys resulting in constant time complexity for get() and put() operations.
-
Method Summary
Modifier and TypeMethodDescriptionstatic <E extends Enum<E> & VeniceDimensionInterface>
AsyncMetricEntityStateOneEnum<E>create(MetricEntity metricEntity, VeniceOpenTelemetryMetricsRepository otelRepository, Map<VeniceMetricsDimensions, String> baseDimensionsMap, Class<E> enumTypeClass, Function<E, DoubleSupplier> callbackProvider) Factory method that accepts aDoubleSuppliercallback for each enum value.booleangetMetricState(E enumValue) Visible for testing
-
Method Details
-
create
public static <E extends Enum<E> & VeniceDimensionInterface> AsyncMetricEntityStateOneEnum<E> create(MetricEntity metricEntity, VeniceOpenTelemetryMetricsRepository otelRepository, Map<VeniceMetricsDimensions, String> baseDimensionsMap, Class<E> enumTypeClass, Function<E, DoubleSupplier> callbackProvider) Factory method that accepts aDoubleSuppliercallback for each enum value. Dispatches to the correct OTel instrument type based onMetricEntity.getMetricType():ASYNC_GAUGEwraps as long (no rounding — simple truncation cast), andASYNC_DOUBLE_GAUGEpasses the double directly.Callers with
longvalues can pass them directly in the lambda — Java auto-widenslongtodouble, which is lossless for all practical metric values. -
emitOpenTelemetryMetrics
public boolean emitOpenTelemetryMetrics() -
getMetricState
-
getMetricStatesByEnum
Visible for testing
-