Add a new metrics to the registry
@param metricsName - the name
@param theMetricsObj - the metrics
@throws IllegalArgumentException if a name is already registered
1957
public void add(final String metricsName, final MetricsBase theMetricsObj) {
    if (metricsList.putIfAbsent(metricsName, theMetricsObj) != null) {
      throw new IllegalArgumentException("Duplicate metricsName:" + metricsName);
    }
  }
33338
public final void updateMetric(MetricName name, Object value) {
        if (!started) {
            return;
        }
        PcpValueInfo info = metricData.get(name);
        if (info == null) {
            throw new IllegalArgumentException("Metric " + name
                    + " was not added before initialising the writer");
        }
        updateValue(info, value);
    }
1084933
public void registerAll(Metric2Set metrics) throws IllegalArgumentException {
		for (Map.Entry<MetricName, Metric> entry : metrics.getMetrics().entrySet()) {
			register(entry.getKey(), entry.getValue());
		}
	}
964203
public void registerAny(Metric2Set metrics) {
		for (Map.Entry<MetricName, Metric> entry : metrics.getMetrics().entrySet()) {
			registerNewMetrics(entry.getKey(), entry.getValue());
		}
	}
284607
public void addMetric(final IMetric<?> metric) {
    // metric null or already present
    if (metric == null) {
      throw new IllegalArgumentException("Cannot add a null metric");
    }

    if (getMetricFromName(metric.getName()) == null) {
      logger.debug(String.format("Adding %s metric in Metric Manager", metric.getName()));
      this.metrics.add(metric);
      metric.updateMetricManager(this);
    } else {
      logger.error("Failed to add metric");
    }
  }
467437
private void configureJobLevelMetrics(final JobRunner jobRunner) {
    this.logger.info("Configuring Azkaban metrics tracking for jobrunner object");
    if (MetricReportManager.isAvailable()) {
      final MetricReportManager metricManager = MetricReportManager.getInstance();

      // Adding NumRunningJobMetric listener
      jobRunner.addListener((NumRunningJobMetric) metricManager
          .getMetricFromName(NumRunningJobMetric.NUM_RUNNING_JOB_METRIC_NAME));

      // Adding NumFailedJobMetric listener
      jobRunner.addListener((NumFailedJobMetric) metricManager
          .getMetricFromName(NumFailedJobMetric.NUM_FAILED_JOB_METRIC_NAME));

    }

    jobRunner.addListener(JmxJobMBeanManager.getInstance());
  }
958819
@Override
  public String metricNamePrefix(boolean includeTagKeys) {
    return Joiner.on('.').join(includeTagKeys ? getTags() : this.tags.values());
  }
1049479
protected void configureMetrics() {
        setConfigProperty(GatewayConfigProperties.METRICS_CLASS, ESMetrics.class.getName());
        setConfigProperty(GatewayConfigProperties.METRICS_CLASS + ".client.type", "jest");
        setConfigProperty(GatewayConfigProperties.METRICS_CLASS + ".client.protocol", "${apiman.es.protocol}");
        setConfigProperty(GatewayConfigProperties.METRICS_CLASS + ".client.host", "${apiman.es.host}");
        setConfigProperty(GatewayConfigProperties.METRICS_CLASS + ".client.port", "${apiman.es.port}");
        setConfigProperty(GatewayConfigProperties.METRICS_CLASS + ".client.username", "${apiman.es.username}");
        setConfigProperty(GatewayConfigProperties.METRICS_CLASS + ".client.password", "${apiman.es.password}");
        setConfigProperty(GatewayConfigProperties.METRICS_CLASS + ".client.index", "apiman_metrics");
    }
1212179
static MetricFamilySamples createDescribableMetricFamilySamples(
      MetricDescriptor metricDescriptor, String namespace) {
    String name = getNamespacedName(metricDescriptor.getName(), namespace);
    Type type = getType(metricDescriptor.getType());
    List<String> labelNames = convertToLabelNames(metricDescriptor.getLabelKeys());

    if (containsDisallowedLeLabelForHistogram(labelNames, type)) {
      throw new IllegalStateException(
          "Prometheus Histogram cannot have a label named 'le', "
              + "because it is a reserved label for bucket boundaries. "
              + "Please remove this key from your view.");
    }

    if (containsDisallowedQuantileLabelForSummary(labelNames, type)) {
      throw new IllegalStateException(
          "Prometheus Summary cannot have a label named 'quantile', "
              + "because it is a reserved label. Please remove this key from your view.");
    }

    return new MetricFamilySamples(
        name, type, metricDescriptor.getDescription(), Collections.<Sample>emptyList());
  }
218039
public synchronized void pushMetric(final MetricsRecord mr) {
    if (changed) {
      try {
        mr.setMetric(getName(), value);
      } catch (Exception e) {
        LOG.info("pushMetric failed for " + getName() + "\n" +
            StringUtils.stringifyException(e));
      }
    }
    changed = false;
  }
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);
      }
    }
  }
283701
@Override
  public Meter meter(String name) {
    final com.codahale.metrics.Meter meter = registry.meter(name);
    return new Meter() {
      @Override
      public void mark() {
        meter.mark();
      }

      @Override
      public void mark(long size) {
        meter.mark(size);
      }
    };
  }
120905
public void registerMetrics() {
        if (metricsAreRegistered) {
            return;
        }
        getMetricRegistry().register("jvm.attribute", new JvmAttributeGaugeSet());
        getMetricRegistry().register("jvm.buffers", new BufferPoolMetricSet(ManagementFactory
                                                                               .getPlatformMBeanServer()));
        getMetricRegistry().register("jvm.classloader", new ClassLoadingGaugeSet());
        getMetricRegistry().register("jvm.filedescriptor", new FileDescriptorRatioGauge());
        getMetricRegistry().register("jvm.gc", new GarbageCollectorMetricSet());
        getMetricRegistry().register("jvm.memory", new MemoryUsageGaugeSet());
        getMetricRegistry().register("jvm.threads", new ThreadStatesGaugeSet());

        JmxReporter.forRegistry(metricRegistry).build().start();
        metricsAreRegistered = true;
    }
848317
public void add(final Metric metric) {
		Preconditions.checkNotNull(metric);
		
		// get the aggregate for this minute
		
		MetricAggregate aggregate = getAggregate(metric.getIdentity());
		
		// add the current metric into the aggregate
		
		switch (metric.getIdentity().getType()) {
			case COUNTER: 
			case TIMER: 
			case AVERAGE:
				aggregate.setCount(aggregate.getCount() + 1);
				aggregate.setValue(aggregate.getValue() + metric.getValue());
			    break;
			case GAUGE:
				aggregate.setCount(1);
				if (metric.isIncrement()) {
					aggregate.setValue(aggregate.getValue() + metric.getValue());
				} else {
					aggregate.setValue(metric.getValue());
				}
			    break;	
			default:
				LOGGER.info("Unable to aggregate {} metric type", metric.getIdentity().getType());
				break;
		}
	}
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");

        }
    }
1265535
public <T extends ContextAwareMetric> T register(T metric) throws IllegalArgumentException {
    return register(metric.getName(), metric);
  }
782665
public synchronized void pushMetric(final MetricsRecord mr) {
    if (changed) 
      mr.setMetric(getName(), value);
    changed = false;
  }