public void removeMetricsForRemoteReplicaInfo(RemoteReplicaInfo remoteReplicaInfo) {
    String metricNamePrefix = generateRemoteReplicaMetricPrefix(remoteReplicaInfo);
    String metadataRequestErrorMetricName = metricNamePrefix + "-metadataRequestError";
    if (metadataRequestErrorMap.remove(metadataRequestErrorMetricName) == null) {
      // if there is no metric associated with given remote replica info, this means it has already been removed
      return;
    }
    registry.remove(MetricRegistry.name(ReplicaThread.class, metadataRequestErrorMetricName));
    String getRequestErrorMetricName = metricNamePrefix + "-getRequestError";
    getRequestErrorMap.remove(getRequestErrorMetricName);
    registry.remove(MetricRegistry.name(ReplicaThread.class, getRequestErrorMetricName));
    String localStoreErrorMetricName = metricNamePrefix + "-localStoreError";
    localStoreErrorMap.remove(localStoreErrorMetricName);
    String replicaToReplicationFetchBytesRateMetricName = metricNamePrefix + REPLICATION_FETCH_BYTES_RATE_SUFFIX;
    replicaToReplicationFetchBytesRateMap.remove(replicaToReplicationFetchBytesRateMetricName);
    registry.remove(MetricRegistry.name(ReplicaThread.class, replicaToReplicationFetchBytesRateMetricName));
    registry.remove(MetricRegistry.name(ReplicaThread.class, localStoreErrorMetricName));
    registry.remove(MetricRegistry.name(ReplicaThread.class, metricNamePrefix + "-remoteLagInBytes"));
  }
Add metrics for given remote replica.
@param remoteReplicaInfo the {@link RemoteReplicaInfo} that contains all infos associated with remote replica
@param trackPerDatacenterLag whether to track remote replicas' lag from local by each datacenter. Specifically, it
                             tracks min/max/avg remote replica lag from each datacenter.
@param trackPerReplicaReplicationBytes whether to track replicated bytes per second from each remote replica,
                                       replica thread is replicating from.
ambry-replication/src/main/java/com/github/ambry/replication/ReplicationMetrics.java