CachedHistogram getLatencyHistogram(ReplicaId replicaId) {
    boolean isLocalReplica = replicaId.getDataNodeId().getDatacenterName().equals(datacenterName);
    CachedHistogram histogramToReturn;
    switch (routerConfig.routerOperationTrackerMetricScope) {
      case Datacenter:
        histogramToReturn = isLocalReplica ? localDcHistogram : crossDcHistogram;
        break;
      case Partition:
        PartitionId partitionId = replicaId.getPartitionId();
        histogramToReturn = isLocalReplica ? localDcResourceToHistogram.computeIfAbsent(partitionId,
            k -> createHistogram(routerConfig, false))
            : crossDcResourceToHistogram.computeIfAbsent(partitionId, k -> createHistogram(routerConfig, false));
        break;
      case DataNode:
        DataNodeId dataNodeId = replicaId.getDataNodeId();
        histogramToReturn = isLocalReplica ? localDcResourceToHistogram.computeIfAbsent(dataNodeId,
            k -> createHistogram(routerConfig, false))
            : crossDcResourceToHistogram.computeIfAbsent(dataNodeId, k -> createHistogram(routerConfig, false));
        break;
      case Disk:
        DiskId diskId = replicaId.getDiskId();
        histogramToReturn = isLocalReplica ? localDcResourceToHistogram.computeIfAbsent(diskId,
            k -> createHistogram(routerConfig, false))
            : crossDcResourceToHistogram.computeIfAbsent(diskId, k -> createHistogram(routerConfig, false));
        break;
      default:
        throw new IllegalArgumentException("Unsupported operation tracker metric scope.");
    }
    return histogramToReturn;
  }
Gets the {@link Histogram} that tracks request latencies to the class of replicas (intra or inter DC) that
{@code replicaId} belongs to.
@param replicaId the {@link ReplicaId} whose request latency is going to be tracked.
@return the {@link CachedHistogram} associated with this replica.
ambry-router/src/main/java/com/github/ambry/router/AdaptiveOperationTracker.java