Given a metric set, registers the ones not already registered.
This method prevents IllegalArgumentException
@param metrics a set of metrics
964203
public void registerAny(Metric2Set metrics) {
		for (Map.Entry<MetricName, Metric> entry : metrics.getMetrics().entrySet()) {
			registerNewMetrics(entry.getKey(), entry.getValue());
		}
	}
47424
def register(metric_name)
      metric_name = metric_name.to_s
      metric_exists = self.for(metric_name).present?

      if metric_exists
        raise(
          MetricAlreadyRegistered,
          "There's a metric already registered with the name `:#{metric_name}`, must be unique"
        )
      end

      metric_manifest = MetricManifest.new(metric_name: metric_name)

      yield(metric_manifest)

      metric_manifest.validate!

      metrics_manifests << metric_manifest
    end
1077343
protected List<Metric> mapping(List<Metric> metrics, List<String> constants) {
		SystemAssert.requireArgument(metrics != null, "Cannot transform null metrics");

		if (metrics.isEmpty()) {
			return metrics;
		}

		List<Metric> newMetricsList = new ArrayList<Metric>();

		for (Metric metric : metrics) {
			metric.setDatapoints(this.valueReducerOrMapping.mapping(metric.getDatapoints(), constants));
			newMetricsList.add(metric);
		}
		return newMetricsList;
	}
864940
public void registerMetrics(MetricRegistry metricRegistry) {
        if (id() != null) {
            metricName = MetricRegistry.name(Pipeline.class, id(), "executed");
            executed = metricRegistry.meter(metricName);
        }
    }
799639
public List<Metric> union(List<Metric> metrics) {
        SystemAssert.requireArgument(metrics != null, "Cannot transform empty metric/metrics");
        if (metrics.isEmpty()) {
            return metrics;
        }

        Metric newMetric = reduce(metrics);
        Map<Long, Double> reducedDatapoints = newMetric.getDatapoints();
        Set<Long> sharedTimestamps = reducedDatapoints.keySet();
        Map<Long, Double> unionDatapoints = new TreeMap<>();

        for (Metric metric : metrics) {
            for (Map.Entry<Long, Double> entry : metric.getDatapoints().entrySet()) {
                if (!sharedTimestamps.contains(entry.getKey())) {
                    unionDatapoints.put(entry.getKey(), entry.getValue());
                }
            }
        }
        
        newMetric.addDatapoints(unionDatapoints);
        return Arrays.asList(newMetric);
    }
1172140
public void heartbeat(final List<Metric> metrics) throws IOException {
    connect();
    try {
      MetricsHeartbeatPRequest.Builder request = MetricsHeartbeatPRequest.newBuilder();
      request.setClientId(IdUtils.createOrGetAppIdFromConfig(mContext.getConf()));
      request.setHostname(NetworkAddressUtils.getClientHostName(mContext.getConf()));
      request.setOptions(MetricsHeartbeatPOptions.newBuilder().addAllMetrics(metrics).build());
      mClient.metricsHeartbeat(request.build());
    } catch (io.grpc.StatusRuntimeException e) {
      throw new UnavailableException(e);
    }
  }
387916
public void setCommittedMetrics() {
    	for (MetricImpl.MetricType metricType : this.tranCoordinatedMetricTypes) {
    		committedMetrics.put(metricType.name(), new MetricImpl(metricType, this.getMetric(metricType).getValue()));
    	}
    }
1347546
@Override
  public void doUpdates(MetricsContext unused) {
    synchronized (this) {
      for (MetricsBase m : registry.getMetricsList()) {
        m.pushMetric(metricsRecord);
      }
    }
    metricsRecord.update();
  }
1202537
public void registerMetrics(MetricRegistry metricRegistry, String pipelineId, String stageId) {
        if (id() == null) {
            LOG.debug("Not registering metrics for unsaved rule {}", name());
            return;
        }
        if (id() != null) {
            globalExecuted = registerGlobalMeter(metricRegistry, "executed");
            localExecuted = registerLocalMeter(metricRegistry, pipelineId, stageId, "executed");

            globalFailed = registerGlobalMeter(metricRegistry, "failed");
            localFailed = registerLocalMeter(metricRegistry, pipelineId, stageId, "failed");

            globalMatched = registerGlobalMeter(metricRegistry, "matched");
            localMatched = registerLocalMeter(metricRegistry, pipelineId, stageId, "matched");

            globalNotMatched = registerGlobalMeter(metricRegistry, "not-matched");
            localNotMatched = registerLocalMeter(metricRegistry, pipelineId, stageId, "not-matched");

        }
    }
133406
@Inject
    public void setReporterMetrics(@Nullable ReporterMetrics metrics) {
        if (metrics != null) {
            builder.metrics(metrics);
        }
    }
545928
public void setMetricList(java.util.Collection<MetricKeyDataPoints> metricList) {
        if (metricList == null) {
            this.metricList = null;
            return;
        }

        this.metricList = new java.util.ArrayList<MetricKeyDataPoints>(metricList);
    }
763228
public void putWorkerMetrics(String hostname, List<Metric> metrics) {
    if (metrics.isEmpty()) {
      return;
    }
    synchronized (mWorkerMetrics) {
      mWorkerMetrics.removeByField(ID_INDEX, getFullInstanceId(hostname, null));
      for (Metric metric : metrics) {
        if (metric.getHostname() == null) {
          continue; // ignore metrics whose hostname is null
        }
        mWorkerMetrics.add(metric);
      }
    }
  }
1074686
public void setMetrics(java.util.Collection<MetricDataQuery> metrics) {
        if (metrics == null) {
            this.metrics = null;
            return;
        }

        this.metrics = new com.amazonaws.internal.SdkInternalList<MetricDataQuery>(metrics);
    }
811856
public void add(Metric m) {
        final MetricName key = m.getName();
        metrics_.put(key, m);
    }
883567
public void submitMetrics(MetricsRecord metricsRecord) {
    List<PoolMetadata> poolMetadatas = getPoolMetadataList();
    PoolFairnessCalculator.calculateFairness(poolMetadatas, metricsRecord);
    for (SchedulerForType scheduler: schedulersForTypes.values()) {
      scheduler.submitMetrics();
    }
  }
717798
public Group withMetrics(java.util.Map<String, MetricValue> metrics) {
        setMetrics(metrics);
        return this;
    }
9475
public void accumulate(List<? extends StandardMetricResult> metricValues) {
        if (metricValues == null || metricValues.isEmpty()) return;
        for (StandardMetricResult v : metricValues) {
            if (lastOffset < v.offset) values.put(v.value.intValue());
        }
        lastOffset = ListUtils.last(metricValues).offset;
    }