org.apache.flink.runtime.metrics.groups.AbstractMetricGroup Java Examples

The following examples show how to use org.apache.flink.runtime.metrics.groups.AbstractMetricGroup. 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: LatencyStatsTest.java    From flink with Apache License 2.0 6 votes vote down vote up
private static void testLatencyStats(
	final LatencyStats.Granularity granularity,
	final Consumer<List<Tuple2<String, Histogram>>> verifier) {

	final AbstractMetricGroup<?> dummyGroup = UnregisteredMetricGroups.createUnregisteredOperatorMetricGroup();
	final TestMetricRegistry registry = new TestMetricRegistry();
	final MetricGroup parentGroup = new GenericMetricGroup(registry, dummyGroup, PARENT_GROUP_NAME);

	final LatencyStats latencyStats = new LatencyStats(
		parentGroup,
		MetricOptions.LATENCY_HISTORY_SIZE.defaultValue(),
		OPERATOR_SUBTASK_INDEX,
		OPERATOR_ID,
		granularity);

	latencyStats.reportLatency(new LatencyMarker(0L, SOURCE_ID_1, 0));
	latencyStats.reportLatency(new LatencyMarker(0L, SOURCE_ID_1, 0));
	latencyStats.reportLatency(new LatencyMarker(0L, SOURCE_ID_1, 1));
	latencyStats.reportLatency(new LatencyMarker(0L, SOURCE_ID_2, 2));
	latencyStats.reportLatency(new LatencyMarker(0L, SOURCE_ID_2, 3));

	verifier.accept(registry.latencyHistograms);
}
 
Example #2
Source File: LatencyStatsTest.java    From flink with Apache License 2.0 6 votes vote down vote up
private static void testLatencyStats(
	final LatencyStats.Granularity granularity,
	final Consumer<List<Tuple2<String, Histogram>>> verifier) {

	final AbstractMetricGroup<?> dummyGroup = UnregisteredMetricGroups.createUnregisteredOperatorMetricGroup();
	final TestMetricRegistry registry = new TestMetricRegistry();
	final MetricGroup parentGroup = new GenericMetricGroup(registry, dummyGroup, PARENT_GROUP_NAME);

	final LatencyStats latencyStats = new LatencyStats(
		parentGroup,
		MetricOptions.LATENCY_HISTORY_SIZE.defaultValue(),
		OPERATOR_SUBTASK_INDEX,
		OPERATOR_ID,
		granularity);

	latencyStats.reportLatency(new LatencyMarker(0L, SOURCE_ID_1, 0));
	latencyStats.reportLatency(new LatencyMarker(0L, SOURCE_ID_1, 0));
	latencyStats.reportLatency(new LatencyMarker(0L, SOURCE_ID_1, 1));
	latencyStats.reportLatency(new LatencyMarker(0L, SOURCE_ID_2, 2));
	latencyStats.reportLatency(new LatencyMarker(0L, SOURCE_ID_2, 3));

	verifier.accept(registry.latencyHistograms);
}
 
Example #3
Source File: LatencyStatsTest.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
private static void testLatencyStats(
	final LatencyStats.Granularity granularity,
	final Consumer<List<Tuple2<String, Histogram>>> verifier) {

	final AbstractMetricGroup<?> dummyGroup = UnregisteredMetricGroups.createUnregisteredOperatorMetricGroup();
	final TestMetricRegistry registry = new TestMetricRegistry();
	final MetricGroup parentGroup = new GenericMetricGroup(registry, dummyGroup, PARENT_GROUP_NAME);

	final LatencyStats latencyStats = new LatencyStats(
		parentGroup,
		MetricOptions.LATENCY_HISTORY_SIZE.defaultValue(),
		OPERATOR_SUBTASK_INDEX,
		OPERATOR_ID,
		granularity);

	latencyStats.reportLatency(new LatencyMarker(0L, SOURCE_ID_1, 0));
	latencyStats.reportLatency(new LatencyMarker(0L, SOURCE_ID_1, 0));
	latencyStats.reportLatency(new LatencyMarker(0L, SOURCE_ID_1, 1));
	latencyStats.reportLatency(new LatencyMarker(0L, SOURCE_ID_2, 2));
	latencyStats.reportLatency(new LatencyMarker(0L, SOURCE_ID_2, 3));

	verifier.accept(registry.latencyHistograms);
}
 
Example #4
Source File: MetricQueryService.java    From flink with Apache License 2.0 5 votes vote down vote up
public void addMetric(String metricName, Metric metric, AbstractMetricGroup group) {
	runAsync(() -> {
		QueryScopeInfo info = group.getQueryServiceMetricInfo(FILTER);

		if (metric instanceof Counter) {
			counters.put((Counter) metric, new Tuple2<>(info, FILTER.filterCharacters(metricName)));
		} else if (metric instanceof Gauge) {
			gauges.put((Gauge<?>) metric, new Tuple2<>(info, FILTER.filterCharacters(metricName)));
		} else if (metric instanceof Histogram) {
			histograms.put((Histogram) metric, new Tuple2<>(info, FILTER.filterCharacters(metricName)));
		} else if (metric instanceof Meter) {
			meters.put((Meter) metric, new Tuple2<>(info, FILTER.filterCharacters(metricName)));
		}
	});
}
 
Example #5
Source File: MetricQueryService.java    From flink with Apache License 2.0 5 votes vote down vote up
public void addMetric(String metricName, Metric metric, AbstractMetricGroup group) {
	runAsync(() -> {
		QueryScopeInfo info = group.getQueryServiceMetricInfo(FILTER);

		if (metric instanceof Counter) {
			counters.put((Counter) metric, new Tuple2<>(info, FILTER.filterCharacters(metricName)));
		} else if (metric instanceof Gauge) {
			gauges.put((Gauge<?>) metric, new Tuple2<>(info, FILTER.filterCharacters(metricName)));
		} else if (metric instanceof Histogram) {
			histograms.put((Histogram) metric, new Tuple2<>(info, FILTER.filterCharacters(metricName)));
		} else if (metric instanceof Meter) {
			meters.put((Meter) metric, new Tuple2<>(info, FILTER.filterCharacters(metricName)));
		}
	});
}
 
Example #6
Source File: NoOpMetricRegistry.java    From flink with Apache License 2.0 4 votes vote down vote up
@Override
public void register(Metric metric, String metricName, AbstractMetricGroup group) {
}
 
Example #7
Source File: NoOpMetricRegistry.java    From flink with Apache License 2.0 4 votes vote down vote up
@Override
public void unregister(Metric metric, String metricName, AbstractMetricGroup group) {
}
 
Example #8
Source File: LatencyStatsTest.java    From flink with Apache License 2.0 4 votes vote down vote up
@Override
public void register(Metric metric, String metricName, AbstractMetricGroup group) {
	if (metric instanceof Histogram) {
		latencyHistograms.add(Tuple2.of(group.getMetricIdentifier(metricName), (Histogram) metric));
	}
}
 
Example #9
Source File: JMXReporter.java    From flink with Apache License 2.0 4 votes vote down vote up
static String generateJmxDomain(String metricName, MetricGroup group) {
	return JMX_DOMAIN_PREFIX + ((FrontMetricGroup<AbstractMetricGroup<?>>) group).getLogicalScope(CHARACTER_FILTER, '.') + '.' + metricName;
}
 
Example #10
Source File: AbstractPrometheusReporter.java    From flink with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings("unchecked")
private static String getLogicalScope(MetricGroup group) {
	return ((FrontMetricGroup<AbstractMetricGroup<?>>) group).getLogicalScope(CHARACTER_FILTER, SCOPE_SEPARATOR);
}
 
Example #11
Source File: MeasurementInfoProvider.java    From flink with Apache License 2.0 4 votes vote down vote up
private static String getLogicalScope(MetricGroup group) {
	return ((FrontMetricGroup<AbstractMetricGroup<?>>) group).getLogicalScope(CHARACTER_FILTER, SCOPE_SEPARATOR);
}
 
Example #12
Source File: RocksDBNativeMetricMonitorTest.java    From flink with Apache License 2.0 4 votes vote down vote up
@Override
public void register(Metric metric, String metricName, AbstractMetricGroup group) {
	if (metric instanceof RocksDBNativeMetricMonitor.RocksDBNativeMetricView) {
		metrics.add((RocksDBNativeMetricMonitor.RocksDBNativeMetricView) metric);
	}
}
 
Example #13
Source File: MeasurementInfoProvider.java    From flink with Apache License 2.0 4 votes vote down vote up
private static String getLogicalScope(MetricGroup group) {
	return ((FrontMetricGroup<AbstractMetricGroup<?>>) group).getLogicalScope(CHARACTER_FILTER, SCOPE_SEPARATOR);
}
 
Example #14
Source File: NoOpMetricRegistry.java    From flink with Apache License 2.0 4 votes vote down vote up
@Override
public void unregister(Metric metric, String metricName, AbstractMetricGroup group) {
}
 
Example #15
Source File: MetricUtils.java    From flink with Apache License 2.0 4 votes vote down vote up
private static MetricGroup createAndInitializeStatusMetricGroup(AbstractMetricGroup<?> parentMetricGroup) {
	MetricGroup statusGroup = parentMetricGroup.addGroup(METRIC_GROUP_STATUS_NAME);

	instantiateStatusMetrics(statusGroup);
	return statusGroup;
}
 
Example #16
Source File: StreamTaskTestHarness.java    From flink with Apache License 2.0 4 votes vote down vote up
@Override
public void register(Metric metric, String metricName, AbstractMetricGroup group) {
	metrics.put(metricName, metric);
}
 
Example #17
Source File: LatencyStatsTest.java    From flink with Apache License 2.0 4 votes vote down vote up
@Override
public void register(Metric metric, String metricName, AbstractMetricGroup group) {
	if (metric instanceof Histogram) {
		latencyHistograms.add(Tuple2.of(group.getMetricIdentifier(metricName), (Histogram) metric));
	}
}
 
Example #18
Source File: JMXReporter.java    From flink with Apache License 2.0 4 votes vote down vote up
static String generateJmxDomain(String metricName, MetricGroup group) {
	return JMX_DOMAIN_PREFIX + ((FrontMetricGroup<AbstractMetricGroup<?>>) group).getLogicalScope(CHARACTER_FILTER, '.') + '.' + metricName;
}
 
Example #19
Source File: AbstractPrometheusReporter.java    From flink with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings("unchecked")
private static String getLogicalScope(MetricGroup group) {
	return ((FrontMetricGroup<AbstractMetricGroup<?>>) group).getLogicalScope(CHARACTER_FILTER, SCOPE_SEPARATOR);
}
 
Example #20
Source File: RocksDBNativeMetricMonitorTest.java    From Flink-CEPplus with Apache License 2.0 4 votes vote down vote up
@Override
public void register(Metric metric, String metricName, AbstractMetricGroup group) {
	if (metric instanceof RocksDBNativeMetricMonitor.RocksDBNativeMetricView) {
		metrics.add((RocksDBNativeMetricMonitor.RocksDBNativeMetricView) metric);
	}
}
 
Example #21
Source File: NoOpMetricRegistry.java    From flink with Apache License 2.0 4 votes vote down vote up
@Override
public void register(Metric metric, String metricName, AbstractMetricGroup group) {
}
 
Example #22
Source File: RocksDBNativeMetricMonitorTest.java    From flink with Apache License 2.0 4 votes vote down vote up
@Override
public void register(Metric metric, String metricName, AbstractMetricGroup group) {
	if (metric instanceof RocksDBNativeMetricMonitor.RocksDBNativeMetricView) {
		metrics.add((RocksDBNativeMetricMonitor.RocksDBNativeMetricView) metric);
	}
}
 
Example #23
Source File: MeasurementInfoProvider.java    From Flink-CEPplus with Apache License 2.0 4 votes vote down vote up
private static String getLogicalScope(MetricGroup group) {
	return ((FrontMetricGroup<AbstractMetricGroup<?>>) group).getLogicalScope(CHARACTER_FILTER, SCOPE_SEPARATOR);
}
 
Example #24
Source File: AbstractPrometheusReporter.java    From Flink-CEPplus with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings("unchecked")
private static String getLogicalScope(MetricGroup group) {
	return ((FrontMetricGroup<AbstractMetricGroup<?>>) group).getLogicalScope(CHARACTER_FILTER, SCOPE_SEPARATOR);
}
 
Example #25
Source File: MetricQueryService.java    From Flink-CEPplus with Apache License 2.0 4 votes vote down vote up
private AddMetric(String metricName, Metric metric, AbstractMetricGroup group) {
	this.metricName = metricName;
	this.metric = metric;
	this.group = group;
}
 
Example #26
Source File: NoOpMetricRegistry.java    From Flink-CEPplus with Apache License 2.0 4 votes vote down vote up
@Override
public void register(Metric metric, String metricName, AbstractMetricGroup group) {
}
 
Example #27
Source File: JMXReporter.java    From Flink-CEPplus with Apache License 2.0 4 votes vote down vote up
static String generateJmxDomain(String metricName, MetricGroup group) {
	return JMX_DOMAIN_PREFIX + ((FrontMetricGroup<AbstractMetricGroup<?>>) group).getLogicalScope(CHARACTER_FILTER, '.') + '.' + metricName;
}
 
Example #28
Source File: NoOpMetricRegistry.java    From Flink-CEPplus with Apache License 2.0 4 votes vote down vote up
@Override
public void unregister(Metric metric, String metricName, AbstractMetricGroup group) {
}
 
Example #29
Source File: LatencyStatsTest.java    From Flink-CEPplus with Apache License 2.0 4 votes vote down vote up
@Override
public void register(Metric metric, String metricName, AbstractMetricGroup group) {
	if (metric instanceof Histogram) {
		latencyHistograms.add(Tuple2.of(group.getMetricIdentifier(metricName), (Histogram) metric));
	}
}
 
Example #30
Source File: RocksDBNativeMetricMonitorTest.java    From Flink-CEPplus with Apache License 2.0 2 votes vote down vote up
@Override
public void unregister(Metric metric, String metricName, AbstractMetricGroup group) {

}