Search in sources :

Example 1 with Histogram

use of com.yammer.metrics.core.Histogram in project java by wavefrontHQ.

the class FlushProcessor method processHistogram.

@Override
public void processHistogram(MetricName name, Histogram histogram, FlushProcessorContext context) throws Exception {
    if (histogram instanceof WavefrontHistogram && useWavefrontHistograms) {
        WavefrontHistogram wavefrontHistogram = (WavefrontHistogram) histogram;
        wavefront.report.Histogram.Builder builder = wavefront.report.Histogram.newBuilder();
        builder.setBins(Lists.newLinkedList());
        builder.setCounts(Lists.newLinkedList());
        long minMillis = Long.MAX_VALUE;
        if (wavefrontHistogram.count() == 0)
            return;
        for (WavefrontHistogram.MinuteBin minuteBin : wavefrontHistogram.bins(true)) {
            builder.getBins().add(minuteBin.getDist().quantile(.5));
            builder.getCounts().add(Math.toIntExact(minuteBin.getDist().size()));
            minMillis = Long.min(minMillis, minuteBin.getMinMillis());
        }
        builder.setType(HistogramType.TDIGEST);
        builder.setDuration(Math.toIntExact(currentMillis.get() - minMillis));
        context.report(builder.build());
    } else {
        context.reportSubMetric(histogram.count(), "count");
        for (Map.Entry<String, Double> entry : MetricsToTimeseries.explodeSummarizable(histogram, reportEmptyHistogramStats).entrySet()) {
            context.reportSubMetric(entry.getValue(), entry.getKey());
        }
        for (Map.Entry<String, Double> entry : MetricsToTimeseries.explodeSampling(histogram, reportEmptyHistogramStats).entrySet()) {
            context.reportSubMetric(entry.getValue(), entry.getKey());
        }
        histogram.clear();
    }
    sentCounter.inc();
}
Also used : Histogram(com.yammer.metrics.core.Histogram) WavefrontHistogram(com.yammer.metrics.core.WavefrontHistogram) WavefrontHistogram(com.yammer.metrics.core.WavefrontHistogram) Map(java.util.Map)

Example 2 with Histogram

use of com.yammer.metrics.core.Histogram in project java by wavefrontHQ.

the class Main method main.

public static void main(String[] args) throws IOException, InterruptedException {
    // Parse inputs.
    System.out.println("Args: " + Joiner.on(", ").join(args));
    if (args.length != 2) {
        System.out.println("Usage: java -jar this.jar <metricsPort> <histogramsPort>");
        return;
    }
    int port = Integer.parseInt(args[0]);
    int histoPort = Integer.parseInt(args[1]);
    // Set up periodic reporting.
    MetricsRegistry metricsRegistry = new MetricsRegistry();
    WavefrontYammerMetricsReporter wavefrontYammerMetricsReporter = new WavefrontYammerMetricsReporter(metricsRegistry, "wavefrontYammerMetrics", "localhost", port, histoPort, System::currentTimeMillis);
    wavefrontYammerMetricsReporter.start(5, TimeUnit.SECONDS);
    // Populate test metrics.
    Counter counter = metricsRegistry.newCounter(new TaggedMetricName("group", "mycounter", "tag1", "value1"));
    Histogram histogram = metricsRegistry.newHistogram(new TaggedMetricName("group2", "myhisto"), false);
    WavefrontHistogram wavefrontHistogram = WavefrontHistogram.get(metricsRegistry, new TaggedMetricName("group", "mywavefronthisto", "tag2", "value2"));
    while (true) {
        counter.inc();
        histogram.update(counter.count());
        wavefrontHistogram.update(counter.count());
        Thread.sleep(1000);
    }
}
Also used : MetricsRegistry(com.yammer.metrics.core.MetricsRegistry) Histogram(com.yammer.metrics.core.Histogram) WavefrontHistogram(com.yammer.metrics.core.WavefrontHistogram) Counter(com.yammer.metrics.core.Counter) WavefrontHistogram(com.yammer.metrics.core.WavefrontHistogram) TaggedMetricName(com.wavefront.common.TaggedMetricName)

Example 3 with Histogram

use of com.yammer.metrics.core.Histogram in project java by wavefrontHQ.

the class WavefrontYammerMetricsReporterTest method testPlainHistogramWithoutClear.

@Test(timeout = 1000)
public void testPlainHistogramWithoutClear() throws Exception {
    innerSetUp(false, null, false, false);
    Histogram histogram = metricsRegistry.newHistogram(WavefrontYammerMetricsReporterTest.class, "myhisto");
    histogram.update(1);
    histogram.update(10);
    wavefrontYammerMetricsReporter.run();
    assertThat(receiveFromSocket(11, fromMetrics), containsInAnyOrder(equalTo("\"myhisto.count\" 2.0 1485224035"), equalTo("\"myhisto.min\" 1.0 1485224035"), equalTo("\"myhisto.max\" 10.0 1485224035"), equalTo("\"myhisto.mean\" 5.5 1485224035"), equalTo("\"myhisto.sum\" 11.0 1485224035"), startsWith("\"myhisto.stddev\""), equalTo("\"myhisto.median\" 5.5 1485224035"), equalTo("\"myhisto.p75\" 10.0 1485224035"), equalTo("\"myhisto.p95\" 10.0 1485224035"), equalTo("\"myhisto.p99\" 10.0 1485224035"), equalTo("\"myhisto.p999\" 10.0 1485224035")));
    // Second run should be the same.
    wavefrontYammerMetricsReporter.run();
    assertThat(receiveFromSocket(11, fromMetrics), containsInAnyOrder(equalTo("\"myhisto.count\" 2.0 1485224035"), equalTo("\"myhisto.min\" 1.0 1485224035"), equalTo("\"myhisto.max\" 10.0 1485224035"), equalTo("\"myhisto.mean\" 5.5 1485224035"), equalTo("\"myhisto.sum\" 11.0 1485224035"), startsWith("\"myhisto.stddev\""), equalTo("\"myhisto.median\" 5.5 1485224035"), equalTo("\"myhisto.p75\" 10.0 1485224035"), equalTo("\"myhisto.p95\" 10.0 1485224035"), equalTo("\"myhisto.p99\" 10.0 1485224035"), equalTo("\"myhisto.p999\" 10.0 1485224035")));
}
Also used : Histogram(com.yammer.metrics.core.Histogram) WavefrontHistogram(com.yammer.metrics.core.WavefrontHistogram) Test(org.junit.Test)

Example 4 with Histogram

use of com.yammer.metrics.core.Histogram in project java by wavefrontHQ.

the class JsonMetricsGeneratorTest method testWavefrontHistogramClear.

@Test
public void testWavefrontHistogramClear() throws IOException {
    Histogram wh = WavefrontHistogram.get(testRegistry, new MetricName("test", "", "metric"), time::get);
    wh.update(10);
    // Simulate the 1 minute has passed and we are ready to flush the histogram
    // (i.e. all the values prior to the current minute) over the wire...
    time.addAndGet(60001L);
    generate(false, false, true, null);
    wh.update(100);
    // Simulate the 1 minute has passed and we are ready to flush the histogram
    // (i.e. all the values prior to the current minute) over the wire...
    time.addAndGet(60001L);
    String json = generate(false, false, true, null);
    assertThat(json).isEqualTo("{\"test.metric\":{\"bins\":[{\"count\":1,\"startMillis\":60000,\"durationMillis\":60000,\"means\":[100.0],\"counts\":[1]}]}}");
}
Also used : MetricName(com.yammer.metrics.core.MetricName) Histogram(com.yammer.metrics.core.Histogram) WavefrontHistogram(com.yammer.metrics.core.WavefrontHistogram) Test(org.junit.Test)

Example 5 with Histogram

use of com.yammer.metrics.core.Histogram in project java by wavefrontHQ.

the class JsonMetricsGeneratorTest method testWavefrontHistogramSpanMultipleMinutes.

@Test
public void testWavefrontHistogramSpanMultipleMinutes() throws IOException {
    Histogram wh = WavefrontHistogram.get(testRegistry, new MetricName("test", "", "metric"), time::get);
    wh.update(10);
    wh.update(100);
    // Simulate the clock advanced by 1 minute
    time.set(61 * 1000);
    wh.update(1000);
    // Simulate the clock advanced by 1 minute
    time.set(61 * 1000 * 2);
    String json = generate(false, false, false, null);
    assertThat(json).isEqualTo("{\"test.metric\":{\"bins\":[{\"count\":2,\"startMillis\":0,\"durationMillis\":60000,\"means\":[10.0,100.0],\"counts\":[1,1]},{\"count\":1,\"startMillis\":60000,\"durationMillis\":60000,\"means\":[1000.0],\"counts\":[1]}]}}");
}
Also used : MetricName(com.yammer.metrics.core.MetricName) Histogram(com.yammer.metrics.core.Histogram) WavefrontHistogram(com.yammer.metrics.core.WavefrontHistogram) Test(org.junit.Test)

Aggregations

Histogram (com.yammer.metrics.core.Histogram)15 WavefrontHistogram (com.yammer.metrics.core.WavefrontHistogram)11 Test (org.junit.Test)10 MetricName (com.yammer.metrics.core.MetricName)7 TaggedMetricName (com.wavefront.common.TaggedMetricName)2 Counter (com.yammer.metrics.core.Counter)2 ArrayList (java.util.ArrayList)2 AggregatedHistogram (com.linkedin.pinot.common.metrics.AggregatedHistogram)1 LatencyMetric (com.linkedin.pinot.common.metrics.LatencyMetric)1 ServerInstance (com.linkedin.pinot.common.response.ServerInstance)1 PerTableRoutingConfig (com.linkedin.pinot.transport.config.PerTableRoutingConfig)1 RoutingTableConfig (com.linkedin.pinot.transport.config.RoutingTableConfig)1 ClusterId (com.nokia.dempsy.config.ClusterId)1 Destination (com.nokia.dempsy.messagetransport.Destination)1 Sender (com.nokia.dempsy.messagetransport.Sender)1 SenderFactory (com.nokia.dempsy.messagetransport.SenderFactory)1 StatsCollector (com.nokia.dempsy.monitoring.StatsCollector)1 BasicStatsCollector (com.nokia.dempsy.monitoring.basic.BasicStatsCollector)1 StatsCollectorFactoryCoda (com.nokia.dempsy.monitoring.coda.StatsCollectorFactoryCoda)1 MetricsRegistry (com.yammer.metrics.core.MetricsRegistry)1