OutputStreamReporter.Factory.newBuilder().outputTo(output).build(properties);
@Test public void testTags() throws IOException { MetricContext metricContext = MetricContext.builder(this.getClass().getCanonicalName()).build(); Counter counter = metricContext.counter("com.linkedin.example.counter"); Map<String, String> tags = new HashMap<>(); tags.put("testKey", "testValue"); tags.put("key2", "value2"); OutputStreamReporter reporter = OutputStreamReporter.Factory.newBuilder().withTags(tags).outputTo(this.stream).build(new Properties()); counter.inc(); reporter.report(); Assert.assertTrue(this.stream.toString().contains("key2=value2")); Assert.assertTrue(this.stream.toString().contains("testKey=testValue")); String[] lines = this.stream.toString().split("\n"); Map<String, Set<String>> expected = new HashMap<>(); expectMetrics(expected, lines); Set<String> counterSubMetrics = new HashSet<>(); counterSubMetrics.add("count"); expected.put("com.linkedin.example.counter", counterSubMetrics); reporter.close(); }
OutputStreamReporter.Factory.newBuilder().outputTo(this.stream).build(new Properties());
OutputStreamReporter.Factory.newBuilder().outputTo(output).build(properties);
@Override public ScheduledReporter newScheduledReporter(Properties properties) throws IOException { return OutputStreamReporter.Factory.newBuilder().build(properties); } }
if (verbose) { OutputStreamReporter.Factory.newBuilder().build(new Properties());
OutputStreamReporter.Factory.newBuilder().build(new Properties());
@Test public void testTagsFromContext() throws IOException { Tag<?> tag1 = new Tag<>("tag1", "value1"); MetricContext context = MetricContext.builder("context").addTag(tag1).build(); Counter counter = context.counter("com.linkedin.example.counter"); OutputStreamReporter reporter = OutputStreamReporter.Factory.newBuilder().outputTo(this.stream).build(new Properties()); counter.inc(); reporter.report(); Assert.assertTrue(this.stream.toString().contains("tag1=value1")); String[] lines = this.stream.toString().split("\n"); Map<String, Set<String>> expected = new HashMap<>(); expectMetrics(expected, lines); Set<String> counterSubMetrics = new HashSet<>(); counterSubMetrics.add("count"); expected.put("com.linkedin.example.counter", counterSubMetrics); reporter.close(); }
@Override public ScheduledReporter newScheduledReporter(Properties properties) throws IOException { return OutputStreamReporter.Factory.newBuilder().build(properties); } }