Class RecordLevelDelayOtelStats

java.lang.Object
com.linkedin.davinci.stats.ingestion.heartbeat.RecordLevelDelayOtelStats

public class RecordLevelDelayOtelStats extends Object
OpenTelemetry metrics for record-level delay monitoring. Tracks delays for regular data records (not heartbeat control messages).

SLO classification dimensions (VeniceStoreWriteType, VeniceChunkingStatus, VeniceRegionLocality) are supplied by the caller on every record so they reflect the version-level configuration the caller resolved (rather than store-level approximations baked in at construction time). Write-type and chunking are emitted as dynamic dimensions; locality stays a base dimension because it is a deterministic function of the source region — caller provides the resolved enum on the first call per region, and it is cached in that region's MetricEntityStateFiveEnums instance.

Note: Tehuti metrics are managed separately in HeartbeatStatReporter.

  • Constructor Details

    • RecordLevelDelayOtelStats

      public RecordLevelDelayOtelStats(io.tehuti.metrics.MetricsRepository metricsRepository, String storeName, String clusterName)
  • Method Details

    • emitOtelMetrics

      public boolean emitOtelMetrics()
      Returns true if OTel metrics are emitted.
    • updateVersionInfo

      public void updateVersionInfo(int currentVersion, int futureVersion)
      Updates the current and future version for this store.
      Parameters:
      currentVersion - The current serving version
      futureVersion - The future/upcoming version
    • recordRecordDelayOtelMetrics

      public void recordRecordDelayOtelMetrics(int version, String region, ReplicaType replicaType, ReplicaState replicaState, VeniceStoreWriteType writeType, VeniceChunkingStatus chunkingStatus, VeniceRegionLocality locality, long delayMs)
      Records a record-level delay with all dimensional attributes to OTel metrics. Returns early only when OTel emission is disabled. Version classification is best-effort: OtelVersionedStatsUtils.classifyVersion(int, com.linkedin.davinci.stats.OtelVersionedStatsUtils.VersionInfo) returns VersionRole.BACKUP for any version that is neither current nor future — including unknown/0/-1 — and emission still proceeds.
      Parameters:
      version - The version number (used to classify VersionRole as CURRENT/FUTURE/BACKUP)
      region - The record's source region
      replicaType - The replica type ReplicaType
      replicaState - The replica state ReplicaState
      writeType - Pre-resolved write-type label (REGULAR / WRITE_COMPUTE)
      chunkingStatus - Pre-resolved chunking label (CHUNKED / UNCHUNKED)
      locality - Pre-resolved locality label (LOCAL / REMOTE) — applied to the per-region metric state on first call per region; subsequent calls reuse the cached state
      delayMs - The delay in milliseconds
    • getVersionInfo

      public OtelVersionedStatsUtils.VersionInfo getVersionInfo()
    • close

      public void close()
      Clears the per-region metric state map, releasing references to MetricEntityState objects. Does not deregister OTel instruments from the metrics repository — they will be cleaned up when the Meter/MeterProvider is closed or the SDK shuts down.