def _unique_metric_name(name, existing_metrics):
  """Returns a unique name given the existing metric names."""
  existing_names = set([metric.name for metric in existing_metrics])

  proposed_name = name
  cnt = 1  # Start incrementing with 1.
  # Increment name suffix until the name is unique.
  while proposed_name in existing_names:
    proposed_name = name + "_" + str(cnt)
    cnt += 1

  return proposed_name