/** * Adds another measurement datapoint. */ public void addMeasurement(Measurement measurement) { dataPoints.add(new TaggedDataPoints(measurement)); }
/** * Adds another measurement datapoint. */ public void addMeasurement(Measurement measurement) { dataPoints.add(new TaggedDataPoints(measurement)); }
/** * Constructor from a single measurement datapoint. */ public MetricValues(String kind, Measurement measurement) { this.kind = kind; dataPoints = new ArrayList<>(); dataPoints.add(new TaggedDataPoints(measurement)); }
/** * Constructor from a single measurement datapoint. */ public MetricValues(String kind, Measurement measurement) { this.kind = kind; dataPoints = new ArrayList<>(); dataPoints.add(new TaggedDataPoints(measurement)); }
@Test public void testEncodeSimpleRegistry() { DefaultRegistry registry = new DefaultRegistry(clock); Counter counterA = registry.counter(idAXY); Counter counterB = registry.counter(idBXY); counterA.increment(4); counterB.increment(10); List<TaggedDataPoints> expectedTaggedDataPointsA = Arrays.asList( new TaggedDataPoints( Arrays.asList(new BasicTag("tagA", "X"), new BasicTag("tagB", "Y")), Arrays.asList(new DataPoint(clock.wallTime(), 4)))); List<TaggedDataPoints> expectedTaggedDataPointsB = Arrays.asList( new TaggedDataPoints( Arrays.asList(new BasicTag("tagA", "X"), new BasicTag("tagB", "Y")), Arrays.asList(new DataPoint(clock.wallTime(), 10)))); HashMap<String, MetricValues> expect = new HashMap<String, MetricValues>(); expect.put("idA", new MetricValues("Counter", expectedTaggedDataPointsA)); expect.put("idB", new MetricValues("Counter", expectedTaggedDataPointsB)); Assertions.assertEquals(expect, controller.encodeRegistry(registry, allowAll)); }
@Test public void testEncodeCombinedRegistry() { // Multiple occurrences of measurements in the same registry // (confirm these are handled within the registry itself). Measurement measureBXY2 = new Measurement(idBXY, 5, 5.5); Meter meterB2 = new TestMeter("ignoreB", measureBXY2); DefaultRegistry registry = new DefaultRegistry(clock); registry.register(meterB); registry.register(meterB2); List<TaggedDataPoints> expectedTaggedDataPoints = Arrays.asList( new TaggedDataPoints( Arrays.asList(new BasicTag("tagA", "X"), new BasicTag("tagB", "Y")), Arrays.asList(new DataPoint(clock.wallTime(), 50.5 + 5.5)))); HashMap<String, MetricValues> expect = new HashMap<>(); expect.put("idB", new MetricValues("Counter", expectedTaggedDataPoints)); PolledMeter.update(registry); Assertions.assertEquals(expect, controller.encodeRegistry(registry, allowAll)); }
new TaggedDataPoints(Arrays.asList(new BasicTag("tagA", "Y"), new BasicTag("tagB", "X")), Arrays.asList(new DataPoint(clock.wallTime(), 12.12))), new TaggedDataPoints(Arrays.asList(new BasicTag("tagA", "X"), new BasicTag("tagB", "Y")), new TaggedDataPoints(Arrays.asList(new BasicTag("tagA", "X"), new BasicTag("tagZ", "Z")), Arrays.asList(new DataPoint(clock.wallTime(), 13.13))));