@Test public void reportsCounters() throws Exception { final Counter counter = mock(Counter.class); valueFilterMap .addFilter(counter, "count", new ValueFilter.Builder("warn").withLower(50).build()) .addFilter(counter, "count", new ValueFilter.Builder("critical") .withLower(150).build()); when(counter.getCount()).thenReturn(100L); reporter.report(this.<Gauge>map(), this.<Counter>map("counter", counter), this.<Histogram>map(), this.<Meter>map(), this.<Timer>map()); final InOrder inOrder = inOrder(riemann, eventDSL, client); inOrder.verify(riemann).connect(); verifyInOrder(inOrder, "prefix|counter|count", 100L, "warn"); inOrder.verify(client).flush(); inOrder.verifyNoMoreInteractions(); }
@Override public void report(SortedMap<String, Gauge> gauges, SortedMap<String, Counter> counters, SortedMap<String, Histogram> histograms, SortedMap<String, Meter> meters, SortedMap<String, Timer> timers) { final long timestamp = clock.getTime() / 1000; log.debug("Reporting metrics: for {} at {}", timestamp, System.currentTimeMillis()); try { riemann.connect(); for (Map.Entry<String, Gauge> entry : gauges.entrySet()) { reportGauge(entry.getKey(), entry.getValue(), timestamp); } for (Map.Entry<String, Counter> entry : counters.entrySet()) { reportCounter(entry.getKey(), entry.getValue(), timestamp); } for (Map.Entry<String, Histogram> entry : histograms.entrySet()) { reportHistogram(entry.getKey(), entry.getValue(), timestamp); } for (Map.Entry<String, Meter> entry : meters.entrySet()) { reportMetered(entry.getKey(), entry.getValue(), timestamp); } for (Map.Entry<String, Timer> entry : timers.entrySet()) { reportTimer(entry.getKey(), entry.getValue(), timestamp); } log.trace("Flushing events to riemann"); riemann.client.flush(); log.debug("Completed at {}", System.currentTimeMillis()); } catch (IOException e) { log.warn("Unable to report to Riemann", riemann, e); } }
RiemannReporter extends ScheduledReporter { @Override public void report(SortedMap<String, Gauge> gauges, SortedMap<String, Counter> counters, SortedMap<String, Histogram> histograms, SortedMap<String, Meter> meters, SortedMap<String, Timer> timers) { final long timestamp = clock.getTime() / 1000; log.debug("Reporting metrics: for {} at {}", timestamp, System.currentTimeMillis()); try { riemann.connect(); for (Map.Entry<String, Gauge> entry : gauges.entrySet()) { reportGauge(entry.getKey(), entry.getValue(), timestamp); } for (Map.Entry<String, Counter> entry : counters.entrySet()) { reportCounter(entry.getKey(), entry.getValue(), timestamp); } for (Map.Entry<String, Histogram> entry : histograms.entrySet()) { reportHistogram(entry.getKey(), entry.getValue(), timestamp); } for (Map.Entry<String, Meter> entry : meters.entrySet()) { reportMetered(entry.getKey(), entry.getValue(), timestamp); } for (Map.Entry<String, Timer> entry : timers.entrySet()) { reportTimer(entry.getKey(), entry.getValue(), timestamp); } log.trace("Flushing events to riemann"); riemann.client.flush(); log.debug("Completed at {}", System.currentTimeMillis()); } catch (IOException e) { log.warn("Unable to report to Riemann", riemann, e); } } }
RiemannReporter extends ScheduledReporter { @Override public void report(SortedMap<String, Gauge> gauges, SortedMap<String, Counter> counters, SortedMap<String, Histogram> histograms, SortedMap<String, Meter> meters, SortedMap<String, Timer> timers) { final long timestamp = clock.getTime() / 1000; log.debug("Reporting metrics: for {} at {}", timestamp, System.currentTimeMillis()); try { riemann.connect(); for (Map.Entry<String, Gauge> entry : gauges.entrySet()) { reportGauge(entry.getKey(), entry.getValue(), timestamp); } for (Map.Entry<String, Counter> entry : counters.entrySet()) { reportCounter(entry.getKey(), entry.getValue(), timestamp); } for (Map.Entry<String, Histogram> entry : histograms.entrySet()) { reportHistogram(entry.getKey(), entry.getValue(), timestamp); } for (Map.Entry<String, Meter> entry : meters.entrySet()) { reportMetered(entry.getKey(), entry.getValue(), timestamp); } for (Map.Entry<String, Timer> entry : timers.entrySet()) { reportTimer(entry.getKey(), entry.getValue(), timestamp); } log.trace("Flushing events to riemann"); riemann.client.flush(); log.debug("Completed at {}", System.currentTimeMillis()); } catch (IOException e) { log.warn("Unable to report to Riemann", riemann, e); } } private  RiemannReporter(MetricRegistry registry,
                            Riemann riemann,
                            Clock clock,
                            TimeUnit rateUnit,
                            TimeUnit durationUnit,
                            Float ttl,
                            String prefix,
                            String separator,
                            String localHost,
                            List<String> tags,
                            MetricFilter filter,
                            ValueFilterMap valueFilterMap); }
RiemannReporter extends ScheduledReporter { @Override public void report(SortedMap<String, Gauge> gauges, SortedMap<String, Counter> counters, SortedMap<String, Histogram> histograms, SortedMap<String, Meter> meters, SortedMap<String, Timer> timers) { final long timestamp = clock.getTime() / 1000; log.debug("Reporting metrics: for {} at {}", timestamp, System.currentTimeMillis()); try { riemann.connect(); for (Map.Entry<String, Gauge> entry : gauges.entrySet()) { reportGauge(entry.getKey(), entry.getValue(), timestamp); } for (Map.Entry<String, Counter> entry : counters.entrySet()) { reportCounter(entry.getKey(), entry.getValue(), timestamp); } for (Map.Entry<String, Histogram> entry : histograms.entrySet()) { reportHistogram(entry.getKey(), entry.getValue(), timestamp); } for (Map.Entry<String, Meter> entry : meters.entrySet()) { reportMetered(entry.getKey(), entry.getValue(), timestamp); } for (Map.Entry<String, Timer> entry : timers.entrySet()) { reportTimer(entry.getKey(), entry.getValue(), timestamp); } log.trace("Flushing events to riemann"); riemann.client.flush(); log.debug("Completed at {}", System.currentTimeMillis()); } catch (IOException e) { log.warn("Unable to report to Riemann", riemann, e); } } private  RiemannReporter(MetricRegistry registry,
                            Riemann riemann,
                            Clock clock,
                            TimeUnit rateUnit,
                            TimeUnit durationUnit,
                            Float ttl,
                            String prefix,
                            String separator,
                            String localHost,
                            List<String> tags,
                            MetricFilter filter,
                            ValueFilterMap valueFilterMap); static Builder forRegistry(MetricRegistry registry); @Override void report(SortedMap<String, Gauge> gauges,
                       SortedMap<String, Counter> counters,
                       SortedMap<String, Histogram> histograms,
                       SortedMap<String, Meter> meters,
                       SortedMap<String, Timer> timers); @Override void stop(); }
RiemannReporter extends ScheduledReporter { @Override public void report(SortedMap<String, Gauge> gauges, SortedMap<String, Counter> counters, SortedMap<String, Histogram> histograms, SortedMap<String, Meter> meters, SortedMap<String, Timer> timers) { final long timestamp = clock.getTime() / 1000; log.debug("Reporting metrics: for {} at {}", timestamp, System.currentTimeMillis()); try { riemann.connect(); for (Map.Entry<String, Gauge> entry : gauges.entrySet()) { reportGauge(entry.getKey(), entry.getValue(), timestamp); } for (Map.Entry<String, Counter> entry : counters.entrySet()) { reportCounter(entry.getKey(), entry.getValue(), timestamp); } for (Map.Entry<String, Histogram> entry : histograms.entrySet()) { reportHistogram(entry.getKey(), entry.getValue(), timestamp); } for (Map.Entry<String, Meter> entry : meters.entrySet()) { reportMetered(entry.getKey(), entry.getValue(), timestamp); } for (Map.Entry<String, Timer> entry : timers.entrySet()) { reportTimer(entry.getKey(), entry.getValue(), timestamp); } log.trace("Flushing events to riemann"); riemann.client.flush(); log.debug("Completed at {}", System.currentTimeMillis()); } catch (IOException e) { log.warn("Unable to report to Riemann", riemann, e); } } private  RiemannReporter(MetricRegistry registry,
                            Riemann riemann,
                            Clock clock,
                            TimeUnit rateUnit,
                            TimeUnit durationUnit,
                            Float ttl,
                            String prefix,
                            String separator,
                            String localHost,
                            List<String> tags,
                            MetricFilter filter,
                            ValueFilterMap valueFilterMap); static Builder forRegistry(MetricRegistry registry); @Override void report(SortedMap<String, Gauge> gauges,
                       SortedMap<String, Counter> counters,
                       SortedMap<String, Histogram> histograms,
                       SortedMap<String, Meter> meters,
                       SortedMap<String, Timer> timers); @Override void stop();  }