Search in sources :

Example 11 with MetricRegistryImpl

use of org.apache.flink.runtime.metrics.MetricRegistryImpl in project flink by apache.

the class AbstractMetricGroupTest method testScopeGenerationWithoutReporters.

@Test
public void testScopeGenerationWithoutReporters() throws Exception {
    Configuration config = new Configuration();
    config.setString(MetricOptions.SCOPE_NAMING_TM, "A.B.C.D");
    MetricRegistryImpl testRegistry = new MetricRegistryImpl(MetricRegistryTestUtils.fromConfiguration(config));
    try {
        TaskManagerMetricGroup group = TaskManagerMetricGroup.createTaskManagerMetricGroup(testRegistry, "host", new ResourceID("id"));
        assertEquals("MetricReporters list should be empty", 0, testRegistry.getReporters().size());
        // default delimiter should be used
        assertEquals("A.B.X.D.1", group.getMetricIdentifier("1", FILTER_C));
        // no caching should occur
        assertEquals("A.X.C.D.1", group.getMetricIdentifier("1", FILTER_B));
        // invalid reporter indices do not throw errors
        assertEquals("A.X.C.D.1", group.getMetricIdentifier("1", FILTER_B, -1, '.'));
        assertEquals("A.X.C.D.1", group.getMetricIdentifier("1", FILTER_B, 2, '.'));
    } finally {
        testRegistry.shutdown().get();
    }
}
Also used : Configuration(org.apache.flink.configuration.Configuration) ResourceID(org.apache.flink.runtime.clusterframework.types.ResourceID) MetricRegistryImpl(org.apache.flink.runtime.metrics.MetricRegistryImpl) Test(org.junit.Test)

Example 12 with MetricRegistryImpl

use of org.apache.flink.runtime.metrics.MetricRegistryImpl in project flink by apache.

the class JobManagerJobGroupTest method testGenerateScopeDefault.

@Test
public void testGenerateScopeDefault() throws Exception {
    MetricRegistryImpl registry = new MetricRegistryImpl(MetricRegistryTestUtils.defaultMetricRegistryConfiguration());
    JobManagerJobMetricGroup jmGroup = JobManagerMetricGroup.createJobManagerMetricGroup(registry, "theHostName").addJob(new JobID(), "myJobName");
    assertArrayEquals(new String[] { "theHostName", "jobmanager", "myJobName" }, jmGroup.getScopeComponents());
    assertEquals("theHostName.jobmanager.myJobName.name", jmGroup.getMetricIdentifier("name"));
    registry.shutdown().get();
}
Also used : MetricRegistryImpl(org.apache.flink.runtime.metrics.MetricRegistryImpl) JobID(org.apache.flink.api.common.JobID) Test(org.junit.Test)

Example 13 with MetricRegistryImpl

use of org.apache.flink.runtime.metrics.MetricRegistryImpl in project flink by apache.

the class JobManagerJobGroupTest method testCreateQueryServiceMetricInfo.

@Test
public void testCreateQueryServiceMetricInfo() {
    JobID jid = new JobID();
    MetricRegistryImpl registry = new MetricRegistryImpl(MetricRegistryTestUtils.defaultMetricRegistryConfiguration());
    JobManagerJobMetricGroup jmj = JobManagerMetricGroup.createJobManagerMetricGroup(registry, "theHostName").addJob(jid, "myJobName");
    QueryScopeInfo.JobQueryScopeInfo info = jmj.createQueryServiceMetricInfo(new DummyCharacterFilter());
    assertEquals("", info.scope);
    assertEquals(jid.toString(), info.jobID);
}
Also used : QueryScopeInfo(org.apache.flink.runtime.metrics.dump.QueryScopeInfo) DummyCharacterFilter(org.apache.flink.runtime.metrics.util.DummyCharacterFilter) MetricRegistryImpl(org.apache.flink.runtime.metrics.MetricRegistryImpl) JobID(org.apache.flink.api.common.JobID) Test(org.junit.Test)

Example 14 with MetricRegistryImpl

use of org.apache.flink.runtime.metrics.MetricRegistryImpl in project flink by apache.

the class JobManagerJobGroupTest method testGenerateScopeCustom.

@Test
public void testGenerateScopeCustom() throws Exception {
    Configuration cfg = new Configuration();
    cfg.setString(MetricOptions.SCOPE_NAMING_JM, "abc");
    cfg.setString(MetricOptions.SCOPE_NAMING_JM_JOB, "some-constant.<job_name>");
    MetricRegistryImpl registry = new MetricRegistryImpl(MetricRegistryTestUtils.fromConfiguration(cfg));
    JobManagerJobMetricGroup jmGroup = JobManagerMetricGroup.createJobManagerMetricGroup(registry, "theHostName").addJob(new JobID(), "myJobName");
    assertArrayEquals(new String[] { "some-constant", "myJobName" }, jmGroup.getScopeComponents());
    assertEquals("some-constant.myJobName.name", jmGroup.getMetricIdentifier("name"));
    registry.shutdown().get();
}
Also used : Configuration(org.apache.flink.configuration.Configuration) MetricRegistryImpl(org.apache.flink.runtime.metrics.MetricRegistryImpl) JobID(org.apache.flink.api.common.JobID) Test(org.junit.Test)

Example 15 with MetricRegistryImpl

use of org.apache.flink.runtime.metrics.MetricRegistryImpl in project flink by apache.

the class JobManagerJobGroupTest method testGenerateScopeCustomWildcard.

@Test
public void testGenerateScopeCustomWildcard() throws Exception {
    Configuration cfg = new Configuration();
    cfg.setString(MetricOptions.SCOPE_NAMING_JM, "peter");
    cfg.setString(MetricOptions.SCOPE_NAMING_JM_JOB, "*.some-constant.<job_id>");
    MetricRegistryImpl registry = new MetricRegistryImpl(MetricRegistryTestUtils.fromConfiguration(cfg));
    JobID jid = new JobID();
    JobManagerJobMetricGroup jmGroup = JobManagerMetricGroup.createJobManagerMetricGroup(registry, "theHostName").addJob(jid, "myJobName");
    assertArrayEquals(new String[] { "peter", "some-constant", jid.toString() }, jmGroup.getScopeComponents());
    assertEquals("peter.some-constant." + jid + ".name", jmGroup.getMetricIdentifier("name"));
    registry.shutdown().get();
}
Also used : Configuration(org.apache.flink.configuration.Configuration) MetricRegistryImpl(org.apache.flink.runtime.metrics.MetricRegistryImpl) JobID(org.apache.flink.api.common.JobID) Test(org.junit.Test)

Aggregations

MetricRegistryImpl (org.apache.flink.runtime.metrics.MetricRegistryImpl)28 Test (org.junit.Test)24 ResourceID (org.apache.flink.runtime.clusterframework.types.ResourceID)17 Configuration (org.apache.flink.configuration.Configuration)15 JobID (org.apache.flink.api.common.JobID)13 MetricGroup (org.apache.flink.metrics.MetricGroup)6 ExecutionAttemptID (org.apache.flink.runtime.executiongraph.ExecutionAttemptID)5 JobVertexID (org.apache.flink.runtime.jobgraph.JobVertexID)5 QueryScopeInfo (org.apache.flink.runtime.metrics.dump.QueryScopeInfo)4 DummyCharacterFilter (org.apache.flink.runtime.metrics.util.DummyCharacterFilter)4 CharacterFilter (org.apache.flink.metrics.CharacterFilter)2 MetricRegistryConfiguration (org.apache.flink.runtime.metrics.MetricRegistryConfiguration)2 BeforeEach (org.junit.jupiter.api.BeforeEach)2 IOException (java.io.IOException)1 UndeclaredThrowableException (java.lang.reflect.UndeclaredThrowableException)1 InetAddress (java.net.InetAddress)1 Duration (java.time.Duration)1 ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1 Collection (java.util.Collection)1