use of org.apache.flink.runtime.metrics.MetricRegistryImpl in project flink by apache.
the class MetricGroupRegistrationTest method testMetricInstantiation.
/**
* Verifies that group methods instantiate the correct metric with the given name.
*/
@Test
public void testMetricInstantiation() throws Exception {
MetricRegistryImpl registry = new MetricRegistryImpl(MetricRegistryTestUtils.defaultMetricRegistryConfiguration(), Collections.singletonList(ReporterSetup.forReporter("test", new TestReporter1())));
MetricGroup root = TaskManagerMetricGroup.createTaskManagerMetricGroup(registry, "host", new ResourceID("id"));
Counter counter = root.counter("counter");
assertEquals(counter, TestReporter1.lastPassedMetric);
assertEquals("counter", TestReporter1.lastPassedName);
Gauge<Object> gauge = root.gauge("gauge", new Gauge<Object>() {
@Override
public Object getValue() {
return null;
}
});
Assert.assertEquals(gauge, TestReporter1.lastPassedMetric);
assertEquals("gauge", TestReporter1.lastPassedName);
Histogram histogram = root.histogram("histogram", new Histogram() {
@Override
public void update(long value) {
}
@Override
public long getCount() {
return 0;
}
@Override
public HistogramStatistics getStatistics() {
return null;
}
});
Assert.assertEquals(histogram, TestReporter1.lastPassedMetric);
assertEquals("histogram", TestReporter1.lastPassedName);
registry.shutdown().get();
}
use of org.apache.flink.runtime.metrics.MetricRegistryImpl in project flink by apache.
the class MetricGroupTest method testCreateQueryServiceMetricInfo.
@Test
public void testCreateQueryServiceMetricInfo() {
JobID jid = new JobID();
JobVertexID vid = new JobVertexID();
ExecutionAttemptID eid = new ExecutionAttemptID();
MetricRegistryImpl registry = new MetricRegistryImpl(defaultMetricRegistryConfiguration);
TaskManagerMetricGroup tm = TaskManagerMetricGroup.createTaskManagerMetricGroup(registry, "host", new ResourceID("id"));
TaskMetricGroup task = tm.addJob(jid, "jobname").addTask(vid, eid, "taskName", 4, 5);
GenericMetricGroup userGroup1 = new GenericMetricGroup(registry, task, "hello");
GenericMetricGroup userGroup2 = new GenericMetricGroup(registry, userGroup1, "world");
QueryScopeInfo.TaskQueryScopeInfo info1 = (QueryScopeInfo.TaskQueryScopeInfo) userGroup1.createQueryServiceMetricInfo(new DummyCharacterFilter());
assertEquals("hello", info1.scope);
assertEquals(jid.toString(), info1.jobID);
assertEquals(vid.toString(), info1.vertexID);
assertEquals(4, info1.subtaskIndex);
QueryScopeInfo.TaskQueryScopeInfo info2 = (QueryScopeInfo.TaskQueryScopeInfo) userGroup2.createQueryServiceMetricInfo(new DummyCharacterFilter());
assertEquals("hello.world", info2.scope);
assertEquals(jid.toString(), info2.jobID);
assertEquals(vid.toString(), info2.vertexID);
assertEquals(4, info2.subtaskIndex);
}
use of org.apache.flink.runtime.metrics.MetricRegistryImpl in project flink by apache.
the class TaskManagerGroupTest method testGenerateScopeCustom.
@Test
public void testGenerateScopeCustom() throws Exception {
Configuration cfg = new Configuration();
cfg.setString(MetricOptions.SCOPE_NAMING_TM, "constant.<host>.foo.<host>");
MetricRegistryImpl registry = new MetricRegistryImpl(MetricRegistryTestUtils.fromConfiguration(cfg));
TaskManagerMetricGroup group = TaskManagerMetricGroup.createTaskManagerMetricGroup(registry, "host", new ResourceID("id"));
assertArrayEquals(new String[] { "constant", "host", "foo", "host" }, group.getScopeComponents());
assertEquals("constant.host.foo.host.name", group.getMetricIdentifier("name"));
registry.shutdown().get();
}
Aggregations