/*
Convenience method for registering ReducedMetric.
181133
@SuppressWarnings("rawtypes")
  public ReducedMetric registerMetric(String name, IReducer reducer, int timeBucketSizeInSecs) {
    return registerMetric(name, new ReducedMetric(reducer), timeBucketSizeInSecs);
  }
244365
public void setMetricRegistry(Object metricRegistry)
   {
      if (metricRegistry != null && safeIsAssignableFrom(metricRegistry, "com.codahale.metrics.MetricRegistry")) {
         setMetricsTrackerFactory(new CodahaleMetricsTrackerFactory((MetricRegistry) metricRegistry));
      }
      else if (metricRegistry != null && safeIsAssignableFrom(metricRegistry, "io.micrometer.core.instrument.MeterRegistry")) {
         setMetricsTrackerFactory(new MicrometerMetricsTrackerFactory((MeterRegistry) metricRegistry));
      }
      else {
         setMetricsTrackerFactory(null);
      }
   }
547572
public void registerNewMetrics(MetricName name, Metric metric) {
		final Set<MetricName> registeredNames = getNames();
		if (!registeredNames.contains(name)) {
			try {
				register(name, metric);
			} catch (IllegalArgumentException e){/* exception due to race condition*/}
		}
	}
1080354
@Override
    protected void collectMetrics(final Metrics metrics) {
        for (final JvmMetricsCollector collector : _collectorsEnabled) {
            collector.collect(metrics, _managementFactory);
        }
    }
643581
@Override
	public void notifyOfAddedMetric(Metric metric, String metricName, MetricGroup group) {
		final String fullName = group.getMetricIdentifier(metricName, this);

		synchronized (this) {
			if (metric instanceof Counter) {
				counters.put((Counter) metric, fullName);
				registry.register(fullName, new FlinkCounterWrapper((Counter) metric));
			}
			else if (metric instanceof Gauge) {
				gauges.put((Gauge<?>) metric, fullName);
				registry.register(fullName, FlinkGaugeWrapper.fromGauge((Gauge<?>) metric));
			} else if (metric instanceof Histogram) {
				Histogram histogram = (Histogram) metric;
				histograms.put(histogram, fullName);

				if (histogram instanceof DropwizardHistogramWrapper) {
					registry.register(fullName, ((DropwizardHistogramWrapper) histogram).getDropwizardHistogram());
				} else {
					registry.register(fullName, new FlinkHistogramWrapper(histogram));
				}
			} else if (metric instanceof Meter) {
				Meter meter = (Meter) metric;
				meters.put(meter, fullName);

				if (meter instanceof DropwizardMeterWrapper) {
					registry.register(fullName, ((DropwizardMeterWrapper) meter).getDropwizardMeter());
				} else {
					registry.register(fullName, new FlinkMeterWrapper(meter));
				}
			} else {
				log.warn("Cannot add metric of type {}. This indicates that the reporter " +
					"does not support this metric type.", metric.getClass().getName());
			}
		}
	}
764045
public void register() {
		registrations.add(editService.addGeometryEditMoveHandler(this));
		registrations.add(editService.addGeometryEditShapeChangedHandler(this));
		registrations.add(editService.addGeometryEditTentativeMoveHandler(this));
		registrations.add(editService.addGeometryEditChangeStateHandler(this));
	}
1175920
@Override
  public <T> CombinedMetric<T> registerMetric(String name,
                                              ICombiner<T> combiner,
                                              int timeBucketSizeInSecs) {
    return registerMetric(name, new CombinedMetric<>(combiner), timeBucketSizeInSecs);
  }
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);
    }
489825
Map<String, MetricValues> encodeRegistry(
        Registry sourceRegistry, Predicate<Measurement> filter) {
    Map<String, MetricValues> metricMap = new HashMap<>();

    /*
     * Flatten the meter measurements into a map of measurements keyed by
     * the name and mapped to the different tag variants.
     */
    for (Meter meter : sourceRegistry) {
      String kind = knownMeterKinds.computeIfAbsent(
                         meter.id(), k -> meterToKind(sourceRegistry, meter));

      for (Measurement measurement : meter.measure()) {
        if (!filter.test(measurement)) {
          continue;
        }
        if (Double.isNaN(measurement.value())) {
          continue;
        }

        String meterName = measurement.id().name();
        MetricValues have = metricMap.get(meterName);
        if (have == null) {
          metricMap.put(meterName, new MetricValues(kind, measurement));
        } else {
          have.addMeasurement(measurement);
        }
      }
    }
    return metricMap;
  }
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);
		}
	}
824074
public void startMetricReporting(Configuration configuration) {
    Properties props = new Properties();
    for (Map.Entry<String, String> entry : configuration) {
      props.put(entry.getKey(), entry.getValue());
    }
    startMetricReporting(props);
  }
27289
protected void regenerateMetrics() {
    if (isInstrumentationEnabled()) {
      this.datasetsCleanFailureMeter =
          Optional.of(this.metricContext.meter(DatasetCleanerMetrics.DATASETS_CLEAN_FAILURE));
      this.datasetsCleanSuccessMeter =
          Optional.of(this.metricContext.meter(DatasetCleanerMetrics.DATASETS_CLEAN_SUCCESS));
    }
  }
782665
public synchronized void pushMetric(final MetricsRecord mr) {
    if (changed) 
      mr.setMetric(getName(), value);
    changed = false;
  }
535008
@Reference(
            name = "carbon.metrics.service",
            service = MetricService.class,
            cardinality = ReferenceCardinality.MANDATORY,
            policy = ReferencePolicy.DYNAMIC,
            unbind = "unsetMetricService"
    )
    protected void setMetricService(MetricService metricService) {
        DataHolder.getInstance().setMetricService(metricService);
    }
472217
protected void regenerateMetrics() {
    if (isInstrumentationEnabled()) {
      this.recordsInMeter = Optional.of(this.metricContext.meter(MetricNames.ConverterMetrics.RECORDS_IN_METER));
      this.recordsOutMeter = Optional.of(this.metricContext.meter(MetricNames.ConverterMetrics.RECORDS_OUT_METER));
      this.recordsExceptionMeter = Optional.of(
          this.metricContext.meter(MetricNames.ConverterMetrics.RECORDS_FAILED_METER));
      this.converterTimer = Optional.<Timer>of(this.metricContext.timer(MetricNames.ConverterMetrics.CONVERT_TIMER));
    }
  }
239453
@Override
  public void reduceToSegmentKeys() {
    if (segmentRegistration != null && size > 0) {
      int sizeCopy = size;
      String[] keyListCopy = keyList.clone();
      T1[][] fullValueListCopy = fullValueList.clone();
      size = 0;
      for (int i = 0; i < sizeCopy; i++) {
        if (segmentKeys.contains(keyListCopy[i])) {
          keyList[size] = keyListCopy[i];
          fullValueList[size] = fullValueListCopy[i];
          size++;
        }
      }
    }
  }
1250879
def register(self, params, target):
        """"""
        self._space.register(params, target)
        self.dispatch(Events.OPTMIZATION_STEP)