Class OtelVersionedStatsUtils

java.lang.Object
com.linkedin.davinci.stats.OtelVersionedStatsUtils

public class OtelVersionedStatsUtils extends Object
Shared utilities for OpenTelemetry versioned stats classes that classify and resolve version roles.
  • Method Details

    • classifyVersion

      public static VersionRole classifyVersion(int version, OtelVersionedStatsUtils.VersionInfo versionInfo)
      Classifies a version as CURRENT, FUTURE, or BACKUP. Returns VersionRole.BACKUP when versionInfo is null (e.g., store not yet registered in a per-store version info map).
      Parameters:
      version - The version number to classify
      versionInfo - The current/future version info, or null
      Returns:
      VersionRole.CURRENT if version matches currentVersion, VersionRole.FUTURE if version matches futureVersion, VersionRole.BACKUP otherwise or if versionInfo is null
    • getVersionForRole

      public static int getVersionForRole(VersionRole role, OtelVersionedStatsUtils.VersionInfo versionInfo, Set<Integer> knownVersions)
      Resolves a VersionRole to a version number using the given OtelVersionedStatsUtils.VersionInfo and a set of known version numbers. For VersionRole.BACKUP, returns the smallest version that is neither current nor future (deterministic selection from an unordered set).
      Parameters:
      role - The version role to resolve
      versionInfo - The current/future version info (read once from volatile before calling)
      knownVersions - The set of known version numbers (e.g., from a per-version map's keySet)
      Returns:
      The version number, or Store.NON_EXISTING_VERSION if versionInfo is null, no backup version exists, or the role is not recognized