package com.github.ambry.replication;

import com.codahale.metrics.Counter;
import com.codahale.metrics.Gauge;
import com.codahale.metrics.MetricRegistry;
import com.codahale.metrics.Timer;

import java.util.List;

/**
 * Metrics for Replication
 */
public class ReplicationMetrics {

  public final Counter interColoReplicationBytesCount;
  public final Counter intraColoReplicationBytesCount;
  public final Counter interColoBlobsReplicatedCount;
  public final Counter intraColoBlobsReplicatedCount;
  public final Counter replicationErrors;
  public final Timer interColoReplicationLatency;
  public final Timer intraColoReplicationLatency;
  public Gauge<Integer> numberOfReplicaThreads;
  private List<ReplicaThread> replicaThreads;

  public ReplicationMetrics(String name, MetricRegistry registry, List<ReplicaThread> replicaThreads) {
    interColoReplicationBytesCount =
            registry.counter(MetricRegistry.name(ReplicaThread.class, name + ".interColoReplicationBytesCount"));
    intraColoReplicationBytesCount =
            registry.counter(MetricRegistry.name(ReplicaThread.class, name + ".intraColoReplicationBytesCount"));
    interColoBlobsReplicatedCount =
            registry.counter(MetricRegistry.name(ReplicaThread.class, name + ".interColoReplicationBlobsCount"));
    intraColoBlobsReplicatedCount =
            registry.counter(MetricRegistry.name(ReplicaThread.class, name + ".intraColoReplicationBlobsCount"));
    replicationErrors =
            registry.counter(MetricRegistry.name(ReplicaThread.class, name + ".replicationErrors"));
    interColoReplicationLatency =
            registry.timer(MetricRegistry.name(ReplicaThread.class, name + ".interColoReplicationLatency"));
    intraColoReplicationLatency =
            registry.timer(MetricRegistry.name(ReplicaThread.class, name + ".intraColoReplicationLatency"));
    this.replicaThreads = replicaThreads;
    numberOfReplicaThreads = new Gauge<Integer>() {
      @Override
      public Integer getValue() {
        return getLiveThreads();
      }
    };
    registry.register(MetricRegistry.name(ReplicaThread.class, ".numberOfReplicaThreads"), numberOfReplicaThreads);
  }

  private int getLiveThreads() {
    int count = 0;
    for (ReplicaThread thread : replicaThreads) {
      if (thread.isThreadUp()) {
        count++;
      }
    }
    return count;
  }
}

@@ -944,33 +944,32 @@
 .class, name + %22
-.
 interColoReplica
@@ -1094,33 +1094,32 @@
 .class, name + %22
-.
 intraColoReplica
@@ -1243,33 +1243,32 @@
 .class, name + %22
-.
 interColoReplica
@@ -1392,33 +1392,32 @@
 .class, name + %22
-.
 intraColoReplica
@@ -1537,17 +1537,16 @@
 name + %22
-.
 replicat
@@ -1669,17 +1669,16 @@
 name + %22
-.
 interCol
@@ -1811,17 +1811,16 @@
 name + %22
-.
 intraCol
@@ -2099,17 +2099,16 @@
 class, %22
-.
 numberOf

Remove . in metric name