MetricDump { public abstract byte getCategory(); private  MetricDump(QueryScopeInfo scopeInfo, String name); abstract byte getCategory(); static final byte METRIC_CATEGORY_COUNTER; static final byte METRIC_CATEGORY_GAUGE; static final byte METRIC_CATEGORY_HISTOGRAM; static final byte METRIC_CATEGORY_METER; final QueryScopeInfo scopeInfo; final String name; }
@Test public void testDumpedCounter() { QueryScopeInfo info = new QueryScopeInfo.JobManagerQueryScopeInfo(); MetricDump.CounterDump cd = new MetricDump.CounterDump(info, "counter", 4); assertEquals("counter", cd.name); assertEquals(4, cd.count); assertEquals(info, cd.scopeInfo); assertEquals(METRIC_CATEGORY_COUNTER, cd.getCategory()); }
@Test public void testDumpedGauge() { QueryScopeInfo info = new QueryScopeInfo.JobManagerQueryScopeInfo(); MetricDump.GaugeDump gd = new MetricDump.GaugeDump(info, "gauge", "hello"); assertEquals("gauge", gd.name); assertEquals("hello", gd.value); assertEquals(info, gd.scopeInfo); assertEquals(METRIC_CATEGORY_GAUGE, gd.getCategory()); }
@Test public void testDumpedHistogram() { QueryScopeInfo info = new QueryScopeInfo.JobManagerQueryScopeInfo(); MetricDump.HistogramDump hd = new MetricDump.HistogramDump(info, "hist", 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11); assertEquals("hist", hd.name); assertEquals(1, hd.min); assertEquals(2, hd.max); assertEquals(3, hd.mean, 0.1); assertEquals(4, hd.median, 0.1); assertEquals(5, hd.stddev, 0.1); assertEquals(6, hd.p75, 0.1); assertEquals(7, hd.p90, 0.1); assertEquals(8, hd.p95, 0.1); assertEquals(9, hd.p98, 0.1); assertEquals(10, hd.p99, 0.1); assertEquals(11, hd.p999, 0.1); assertEquals(info, hd.scopeInfo); assertEquals(METRIC_CATEGORY_HISTOGRAM, hd.getCategory()); }
@Test public void testDumpedMeter() { QueryScopeInfo info = new QueryScopeInfo.JobManagerQueryScopeInfo(); MetricDump.MeterDump md = new MetricDump.MeterDump(info, "meter", 5.0); assertEquals("meter", md.name); assertEquals(5.0, md.rate, 0.1); assertEquals(info, md.scopeInfo); assertEquals(METRIC_CATEGORY_METER, md.getCategory()); }