Registers all the metrics in this metrics pack.

@param metricsRegistry the MetricsRegister upon which the metrics are registered.
977871
public static void register(MetricsRegistry metricsRegistry) {
        checkNotNull(metricsRegistry, "metricsRegistry");

        GcStats stats = new GcStats();
        metricsRegistry.scheduleAtFixedRate(stats, PUBLISH_FREQUENCY_SECONDS, SECONDS, INFO);
        metricsRegistry.scanAndRegister(stats, "gc");
    }
813752
private void addMetric(
      List<Metric> metrics,
      String name,
      TagList tags,
      Object value) {
    long now = System.currentTimeMillis();
    if (onlyNumericMetrics) {
      value = asNumber(value);
    }
    if (value != null) {

      TagList newTags = counters.matches(MonitorConfig.builder(name).withTags(tags).build())
          ? getTagListWithAdditionalTag(tags, DataSourceType.COUNTER)
          : getTagListWithAdditionalTag(tags, DataSourceType.GAUGE);
      Metric m = new Metric(name, newTags, now, value);
      metrics.add(m);
    }
  }
1158739
public static void registerQueueLengthMetrics(MetricGroup group, SingleInputGate gate) {
		InputGateMetrics metrics = new InputGateMetrics(gate);

		group.gauge("totalQueueLen", metrics.getTotalQueueLenGauge());
		group.gauge("minQueueLen", metrics.getMinQueueLenGauge());
		group.gauge("maxQueueLen", metrics.getMaxQueueLenGauge());
		group.gauge("avgQueueLen", metrics.getAvgQueueLenGauge());
	}
472152
public void setMetricData(java.util.Collection<MetricDatapoint> metricData) {
        if (metricData == null) {
            this.metricData = null;
            return;
        }

        this.metricData = new java.util.ArrayList<MetricDatapoint>(metricData);
    }
602317
public void registerAll(String prefix, MetricSet metrics) throws IllegalArgumentException {
        for (Map.Entry<String, Metric> entry : metrics.getMetrics().entrySet()) {
            if (entry.getValue() instanceof MetricSet) {
                registerAll(name(prefix, entry.getKey()), (MetricSet) entry.getValue());
            } else {
                register(name(prefix, entry.getKey()), entry.getValue());
            }
        }
    }
544225
@Override
    public <T extends Metric> T register(String name, T metric) throws IllegalArgumentException {
        // For MP Metrics 1.0, MetricType.from(Class in) does not support lambdas or proxy classes
        return register(name, metric, new Metadata(name, from(metric)));
    }
985795
public void processMetricAggregation() {
        if (!isEmpty(metricAggregation)) {
            String[] aggregations = metricAggregation.split(";");
            for (int i = 0; i < aggregations.length; i++) {
                String definition = aggregations[i].trim();
                int index0 = definition.indexOf("=");
                int index1 = definition.indexOf("(");
                int index2 = definition.indexOf(")");
                String aggregatedName = definition.substring(0, index0);
                String operation = definition.substring(index0 + 1, index1);
                String parameters = definition.substring(index1 + 1, index2);
                List<String> metricNames = new ArrayList<>();
                metricNames.add(operation);
                // Case a list of metricNames
                if (parameters.contains(",")) {
                    String[] listMetricNames = parameters.split(",");
                    for (int j = 0; j < listMetricNames.length; j++) {
                        metricNames.add(listMetricNames[j].trim());
                    }
                } else {
                    Pattern pattern = Pattern.compile(parameters);
                    for (String metricName : nameIdMetrics.keySet()) {
                        if (pattern.matcher(metricName).matches()) {
                            metricNames.add(metricName);
                        }
                    }
                }
                aggregatedMetrics.put(aggregatedName, metricNames);
            }
            log.debugf("Gnocchi Aggregated Metrics from %s -> %s", metricAggregation, aggregatedMetrics);
        }
    }
545928
public void setMetricList(java.util.Collection<MetricKeyDataPoints> metricList) {
        if (metricList == null) {
            this.metricList = null;
            return;
        }

        this.metricList = new java.util.ArrayList<MetricKeyDataPoints>(metricList);
    }
497540
public static void setCommonAttributes(List<Metric> metrics, Metric result) {
        MetricDistiller distiller = new MetricDistiller();

        distiller.distill(metrics);
        result.setDisplayName(distiller.getDisplayName());
        result.setUnits(distiller.getUnits());
        result.setTags(distiller.getTags());
    }
88797
public static void startSinks(String metricsConfFile) {
    synchronized (MetricsSystem.class) {
      if (sSinks != null) {
        LOG.info("Sinks have already been started.");
        return;
      }
    }
    if (metricsConfFile.isEmpty()) {
      LOG.info("Metrics is not enabled.");
      return;
    }
    MetricsConfig config = new MetricsConfig(metricsConfFile);
    startSinksFromConfig(config);
  }
986468
public void forceGatherAllMetrics() {
    LOG.info("Forcing to gather all metrics and flush out.");
    Metrics.MetricPublisherPublishMessage.Builder builder =
        Metrics.MetricPublisherPublishMessage.newBuilder();

    for (List<String> metricNames : timeBucketToMetricNames.values()) {
      for (String metricName : metricNames) {
        gatherOneMetric(metricName, builder);
      }
    }

    metricCollectionCount.incr();
    addDataToMetricPublisher(builder, COLLECTION_COUNT_NAME, metricCollectionCount);

    Metrics.MetricPublisherPublishMessage msg = builder.build();

    queue.offer(msg);
  }
1287968
public void selfRegister() {
        LocalUnitsManager.unitMap(unitMap -> {
            unitMap.forEach((groupName, unitsIgnored) -> {
                try {
                    ServiceInstance<GroupProxy> serviceInstance = ZkServiceInstanceAdaptor.thisCuratorServiceInstance(groupName);
                    serviceDiscovery.registerService(serviceInstance);
                } catch (Exception e) {
                    LOG.error(e);
                    //the registration should not be interrupted due to one error.
                }
            });
        });
    }
1265535
public <T extends ContextAwareMetric> T register(T metric) throws IllegalArgumentException {
    return register(metric.getName(), metric);
  }
813073
@Override
	public void notifyOfAddedMetric(Metric metric, String metricName, MetricGroup group) {
		final String domain = generateJmxDomain(metricName, group);
		final Hashtable<String, String> table = generateJmxTable(group.getAllVariables());

		AbstractBean jmxMetric;
		ObjectName jmxName;
		try {
			jmxName = new ObjectName(domain, table);
		} catch (MalformedObjectNameException e) {
			/**
			 * There is an implementation error on our side if this occurs. Either the domain was modified and no longer
			 * conforms to the JMX domain rules or the table wasn't properly generated.
			 */
			LOG.debug("Implementation error. The domain or table does not conform to JMX rules." , e);
			return;
		}

		if (metric instanceof Gauge) {
			jmxMetric = new JmxGauge((Gauge<?>) metric);
		} else if (metric instanceof Counter) {
			jmxMetric = new JmxCounter((Counter) metric);
		} else if (metric instanceof Histogram) {
			jmxMetric = new JmxHistogram((Histogram) metric);
		} else if (metric instanceof Meter) {
			jmxMetric = new JmxMeter((Meter) metric);
		} else {
			LOG.error("Cannot add unknown metric type: {}. This indicates that the metric type " +
				"is not supported by this reporter.", metric.getClass().getName());
			return;
		}

		try {
			synchronized (this) {
				mBeanServer.registerMBean(jmxMetric, jmxName);
				registeredMetrics.put(metric, jmxName);
			}
		} catch (NotCompliantMBeanException e) {
			// implementation error on our side
			LOG.debug("Metric did not comply with JMX MBean rules.", e);
		} catch (InstanceAlreadyExistsException e) {
			LOG.warn("A metric with the name " + jmxName + " was already registered.", e);
		} catch (Throwable t) {
			LOG.warn("Failed to register metric", t);
		}
	}
705433
public void setMetricDataResults(java.util.Collection<MetricDataResult> metricDataResults) {
        if (metricDataResults == null) {
            this.metricDataResults = null;
            return;
        }

        this.metricDataResults = new com.amazonaws.internal.SdkInternalList<MetricDataResult>(metricDataResults);
    }
701822
public void registerMetrics(MetricRegistry metricRegistry, String pipelineId) {
        meterName = name(Pipeline.class, pipelineId, "stage", String.valueOf(stage()), "executed");
        executed = metricRegistry.meter(meterName);
    }
1151345
public void setMetricTransformations(java.util.Collection<MetricTransformation> metricTransformations) {
        if (metricTransformations == null) {
            this.metricTransformations = null;
            return;
        }

        this.metricTransformations = new com.amazonaws.internal.SdkInternalList<MetricTransformation>(metricTransformations);
    }