@Override public String toString() { return new StringJoiner(", ", this.getClass().getSimpleName() + "{", "}") .add("info=" + metricsInfo.toString()) .add("tags=" + tags()) .add("metrics=" + metrics()) .toString(); }
/** * Sample all the mutable metrics and put the snapshot in the builder * @param builder to contain the metrics snapshot * @param all get all the metrics even if the values are not changed. */ public synchronized void snapshot(MetricsRecordBuilder builder, boolean all) { for (MetricsTag tag : tags()) { builder.add(tag); } for (MutableMetric metric : metrics()) { metric.snapshot(builder, all); } }
@Override public String toString() { return Objects.toStringHelper(this) .add("info", metricsInfo).add("tags", tags()).add("metrics", metrics()) .toString(); } }
@Override public String toString() { return Objects.toStringHelper(this) .add("info", metricsInfo).add("tags", tags()).add("metrics", metrics()) .toString(); } }
@Override public String toString() { return Objects.toStringHelper(this) .add("info", metricsInfo).add("tags", tags()).add("metrics", metrics()) .toString(); } }
/** * Sample all the mutable metrics and put the snapshot in the builder * @param builder to contain the metrics snapshot * @param all get all the metrics even if the values are not changed. */ public synchronized void snapshot(MetricsRecordBuilder builder, boolean all) { for (MetricsTag tag : tags()) { builder.add(tag); } for (MutableMetric metric : metrics()) { metric.snapshot(builder, all); } }
/** * Sample all the mutable metrics and put the snapshot in the builder * @param builder to contain the metrics snapshot * @param all get all the metrics even if the values are not changed. */ public synchronized void snapshot(MetricsRecordBuilder builder, boolean all) { for (MetricsTag tag : tags()) { builder.add(tag); } for (MutableMetric metric : metrics()) { metric.snapshot(builder, all); } }
/** * Sample all the mutable metrics and put the snapshot in the builder * @param builder to contain the metrics snapshot * @param all get all the metrics even if the values are not changed. */ public synchronized void snapshot(MetricsRecordBuilder builder, boolean all) { for (MetricsTag tag : tags()) { builder.add(tag); } for (MutableMetric metric : metrics()) { metric.snapshot(builder, all); } }
/** * Sample all the mutable metrics and put the snapshot in the builder * @param builder to contain the metrics snapshot * @param all get all the metrics even if the values are not changed. */ public synchronized void snapshot(MetricsRecordBuilder builder, boolean all) { for (MetricsTag tag : tags()) { builder.add(tag); } for (MutableMetric metric : metrics()) { metric.snapshot(builder, all); } }
@Override public String toString() { return Objects.toStringHelper(this) .add("info", metricsInfo).add("tags", tags()).add("metrics", metrics()) .toString(); } }
}); assertEquals("num metrics in registry", 3, r.metrics().size());
}); assertEquals("num metrics in registry", 3, r.metrics().size());
/** * Test various factory methods */ @Test public void testNewMetrics() { final MetricsRegistry r = new MetricsRegistry("test"); r.newCounter("c1", "c1 desc", 1); r.newCounter("c2", "c2 desc", 2L); r.newGauge("g1", "g1 desc", 3); r.newGauge("g2", "g2 desc", 4L); r.newStat("s1", "s1 desc", "ops", "time"); assertEquals("num metrics in registry", 5, r.metrics().size()); assertTrue("c1 found", r.get("c1") instanceof MutableCounterInt); assertTrue("c2 found", r.get("c2") instanceof MutableCounterLong); assertTrue("g1 found", r.get("g1") instanceof MutableGaugeInt); assertTrue("g2 found", r.get("g2") instanceof MutableGaugeLong); assertTrue("s1 found", r.get("s1") instanceof MutableStat); expectMetricsException("Metric name c1 already exists", new Runnable() { @Override public void run() { r.newCounter("c1", "test dup", 0); } }); }
/** * Test various factory methods */ @Test public void testNewMetrics() { final MetricsRegistry r = new MetricsRegistry("test"); r.newCounter("c1", "c1 desc", 1); r.newCounter("c2", "c2 desc", 2L); r.newGauge("g1", "g1 desc", 3); r.newGauge("g2", "g2 desc", 4L); r.newStat("s1", "s1 desc", "ops", "time"); assertEquals("num metrics in registry", 5, r.metrics().size()); assertTrue("c1 found", r.get("c1") instanceof MutableCounterInt); assertTrue("c2 found", r.get("c2") instanceof MutableCounterLong); assertTrue("g1 found", r.get("g1") instanceof MutableGaugeInt); assertTrue("g2 found", r.get("g2") instanceof MutableGaugeLong); assertTrue("s1 found", r.get("s1") instanceof MutableStat); expectMetricsException("Metric name c1 already exists", new Runnable() { @Override public void run() { r.newCounter("c1", "test dup", 0); } }); }