code: public Set<Metric> getMetricsByInstanceTypeAndName(
        MetricsSystem.InstanceType instanceType, String name) {
      if (instanceType == InstanceType.MASTER) {
        return getMasterMetrics(name);
      }
  
      if (instanceType == InstanceType.WORKER) {
        synchronized (mWorkerMetrics) {
          return mWorkerMetrics.getByField(NAME_INDEX, name);
        }
      } else if (instanceType == InstanceType.CLIENT) {
        synchronized (mClientMetrics) {
          return mClientMetrics.getByField(NAME_INDEX, name);
        }
      } else {
        throw new IllegalArgumentException("Unsupported instance type " + instanceType);
      }
    }
docs: Gets all the metrics by instance type and the metric name. The supported instance types are
  worker and client.
  
  @param instanceType the instance type
  @param name the metric name
  @return the set of matched metrics