@Override protected void reportInContext( MetricContext context, SortedMap<String, Gauge> gauges, SortedMap<String, Counter> counters, SortedMap<String, Histogram> histograms, SortedMap<String, Meter> meters, SortedMap<String, Timer> timers) { Assert.assertEquals(context.getName(), CONTEXT_NAME); Assert.assertEquals(gauges.size(), 1); Assert.assertTrue(gauges.containsKey(QUEUE_SIZE)); Assert.assertEquals(counters.size(), 1); Assert.assertTrue(counters.containsKey(RECORDS_PROCESSED)); Assert.assertEquals(histograms.size(), 1); Assert.assertTrue(histograms.containsKey(RECORD_SIZE_DISTRIBUTION)); Assert.assertEquals(meters.size(), 1); Assert.assertTrue(meters.containsKey(RECORD_PROCESS_RATE)); Assert.assertEquals(timers.size(), 2); Assert.assertTrue(timers.containsKey(TOTAL_DURATION)); }
@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}")); }