Search in sources :

Example 26 with Snapshot

use of com.codahale.metrics.Snapshot in project engineblock by engineblock.

the class TestHistoTypes method summary.

private void summary(long min, long max, Snapshot... snapshots) {
    for (int i = 0; i <= 100; i++) {
        double pct = (double) i / 100.0D;
        double expectedValue = pct * max;
        System.out.format("% 3d %%p is % 11d : ", (long) (pct * 100), (long) expectedValue);
        for (Snapshot snapshot : snapshots) {
            System.out.format("% 10d ", (long) snapshot.getValue(pct));
        }
        System.out.print("\n");
    }
}
Also used : Snapshot(com.codahale.metrics.Snapshot)

Example 27 with Snapshot

use of com.codahale.metrics.Snapshot in project oxCore by GluuFederation.

the class LdapEntryReporter method builTimerEntries.

private List<MetricEntry> builTimerEntries(SortedMap<String, Timer> timers, Set<MetricType> registeredMetricTypes) {
    List<MetricEntry> result = new ArrayList<MetricEntry>();
    for (MetricType metricType : registeredMetricTypes) {
        Timer timer = timers.get(metricType.getValue());
        if (timer != null) {
            Snapshot snapshot = timer.getSnapshot();
            TimerMetricData timerMetricData = new TimerMetricData(timer.getCount(), convertRate(timer.getMeanRate()), convertRate(timer.getOneMinuteRate()), convertRate(timer.getFiveMinuteRate()), convertRate(timer.getFifteenMinuteRate()), getRateUnit(), convertDuration(snapshot.getMin()), convertDuration(snapshot.getMax()), convertDuration(snapshot.getMean()), convertDuration(snapshot.getStdDev()), convertDuration(snapshot.getMedian()), convertDuration(snapshot.get75thPercentile()), convertDuration(snapshot.get95thPercentile()), convertDuration(snapshot.get98thPercentile()), convertDuration(snapshot.get99thPercentile()), convertDuration(snapshot.get999thPercentile()), getDurationUnit());
            TimerMetricEntry timerMetricEntry = new TimerMetricEntry();
            timerMetricEntry.setMetricData(timerMetricData);
            timerMetricEntry.setMetricType(metricType);
            result.add(timerMetricEntry);
        }
    }
    return result;
}
Also used : Snapshot(com.codahale.metrics.Snapshot) Timer(com.codahale.metrics.Timer) MetricType(org.xdi.model.metric.MetricType) ArrayList(java.util.ArrayList) CounterMetricEntry(org.xdi.model.metric.counter.CounterMetricEntry) TimerMetricEntry(org.xdi.model.metric.timer.TimerMetricEntry) MetricEntry(org.xdi.model.metric.ldap.MetricEntry) TimerMetricData(org.xdi.model.metric.timer.TimerMetricData) TimerMetricEntry(org.xdi.model.metric.timer.TimerMetricEntry)

Example 28 with Snapshot

use of com.codahale.metrics.Snapshot in project sling by apache.

the class MetricWebConsolePlugin method addHistogramDetails.

private void addHistogramDetails(PrintWriter pw, SortedMap<String, Histogram> histograms) {
    if (histograms.isEmpty()) {
        return;
    }
    pw.println("<br>");
    pw.println("<div class='table'>");
    pw.println("<div class='ui-widget-header ui-corner-top buttonGroup'>Histograms</div>");
    pw.println("<table class='nicetable' id='data-histograms'>");
    pw.println("<thead>");
    pw.println("<tr>");
    pw.println("<th class='header'>Name</th>");
    pw.println("<th class='header'>Count</th>");
    pw.println("<th class='header'>50%</th>");
    pw.println("<th class='header'>Min</th>");
    pw.println("<th class='header'>Max</th>");
    pw.println("<th class='header'>Mean</th>");
    pw.println("<th class='header'>StdDev</th>");
    pw.println("<th class='header'>75%</th>");
    pw.println("<th class='header'>95%</th>");
    pw.println("<th class='header'>98%</th>");
    pw.println("<th class='header'>99%</th>");
    pw.println("<th class='header'>999%</th>");
    pw.println("<th>Duration Unit</th>");
    pw.println("</tr>");
    pw.println("</thead>");
    pw.println("<tbody>");
    String rowClass = "odd";
    for (Map.Entry<String, Histogram> e : histograms.entrySet()) {
        Histogram h = e.getValue();
        Snapshot s = h.getSnapshot();
        String name = e.getKey();
        double durationFactor = 1.0 / timeUnit.durationFor(name).toNanos(1);
        String durationUnit = timeUnit.durationFor(name).toString().toLowerCase(Locale.US);
        pw.printf("<tr class='%s ui-state-default'>%n", rowClass);
        pw.printf("<td>%s</td>", name);
        pw.printf("<td>%d</td>", h.getCount());
        pw.printf("<td>%f</td>", s.getMedian() * durationFactor);
        pw.printf("<td>%f</td>", s.getMin() * durationFactor);
        pw.printf("<td>%f</td>", s.getMax() * durationFactor);
        pw.printf("<td>%f</td>", s.getMean() * durationFactor);
        pw.printf("<td>%f</td>", s.getStdDev() * durationFactor);
        pw.printf("<td>%f</td>", s.get75thPercentile() * durationFactor);
        pw.printf("<td>%f</td>", s.get95thPercentile() * durationFactor);
        pw.printf("<td>%f</td>", s.get98thPercentile() * durationFactor);
        pw.printf("<td>%f</td>", s.get99thPercentile() * durationFactor);
        pw.printf("<td>%f</td>", s.get999thPercentile() * durationFactor);
        pw.printf("<td>%s</td>", durationUnit);
        pw.println("</tr>");
        rowClass = "odd".equals(rowClass) ? "even" : "odd";
    }
    pw.println("</tbody>");
    pw.println("</table>");
    pw.println("</div>");
}
Also used : Snapshot(com.codahale.metrics.Snapshot) Histogram(com.codahale.metrics.Histogram) ConcurrentMap(java.util.concurrent.ConcurrentMap) Map(java.util.Map) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) SortedMap(java.util.SortedMap)

Example 29 with Snapshot

use of com.codahale.metrics.Snapshot in project sling by apache.

the class JSONReporter method printTimer.

private void printTimer(Map.Entry<String, Timer> e) throws IOException {
    json.key(e.getKey()).object();
    Timer timer = e.getValue();
    Snapshot snapshot = timer.getSnapshot();
    json.key("count").value(timer.getCount());
    json.key("max").value(snapshot.getMax() * durationFactor);
    json.key("mean").value(snapshot.getMean() * durationFactor);
    json.key("min").value(snapshot.getMin() * durationFactor);
    json.key("p50").value(snapshot.getMedian() * durationFactor);
    json.key("p75").value(snapshot.get75thPercentile() * durationFactor);
    json.key("p95").value(snapshot.get95thPercentile() * durationFactor);
    json.key("p98").value(snapshot.get98thPercentile() * durationFactor);
    json.key("p99").value(snapshot.get99thPercentile() * durationFactor);
    json.key("p999").value(snapshot.get999thPercentile() * durationFactor);
    json.key("stddev").value(snapshot.getStdDev() * durationFactor);
    json.key("m1_rate").value(timer.getOneMinuteRate() * rateFactor);
    json.key("m5_rate").value(timer.getFiveMinuteRate() * rateFactor);
    json.key("m15_rate").value(timer.getFifteenMinuteRate() * rateFactor);
    json.key("mean_rate").value(timer.getMeanRate() * rateFactor);
    json.key("duration_units").value(durationUnit);
    json.key("rate_units").value(rateUnit);
    json.endObject();
}
Also used : Snapshot(com.codahale.metrics.Snapshot) Timer(com.codahale.metrics.Timer)

Example 30 with Snapshot

use of com.codahale.metrics.Snapshot in project sling by apache.

the class JSONReporter method printHistogram.

private void printHistogram(Map.Entry<String, Histogram> e) throws IOException {
    json.key(e.getKey()).object();
    json.key("count").value(e.getValue().getCount());
    Snapshot snapshot = e.getValue().getSnapshot();
    json.key("max").value(snapshot.getMax());
    json.key("mean").value(snapshot.getMean());
    json.key("min").value(snapshot.getMin());
    json.key("p50").value(snapshot.getMedian());
    json.key("p75").value(snapshot.get75thPercentile());
    json.key("p95").value(snapshot.get95thPercentile());
    json.key("p98").value(snapshot.get98thPercentile());
    json.key("p99").value(snapshot.get99thPercentile());
    json.key("p999").value(snapshot.get999thPercentile());
    json.key("stddev").value(snapshot.getStdDev());
    json.endObject();
}
Also used : Snapshot(com.codahale.metrics.Snapshot)

Aggregations

Snapshot (com.codahale.metrics.Snapshot)57 Test (org.junit.Test)13 Histogram (com.codahale.metrics.Histogram)11 Timer (com.codahale.metrics.Timer)11 Map (java.util.Map)6 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)4 ConcurrentMap (java.util.concurrent.ConcurrentMap)4 HashMap (java.util.HashMap)3 SortedMap (java.util.SortedMap)3 MetricSnapshot (backtype.storm.generated.MetricSnapshot)2 JAverageSnapshot (com.alibaba.jstorm.common.metric.codahale.JAverageSnapshot)2 Counter (com.codahale.metrics.Counter)2 Gauge (com.codahale.metrics.Gauge)2 Meter (com.codahale.metrics.Meter)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)2 InOrder (org.mockito.InOrder)2 SlidingWindowReservoir (com.codahale.metrics.SlidingWindowReservoir)1 UniformReservoir (com.codahale.metrics.UniformReservoir)1 ResultSet (com.datastax.driver.core.ResultSet)1 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)1