@BeforeClass public void setUp() { this.context = MetricContext.builder(CONTEXT_NAME) .addTag(new Tag<String>(JOB_ID_KEY, JOB_ID_PREFIX + 0)) .addContextAwareScheduledReporter( new TestContextAwareScheduledReporter.TestContextAwareScheduledReporterBuilder( TEST_REPORTER_NAME)) .reportFullyQualifiedNames(false) .build(); Assert.assertEquals(this.context.getName(), CONTEXT_NAME); Assert.assertFalse(this.context.getParent().isPresent()); Assert.assertEquals(this.context.getTags().size(), 2); // uuid tag gets added automatically Assert.assertEquals(this.context.getTags().get(0).getKey(), JOB_ID_KEY); Assert.assertEquals(this.context.getTags().get(0).getValue(), JOB_ID_PREFIX + 0); // Second tag should be uuid Assert.assertTrue( this.context .getTags() .get(1) .getValue() .toString() .matches("[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}")); Assert.assertEquals( this.context.metricNamePrefix(false), this.context.getTags().get(0).getValue() + "." + this.context.getTags().get(1).getValue()); }
@BeforeClass public void setUp() { String contextName = CONTEXT_NAME + "_" + UUID.randomUUID().toString(); this.context = MetricContext.builder(contextName) .addTag(new Tag<String>(JOB_ID_KEY, JOB_ID_PREFIX + 0)) .build(); Assert.assertEquals(this.context.getName(), contextName); Assert.assertTrue(this.context.getParent().isPresent()); Assert.assertEquals(this.context.getParent().get(), RootMetricContext.get()); Assert.assertEquals( this.context.getTags().size(), 3); // uuid and name tag gets added automatically Assert.assertEquals(this.context.getTags().get(0).getKey(), JOB_ID_KEY); Assert.assertEquals(this.context.getTags().get(0).getValue(), JOB_ID_PREFIX + 0); // Second tag should be uuid Assert.assertTrue( this.context .getTags() .get(1) .getValue() .toString() .matches("[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}")); }