Java Code Examples for com.yammer.metrics.core.Histogram#getSnapshot()

The following examples show how to use com.yammer.metrics.core.Histogram#getSnapshot() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CustomReporter.java    From netty-4.1.22 with Apache License 2.0 6 votes vote down vote up
@Override
public void processHistogram(final MetricName name,
        final Histogram histogram, final PrintStream stream) {
    final Snapshot snapshot = histogram.getSnapshot();
    stream.printf(locale, "               min = %,2.2f\n", histogram.min());
    stream.printf(locale, "               max = %,2.2f\n", histogram.max());
    stream.printf(locale, "              mean = %,2.2f\n", histogram.mean());
    stream.printf(locale, "            stddev = %,2.2f\n",
            histogram.stdDev());
    stream.printf(locale, "            median = %,2.2f\n",
            snapshot.getMedian());
    stream.printf(locale, "              75%% <= %,2.2f\n",
            snapshot.get75thPercentile());
    stream.printf(locale, "              95%% <= %,2.2f\n",
            snapshot.get95thPercentile());
    stream.printf(locale, "              98%% <= %,2.2f\n",
            snapshot.get98thPercentile());
    stream.printf(locale, "              99%% <= %,2.2f\n",
            snapshot.get99thPercentile());
    stream.printf(locale, "            99.9%% <= %,2.2f\n",
            snapshot.get999thPercentile());
}
 
Example 2
Source File: CustomReporter.java    From netty4.0.27Learn with Apache License 2.0 6 votes vote down vote up
@Override
public void processHistogram(final MetricName name,
        final Histogram histogram, final PrintStream stream) {
    final Snapshot snapshot = histogram.getSnapshot();
    stream.printf(locale, "               min = %,2.2f\n", histogram.min());
    stream.printf(locale, "               max = %,2.2f\n", histogram.max());
    stream.printf(locale, "              mean = %,2.2f\n", histogram.mean());
    stream.printf(locale, "            stddev = %,2.2f\n",
            histogram.stdDev());
    stream.printf(locale, "            median = %,2.2f\n",
            snapshot.getMedian());
    stream.printf(locale, "              75%% <= %,2.2f\n",
            snapshot.get75thPercentile());
    stream.printf(locale, "              95%% <= %,2.2f\n",
            snapshot.get95thPercentile());
    stream.printf(locale, "              98%% <= %,2.2f\n",
            snapshot.get98thPercentile());
    stream.printf(locale, "              99%% <= %,2.2f\n",
            snapshot.get99thPercentile());
    stream.printf(locale, "            99.9%% <= %,2.2f\n",
            snapshot.get999thPercentile());
}
 
Example 3
Source File: MemoryReporter.java    From incubator-retired-blur with Apache License 2.0 6 votes vote down vote up
@Override
public void processHistogram(MetricName name, Histogram histogram,
    ConcurrentMap<String, org.apache.blur.thrift.generated.Metric> context) throws Exception {
  org.apache.blur.thrift.generated.Metric metric = getMetric(name, context);
  metric.putToDoubleMap("min", histogram.min());
  metric.putToDoubleMap("max", histogram.max());
  metric.putToDoubleMap("mean", histogram.mean());
  metric.putToDoubleMap("stdDev", histogram.stdDev());

  Snapshot snapshot = histogram.getSnapshot();
  metric.putToDoubleMap("median", snapshot.getMedian());
  metric.putToDoubleMap("75%", snapshot.get75thPercentile());
  metric.putToDoubleMap("95%", snapshot.get95thPercentile());
  metric.putToDoubleMap("98%", snapshot.get98thPercentile());
  metric.putToDoubleMap("99%", snapshot.get99thPercentile());
  metric.putToDoubleMap("99.9%", snapshot.get999thPercentile());
}
 
Example 4
Source File: JSONReporter.java    From incubator-retired-blur with Apache License 2.0 6 votes vote down vote up
@Override
public void processHistogram(MetricName name, Histogram histogram, Context context) throws Exception {
  MetricInfo info = context.getMetricInfo(name);
  long time = context.getTime();
  info.addNumber("timestamp", time);
  info.addNumber("min", histogram.min());
  info.addNumber("max", histogram.max());
  info.addNumber("mean", histogram.mean());
  info.addNumber("stdDev", histogram.stdDev());

  Snapshot snapshot = histogram.getSnapshot();
  info.addNumber("median", snapshot.getMedian());
  info.addNumber("75%", snapshot.get75thPercentile());
  info.addNumber("95%", snapshot.get95thPercentile());
  info.addNumber("98%", snapshot.get98thPercentile());
  info.addNumber("99%", snapshot.get99thPercentile());
  info.addNumber("99.9%", snapshot.get999thPercentile());
}
 
Example 5
Source File: YammerFacadeMetric.java    From storm-metrics-reporter with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
public void processHistogram(final MetricName metricName,
                             final Histogram histogram,
                             final Map context) throws Exception {

  final Snapshot snapshot = histogram.getSnapshot();

  final Map subMetrics =
          ImmutableMap
                  .builder()
                  .put("75percentile", snapshot.get75thPercentile())
                  .put("95percentile", snapshot.get95thPercentile())
                  .put("99percentile", snapshot.get99thPercentile())
                  .put("median", snapshot.getMedian())
                  .put("mean", histogram.mean())
                  .put("min", histogram.min())
                  .put("max", histogram.max())
                  .put("stddev", histogram.stdDev())
                  .build();


  context.put(toString(metricName), subMetrics);
}
 
Example 6
Source File: KafkaTimelineMetricsReporter.java    From ambari-metrics with Apache License 2.0 5 votes vote down vote up
@Override
public void processHistogram(MetricName name, Histogram histogram, Context context) throws Exception {
  final long currentTimeMillis = System.currentTimeMillis();
  final Snapshot snapshot = histogram.getSnapshot();
  final String sanitizedName = sanitizeName(name);

  String[] metricHNames = cacheKafkaSummarizable(currentTimeMillis, sanitizedName, histogram);
  String[] metricSNames = cacheKafkaSnapshot(currentTimeMillis, sanitizedName, snapshot);

  String[] metricNames = (String[]) ArrayUtils.addAll(metricHNames, metricSNames);

  populateMetricsList(context, MetricType.GAUGE, metricNames);
}
 
Example 7
Source File: YammerMetricProcessor.java    From cruise-control with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
public void processHistogram(MetricName metricName, Histogram histogram, Context context) {
  if (MetricsUtils.isInterested(metricName)) {
    LOG.trace("Processing metric {} of type Histogram.", metricName);
    // Get max metric value
    CruiseControlMetric ccm = MetricsUtils.toCruiseControlMetric(context.time(),
                                                                 context.brokerId(),
                                                                 metricName,
                                                                 histogram.max(),
                                                                 MetricsUtils.ATTRIBUTE_MAX);
    context.reporter().sendCruiseControlMetric(ccm);

    // Get mean metric value
    ccm = MetricsUtils.toCruiseControlMetric(context.time(),
                                             context.brokerId(),
                                             metricName,
                                             histogram.mean(),
                                             MetricsUtils.ATTRIBUTE_MEAN);
    context.reporter().sendCruiseControlMetric(ccm);

    Snapshot snapshot = histogram.getSnapshot();
    // Get 50th percentile (i.e. median) metric value
    ccm = MetricsUtils.toCruiseControlMetric(context.time(),
                                             context.brokerId(),
                                             metricName,
                                             snapshot.getMedian(),
                                             MetricsUtils.ATTRIBUTE_50TH_PERCENTILE);
    context.reporter().sendCruiseControlMetric(ccm);

    // Get 999th percentile metric value
    ccm = MetricsUtils.toCruiseControlMetric(context.time(),
                                             context.brokerId(),
                                             metricName,
                                             snapshot.get999thPercentile(),
                                             MetricsUtils.ATTRIBUTE_999TH_PERCENTILE);
    context.reporter().sendCruiseControlMetric(ccm);
  }
}