org.apache.flink.metrics.Metric Java Examples

The following examples show how to use org.apache.flink.metrics.Metric. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AbstractReporter.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
@Override
public void notifyOfAddedMetric(Metric metric, String metricName, MetricGroup group) {
	final MetricInfo metricInfo = metricInfoProvider.getMetricInfo(metricName, group);
	synchronized (this) {
		if (metric instanceof Counter) {
			counters.put((Counter) metric, metricInfo);
		} else if (metric instanceof Gauge) {
			gauges.put((Gauge<?>) metric, metricInfo);
		} else if (metric instanceof Histogram) {
			histograms.put((Histogram) metric, metricInfo);
		} else if (metric instanceof Meter) {
			meters.put((Meter) metric, metricInfo);
		} else {
			log.warn("Cannot add unknown metric type {}. This indicates that the reporter " +
				"does not support this metric type.", metric.getClass().getName());
		}
	}
}
 
Example #2
Source File: DatadogHttpReporter.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
@Override
public void notifyOfAddedMetric(Metric metric, String metricName, MetricGroup group) {
	final String name = group.getMetricIdentifier(metricName);

	List<String> tags = new ArrayList<>(configTags);
	tags.addAll(getTagsFromMetricGroup(group));
	String host = getHostFromMetricGroup(group);

	if (metric instanceof Counter) {
		Counter c = (Counter) metric;
		counters.put(c, new DCounter(c, name, host, tags));
	} else if (metric instanceof Gauge) {
		Gauge g = (Gauge) metric;
		gauges.put(g, new DGauge(g, name, host, tags));
	} else if (metric instanceof Meter) {
		Meter m = (Meter) metric;
		// Only consider rate
		meters.put(m, new DMeter(m, name, host, tags));
	} else if (metric instanceof Histogram) {
		LOGGER.warn("Cannot add {} because Datadog HTTP API doesn't support Histogram", metricName);
	} else {
		LOGGER.warn("Cannot add unknown metric type {}. This indicates that the reporter " +
			"does not support this metric type.", metric.getClass().getName());
	}
}
 
Example #3
Source File: ScheduledDropwizardReporter.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
@Override
public void notifyOfRemovedMetric(Metric metric, String metricName, MetricGroup group) {
	synchronized (this) {
		String fullName;

		if (metric instanceof Counter) {
			fullName = counters.remove(metric);
		} else if (metric instanceof Gauge) {
			fullName = gauges.remove(metric);
		} else if (metric instanceof Histogram) {
			fullName = histograms.remove(metric);
		} else if (metric instanceof Meter) {
			fullName = meters.remove(metric);
		} else {
			fullName = null;
		}

		if (fullName != null) {
			registry.remove(fullName);
		}
	}
}
 
Example #4
Source File: AbstractMetricGroup.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
public void close() {
	synchronized (this) {
		if (!closed) {
			closed = true;

			// close all subgroups
			for (AbstractMetricGroup group : groups.values()) {
				group.close();
			}
			groups.clear();

			// un-register all directly contained metrics
			for (Map.Entry<String, Metric> metric : metrics.entrySet()) {
				registry.unregister(metric.getValue(), metric.getKey(), this);
			}
			metrics.clear();
		}
	}
}
 
Example #5
Source File: AbstractPrometheusReporter.java    From flink with Apache License 2.0 6 votes vote down vote up
private Collector createCollector(Metric metric, List<String> dimensionKeys, List<String> dimensionValues, String scopedMetricName, String helpString) {
	Collector collector;
	if (metric instanceof Gauge || metric instanceof Counter || metric instanceof Meter) {
		collector = io.prometheus.client.Gauge
			.build()
			.name(scopedMetricName)
			.help(helpString)
			.labelNames(toArray(dimensionKeys))
			.create();
	} else if (metric instanceof Histogram) {
		collector = new HistogramSummaryProxy((Histogram) metric, scopedMetricName, helpString, dimensionKeys, dimensionValues);
	} else {
		log.warn("Cannot create collector for unknown metric type: {}. This indicates that the metric type is not supported by this reporter.",
			metric.getClass().getName());
		collector = null;
	}
	return collector;
}
 
Example #6
Source File: DatadogHttpReporter.java    From flink with Apache License 2.0 6 votes vote down vote up
@Override
public void notifyOfAddedMetric(Metric metric, String metricName, MetricGroup group) {
	final String name = group.getMetricIdentifier(metricName);

	List<String> tags = new ArrayList<>(configTags);
	tags.addAll(getTagsFromMetricGroup(group));
	String host = getHostFromMetricGroup(group);

	if (metric instanceof Counter) {
		Counter c = (Counter) metric;
		counters.put(c, new DCounter(c, name, host, tags));
	} else if (metric instanceof Gauge) {
		Gauge g = (Gauge) metric;
		gauges.put(g, new DGauge(g, name, host, tags));
	} else if (metric instanceof Meter) {
		Meter m = (Meter) metric;
		// Only consider rate
		meters.put(m, new DMeter(m, name, host, tags));
	} else if (metric instanceof Histogram) {
		LOGGER.warn("Cannot add {} because Datadog HTTP API doesn't support Histogram", metricName);
	} else {
		LOGGER.warn("Cannot add unknown metric type {}. This indicates that the reporter " +
			"does not support this metric type.", metric.getClass().getName());
	}
}
 
Example #7
Source File: AbstractReporter.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
@Override
public void notifyOfAddedMetric(Metric metric, String metricName, MetricGroup group) {
	final String name = group.getMetricIdentifier(metricName, this);

	synchronized (this) {
		if (metric instanceof Counter) {
			counters.put((Counter) metric, name);
		} else if (metric instanceof Gauge) {
			gauges.put((Gauge<?>) metric, name);
		} else if (metric instanceof Histogram) {
			histograms.put((Histogram) metric, name);
		} else if (metric instanceof Meter) {
			meters.put((Meter) metric, name);
		} else {
			log.warn("Cannot add unknown metric type {}. This indicates that the reporter " +
				"does not support this metric type.", metric.getClass().getName());
		}
	}
}
 
Example #8
Source File: ScheduledDropwizardReporter.java    From flink with Apache License 2.0 6 votes vote down vote up
@Override
public void notifyOfRemovedMetric(Metric metric, String metricName, MetricGroup group) {
	synchronized (this) {
		String fullName;

		if (metric instanceof Counter) {
			fullName = counters.remove(metric);
		} else if (metric instanceof Gauge) {
			fullName = gauges.remove(metric);
		} else if (metric instanceof Histogram) {
			fullName = histograms.remove(metric);
		} else if (metric instanceof Meter) {
			fullName = meters.remove(metric);
		} else {
			fullName = null;
		}

		if (fullName != null) {
			registry.remove(fullName);
		}
	}
}
 
Example #9
Source File: AbstractReporter.java    From flink with Apache License 2.0 6 votes vote down vote up
@Override
public void notifyOfAddedMetric(Metric metric, String metricName, MetricGroup group) {
	final MetricInfo metricInfo = metricInfoProvider.getMetricInfo(metricName, group);
	synchronized (this) {
		if (metric instanceof Counter) {
			counters.put((Counter) metric, metricInfo);
		} else if (metric instanceof Gauge) {
			gauges.put((Gauge<?>) metric, metricInfo);
		} else if (metric instanceof Histogram) {
			histograms.put((Histogram) metric, metricInfo);
		} else if (metric instanceof Meter) {
			meters.put((Meter) metric, metricInfo);
		} else {
			log.warn("Cannot add unknown metric type {}. This indicates that the reporter " +
				"does not support this metric type.", metric.getClass().getName());
		}
	}
}
 
Example #10
Source File: AbstractReporter.java    From flink with Apache License 2.0 6 votes vote down vote up
@Override
public void notifyOfAddedMetric(Metric metric, String metricName, MetricGroup group) {
	final String name = group.getMetricIdentifier(metricName, this);

	synchronized (this) {
		if (metric instanceof Counter) {
			counters.put((Counter) metric, name);
		} else if (metric instanceof Gauge) {
			gauges.put((Gauge<?>) metric, name);
		} else if (metric instanceof Histogram) {
			histograms.put((Histogram) metric, name);
		} else if (metric instanceof Meter) {
			meters.put((Meter) metric, name);
		} else {
			log.warn("Cannot add unknown metric type {}. This indicates that the reporter " +
				"does not support this metric type.", metric.getClass().getName());
		}
	}
}
 
Example #11
Source File: AbstractPrometheusReporter.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
private Collector createCollector(Metric metric, List<String> dimensionKeys, List<String> dimensionValues, String scopedMetricName, String helpString) {
	Collector collector;
	if (metric instanceof Gauge || metric instanceof Counter || metric instanceof Meter) {
		collector = io.prometheus.client.Gauge
			.build()
			.name(scopedMetricName)
			.help(helpString)
			.labelNames(toArray(dimensionKeys))
			.create();
	} else if (metric instanceof Histogram) {
		collector = new HistogramSummaryProxy((Histogram) metric, scopedMetricName, helpString, dimensionKeys, dimensionValues);
	} else {
		log.warn("Cannot create collector for unknown metric type: {}. This indicates that the metric type is not supported by this reporter.",
			metric.getClass().getName());
		collector = null;
	}
	return collector;
}
 
Example #12
Source File: AbstractMetricGroup.java    From flink with Apache License 2.0 6 votes vote down vote up
public void close() {
	synchronized (this) {
		if (!closed) {
			closed = true;

			// close all subgroups
			for (AbstractMetricGroup group : groups.values()) {
				group.close();
			}
			groups.clear();

			// un-register all directly contained metrics
			for (Map.Entry<String, Metric> metric : metrics.entrySet()) {
				registry.unregister(metric.getValue(), metric.getKey(), this);
			}
			metrics.clear();
		}
	}
}
 
Example #13
Source File: JMXReporter.java    From flink with Apache License 2.0 6 votes vote down vote up
@Override
public void notifyOfRemovedMetric(Metric metric, String metricName, MetricGroup group) {
	try {
		synchronized (this) {
			final ObjectName jmxName = registeredMetrics.remove(metric);

			// remove the metric if it is known. if it is not known, ignore the request
			if (jmxName != null) {
				mBeanServer.unregisterMBean(jmxName);
			}
		}
	} catch (InstanceNotFoundException e) {
		// alright then
	} catch (Throwable t) {
		// never propagate exceptions - the metrics reporter should not affect the stability
		// of the running system
		LOG.error("Un-registering metric failed", t);
	}
}
 
Example #14
Source File: AbstractReporter.java    From flink with Apache License 2.0 6 votes vote down vote up
@Override
public void notifyOfRemovedMetric(Metric metric, String metricName, MetricGroup group) {
	synchronized (this) {
		if (metric instanceof Counter) {
			counters.remove(metric);
		} else if (metric instanceof Gauge) {
			gauges.remove(metric);
		} else if (metric instanceof Histogram) {
			histograms.remove(metric);
		} else if (metric instanceof Meter) {
			meters.remove(metric);
		} else {
			log.warn("Cannot remove unknown metric type {}. This indicates that the reporter " +
				"does not support this metric type.", metric.getClass().getName());
		}
	}
}
 
Example #15
Source File: InterceptingOperatorMetricGroup.java    From flink with Apache License 2.0 5 votes vote down vote up
@Override
protected void addMetric(String name, Metric metric) {
	if (intercepted == null) {
		intercepted = new HashMap<>();
	}
	intercepted.put(name, metric);
	super.addMetric(name, metric);
}
 
Example #16
Source File: AbstractPrometheusReporter.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
private void removeMetric(Metric metric, List<String> dimensionValues, Collector collector) {
	if (metric instanceof Gauge) {
		((io.prometheus.client.Gauge) collector).remove(toArray(dimensionValues));
	} else if (metric instanceof Counter) {
		((io.prometheus.client.Gauge) collector).remove(toArray(dimensionValues));
	} else if (metric instanceof Meter) {
		((io.prometheus.client.Gauge) collector).remove(toArray(dimensionValues));
	} else if (metric instanceof Histogram) {
		((HistogramSummaryProxy) collector).remove(dimensionValues);
	} else {
		log.warn("Cannot remove unknown metric type: {}. This indicates that the metric type is not supported by this reporter.",
			metric.getClass().getName());
	}
}
 
Example #17
Source File: AbstractPrometheusReporter.java    From flink with Apache License 2.0 5 votes vote down vote up
private void addMetric(Metric metric, List<String> dimensionValues, Collector collector) {
	if (metric instanceof Gauge) {
		((io.prometheus.client.Gauge) collector).setChild(gaugeFrom((Gauge) metric), toArray(dimensionValues));
	} else if (metric instanceof Counter) {
		((io.prometheus.client.Gauge) collector).setChild(gaugeFrom((Counter) metric), toArray(dimensionValues));
	} else if (metric instanceof Meter) {
		((io.prometheus.client.Gauge) collector).setChild(gaugeFrom((Meter) metric), toArray(dimensionValues));
	} else if (metric instanceof Histogram) {
		((HistogramSummaryProxy) collector).addChild((Histogram) metric, dimensionValues);
	} else {
		log.warn("Cannot add unknown metric type: {}. This indicates that the metric type is not supported by this reporter.",
			metric.getClass().getName());
	}
}
 
Example #18
Source File: AbstractPrometheusReporter.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
@Override
public void notifyOfRemovedMetric(final Metric metric, final String metricName, final MetricGroup group) {

	List<String> dimensionValues = new LinkedList<>();
	for (final Map.Entry<String, String> dimension : group.getAllVariables().entrySet()) {
		dimensionValues.add(labelValueCharactersFilter.filterCharacters(dimension.getValue()));
	}

	final String scopedMetricName = getScopedName(metricName, group);
	synchronized (this) {
		final AbstractMap.SimpleImmutableEntry<Collector, Integer> collectorWithCount = collectorsWithCountByMetricName.get(scopedMetricName);
		final Integer count = collectorWithCount.getValue();
		final Collector collector = collectorWithCount.getKey();

		removeMetric(metric, dimensionValues, collector);

		if (count == 1) {
			try {
				CollectorRegistry.defaultRegistry.unregister(collector);
			} catch (Exception e) {
				log.warn("There was a problem unregistering metric {}.", scopedMetricName, e);
			}
			collectorsWithCountByMetricName.remove(scopedMetricName);
		} else {
			collectorsWithCountByMetricName.put(scopedMetricName, new AbstractMap.SimpleImmutableEntry<>(collector, count - 1));
		}
	}
}
 
Example #19
Source File: PrometheusReporterTest.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
private void assertThatGaugeIsExported(Metric metric, String name, String expectedValue) throws UnirestException {
	final String prometheusName = SCOPE_PREFIX + name;
	assertThat(addMetricAndPollResponse(metric, name),
		containsString(HELP_PREFIX + prometheusName + " " + name + " (scope: taskmanager)\n" +
			TYPE_PREFIX + prometheusName + " gauge" + "\n" +
			prometheusName + DEFAULT_LABELS + " " + expectedValue + "\n"));
}
 
Example #20
Source File: AbstractPrometheusReporter.java    From flink with Apache License 2.0 5 votes vote down vote up
@Override
public void notifyOfAddedMetric(final Metric metric, final String metricName, final MetricGroup group) {

	List<String> dimensionKeys = new LinkedList<>();
	List<String> dimensionValues = new LinkedList<>();
	for (final Map.Entry<String, String> dimension : group.getAllVariables().entrySet()) {
		final String key = dimension.getKey();
		dimensionKeys.add(CHARACTER_FILTER.filterCharacters(key.substring(1, key.length() - 1)));
		dimensionValues.add(labelValueCharactersFilter.filterCharacters(dimension.getValue()));
	}

	final String scopedMetricName = getScopedName(metricName, group);
	final String helpString = metricName + " (scope: " + getLogicalScope(group) + ")";

	final Collector collector;
	Integer count = 0;

	synchronized (this) {
		if (collectorsWithCountByMetricName.containsKey(scopedMetricName)) {
			final AbstractMap.SimpleImmutableEntry<Collector, Integer> collectorWithCount = collectorsWithCountByMetricName.get(scopedMetricName);
			collector = collectorWithCount.getKey();
			count = collectorWithCount.getValue();
		} else {
			collector = createCollector(metric, dimensionKeys, dimensionValues, scopedMetricName, helpString);
			try {
				collector.register();
			} catch (Exception e) {
				log.warn("There was a problem registering metric {}.", metricName, e);
			}
		}
		addMetric(metric, dimensionValues, collector);
		collectorsWithCountByMetricName.put(scopedMetricName, new AbstractMap.SimpleImmutableEntry<>(collector, count + 1));
	}
}
 
Example #21
Source File: AbstractMetricGroupTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Override
public void checkScopes(Metric metric, String metricName, MetricGroup group) {
	// the first call determines which filter is applied to all future calls; in this case no filter is used at all
	assertEquals("A-B-C-D-1", group.getMetricIdentifier(metricName));
	// from now on the scope string is cached and should not be reliant on the given filter
	assertEquals("A-B-C-D-1", group.getMetricIdentifier(metricName, FILTER_C));
	assertEquals("A-B-C-D-1", group.getMetricIdentifier(metricName, this));
	// the metric name however is still affected by the filter as it is not cached
	assertEquals("A-B-C-D-4", group.getMetricIdentifier(metricName, new CharacterFilter() {
		@Override
		public String filterCharacters(String input) {
			return input.replace("B", "X").replace("1", "4");
		}
	}));
}
 
Example #22
Source File: InterceptingOperatorMetricGroup.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
@Override
protected void addMetric(String name, Metric metric) {
	if (intercepted == null) {
		intercepted = new HashMap<>();
	}
	intercepted.put(name, metric);
	super.addMetric(name, metric);
}
 
Example #23
Source File: DatadogHttpReporter.java    From flink with Apache License 2.0 5 votes vote down vote up
@Override
public void notifyOfRemovedMetric(Metric metric, String metricName, MetricGroup group) {
	if (metric instanceof Counter) {
		counters.remove(metric);
	} else if (metric instanceof Gauge) {
		gauges.remove(metric);
	} else if (metric instanceof Meter) {
		meters.remove(metric);
	} else if (metric instanceof Histogram) {
		// No Histogram is registered
	} else {
		LOGGER.warn("Cannot remove unknown metric type {}. This indicates that the reporter " +
			"does not support this metric type.", metric.getClass().getName());
	}
}
 
Example #24
Source File: InterceptingTaskMetricGroup.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
@Override
protected void addMetric(String name, Metric metric) {
	if (intercepted == null) {
		intercepted = new HashMap<>();
	}
	intercepted.put(name, metric);
	super.addMetric(name, metric);
}
 
Example #25
Source File: AbstractPrometheusReporter.java    From flink with Apache License 2.0 5 votes vote down vote up
private void removeMetric(Metric metric, List<String> dimensionValues, Collector collector) {
	if (metric instanceof Gauge) {
		((io.prometheus.client.Gauge) collector).remove(toArray(dimensionValues));
	} else if (metric instanceof Counter) {
		((io.prometheus.client.Gauge) collector).remove(toArray(dimensionValues));
	} else if (metric instanceof Meter) {
		((io.prometheus.client.Gauge) collector).remove(toArray(dimensionValues));
	} else if (metric instanceof Histogram) {
		((HistogramSummaryProxy) collector).remove(dimensionValues);
	} else {
		log.warn("Cannot remove unknown metric type: {}. This indicates that the metric type is not supported by this reporter.",
			metric.getClass().getName());
	}
}
 
Example #26
Source File: AbstractPrometheusReporter.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
@Override
public void notifyOfAddedMetric(final Metric metric, final String metricName, final MetricGroup group) {

	List<String> dimensionKeys = new LinkedList<>();
	List<String> dimensionValues = new LinkedList<>();
	for (final Map.Entry<String, String> dimension : group.getAllVariables().entrySet()) {
		final String key = dimension.getKey();
		dimensionKeys.add(CHARACTER_FILTER.filterCharacters(key.substring(1, key.length() - 1)));
		dimensionValues.add(labelValueCharactersFilter.filterCharacters(dimension.getValue()));
	}

	final String scopedMetricName = getScopedName(metricName, group);
	final String helpString = metricName + " (scope: " + getLogicalScope(group) + ")";

	final Collector collector;
	Integer count = 0;

	synchronized (this) {
		if (collectorsWithCountByMetricName.containsKey(scopedMetricName)) {
			final AbstractMap.SimpleImmutableEntry<Collector, Integer> collectorWithCount = collectorsWithCountByMetricName.get(scopedMetricName);
			collector = collectorWithCount.getKey();
			count = collectorWithCount.getValue();
		} else {
			collector = createCollector(metric, dimensionKeys, dimensionValues, scopedMetricName, helpString);
			try {
				collector.register();
			} catch (Exception e) {
				log.warn("There was a problem registering metric {}.", metricName, e);
			}
		}
		addMetric(metric, dimensionValues, collector);
		collectorsWithCountByMetricName.put(scopedMetricName, new AbstractMap.SimpleImmutableEntry<>(collector, count + 1));
	}
}
 
Example #27
Source File: MetricRegistryImplTest.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
@Override
public void notifyOfAddedMetric(Metric metric, String metricName, MetricGroup group) {
	String expectedMetric = "A" + expectedDelimiter + "B" + expectedDelimiter + "C";
	assertEquals(expectedMetric, group.getMetricIdentifier(metricName, this));
	assertEquals(expectedMetric, group.getMetricIdentifier(metricName));
	numCorrectDelimitersForRegister++;
}
 
Example #28
Source File: AbstractPrometheusReporter.java    From flink with Apache License 2.0 5 votes vote down vote up
@Override
public void notifyOfRemovedMetric(final Metric metric, final String metricName, final MetricGroup group) {

	List<String> dimensionValues = new LinkedList<>();
	for (final Map.Entry<String, String> dimension : group.getAllVariables().entrySet()) {
		dimensionValues.add(labelValueCharactersFilter.filterCharacters(dimension.getValue()));
	}

	final String scopedMetricName = getScopedName(metricName, group);
	synchronized (this) {
		final AbstractMap.SimpleImmutableEntry<Collector, Integer> collectorWithCount = collectorsWithCountByMetricName.get(scopedMetricName);
		final Integer count = collectorWithCount.getValue();
		final Collector collector = collectorWithCount.getKey();

		removeMetric(metric, dimensionValues, collector);

		if (count == 1) {
			try {
				CollectorRegistry.defaultRegistry.unregister(collector);
			} catch (Exception e) {
				log.warn("There was a problem unregistering metric {}.", scopedMetricName, e);
			}
			collectorsWithCountByMetricName.remove(scopedMetricName);
		} else {
			collectorsWithCountByMetricName.put(scopedMetricName, new AbstractMap.SimpleImmutableEntry<>(collector, count - 1));
		}
	}
}
 
Example #29
Source File: ScheduledDropwizardReporter.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
@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());
		}
	}
}
 
Example #30
Source File: DatadogHttpReporter.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
@Override
public void notifyOfRemovedMetric(Metric metric, String metricName, MetricGroup group) {
	if (metric instanceof Counter) {
		counters.remove(metric);
	} else if (metric instanceof Gauge) {
		gauges.remove(metric);
	} else if (metric instanceof Meter) {
		meters.remove(metric);
	} else if (metric instanceof Histogram) {
		// No Histogram is registered
	} else {
		LOGGER.warn("Cannot remove unknown metric type {}. This indicates that the reporter " +
			"does not support this metric type.", metric.getClass().getName());
	}
}