Class StoreVersionOtelStats
- All Implemented Interfaces:
StoreDataChangedListener,Closeable,AutoCloseable
ASYNC_GAUGE callbacks per store for the current and future version numbers.
Metric: store.version with dimensions CLUSTER_NAME, STORE_NAME,
and VERSION_ROLE. Only CURRENT and FUTURE
are emitted — backup version number is not tracked.
This class implements StoreDataChangedListener and should be registered once per process
on the metadata repository via register(ReadOnlyStoreRepository). Per-store state is
created lazily on first store change and bounded by the number of distinct store names ever
observed by the process (entries are not removed on deletion — see cleanup limitation below).
Cleanup limitation: the OTel SDK does support per-instrument deregistration via
ObservableLongGauge.close(), but the current Venice wrapper
(AsyncMetricEntityStateBase) doesn't surface the SDK instrument handle, so callbacks
remain registered until the MetricsRepository is closed. On store deletion, version
info is reset to OtelVersionedStatsUtils.VersionInfo.NON_EXISTING rather than removed — see
handleStoreDeleted(java.lang.String) for why removing the map entry is unsafe given the current wrapper.
-
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Unregisters this OTel listener from the metadata repository.static StoreVersionOtelStatscreate(io.tehuti.metrics.MetricsRepository metricsRepository, String clusterName, ReadOnlyStoreRepository metadataRepository) Creates and registers aStoreVersionOtelStatslistener on the given metadata repository.voidhandleStoreChanged(Store store) voidhandleStoreCreated(Store store) Do NOT try to acquire the lock of store repository again in the implementation, otherwise a dead lock issue will happen.voidhandleStoreDeleted(String storeName) Resets version info toOtelVersionedStatsUtils.VersionInfo.NON_EXISTINGrather than removing the map entry.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.linkedin.venice.meta.StoreDataChangedListener
handleStoreDeleted
-
Method Details
-
create
public static StoreVersionOtelStats create(io.tehuti.metrics.MetricsRepository metricsRepository, String clusterName, ReadOnlyStoreRepository metadataRepository) Creates and registers aStoreVersionOtelStatslistener on the given metadata repository. Initializes gauges for all pre-existing stores. This is the preferred entry point — it combines construction and registration to prevent the listener from existing in an unregistered state. -
close
public void close()Unregisters this OTel listener from the metadata repository. Idempotent.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable
-
handleStoreCreated
Description copied from interface:StoreDataChangedListenerDo NOT try to acquire the lock of store repository again in the implementation, otherwise a dead lock issue will happen.- Specified by:
handleStoreCreatedin interfaceStoreDataChangedListener
-
handleStoreChanged
- Specified by:
handleStoreChangedin interfaceStoreDataChangedListener
-
handleStoreDeleted
Resets version info toOtelVersionedStatsUtils.VersionInfo.NON_EXISTINGrather than removing the map entry. The async-gauge callback closes over theAtomicReference, which the Venice wrapper doesn't currently surface for de-registration. Removing the map entry would orphan the live callback (SDK keeps polling stale data); a subsequent re-create would register a second callback emitting under the same attributes. Resetting keeps one live callback pointed at the right state across delete→re-create cycles.- Specified by:
handleStoreDeletedin interfaceStoreDataChangedListener
-