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

The following examples show how to use com.yammer.metrics.core.Timer#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: MemoryReporter.java    From incubator-retired-blur with Apache License 2.0 6 votes vote down vote up
@Override
public void processTimer(MetricName name, Timer timer,
    ConcurrentMap<String, org.apache.blur.thrift.generated.Metric> context) throws Exception {

  org.apache.blur.thrift.generated.Metric metric = getMetric(name, context);
  addMeter(metric, timer, context);
  metric.putToStrMap("unit", timer.durationUnit().toString());
  metric.putToDoubleMap("min", timer.min());
  metric.putToDoubleMap("max", timer.max());
  metric.putToDoubleMap("mean", timer.mean());
  metric.putToDoubleMap("stdDev", timer.stdDev());

  Snapshot snapshot = timer.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 2
Source File: JSONReporter.java    From incubator-retired-blur with Apache License 2.0 6 votes vote down vote up
@Override
public void processTimer(MetricName name, Timer timer, Context context) throws Exception {
  MetricInfo info = context.getMetricInfo(name);
  long time = context.getTime();

  addMeterInfo(time, timer, info);
  info.setMetaData("unit", timer.durationUnit().toString());
  info.addNumber("min", timer.min());
  info.addNumber("max", timer.max());
  info.addNumber("mean", timer.mean());
  info.addNumber("stdDev", timer.stdDev());

  Snapshot snapshot = timer.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 3
Source File: YammerFacadeMetric.java    From storm-metrics-reporter with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
public void processTimer(final MetricName name, final Timer timer, final Map context) throws Exception {

  final Snapshot snapshot = timer.getSnapshot();

  final Map subMetrics =
          ImmutableMap
                  .builder()
                  .put("count", timer.count())
                  .put("median", snapshot.getMedian())
                  .put("75percentile", snapshot.get75thPercentile())
                  .put("95percentile", snapshot.get95thPercentile())
                  .put("99percentile", snapshot.get99thPercentile())
                  .build();

  context.put(toString(name), subMetrics);
}
 
Example 4
Source File: CustomReporter.java    From netty-4.1.22 with Apache License 2.0 5 votes vote down vote up
@Override
public void processTimer(final MetricName name, final Timer timer,
        final PrintStream stream) {
    processMeter(name, timer, stream);
    final String durationUnit = abbrev(timer.durationUnit());
    final Snapshot snapshot = timer.getSnapshot();
    stream.printf(locale, "               min = %,2.2f %s\n", timer.min(),
            durationUnit);
    stream.printf(locale, "               max = %,2.2f %s\n", timer.max(),
            durationUnit);
    stream.printf(locale, "              mean = %,2.2f %s\n", timer.mean(),
            durationUnit);
    stream.printf(locale, "            stddev = %,2.2f %s\n",
            timer.stdDev(), durationUnit);
    stream.printf(locale, "            median = %,2.2f %s\n",
            snapshot.getMedian(), durationUnit);
    stream.printf(locale, "              75%% <= %,2.2f %s\n",
            snapshot.get75thPercentile(), durationUnit);
    stream.printf(locale, "              95%% <= %,2.2f %s\n",
            snapshot.get95thPercentile(), durationUnit);
    stream.printf(locale, "              98%% <= %,2.2f %s\n",
            snapshot.get98thPercentile(), durationUnit);
    stream.printf(locale, "              99%% <= %,2.2f %s\n",
            snapshot.get99thPercentile(), durationUnit);
    stream.printf(locale, "            99.9%% <= %,2.2f %s\n",
            snapshot.get999thPercentile(), durationUnit);
}
 
Example 5
Source File: KafkaTimelineMetricsReporter.java    From ambari-metrics with Apache License 2.0 5 votes vote down vote up
@Override
public void processTimer(MetricName name, Timer timer, Context context) throws Exception {
  final long currentTimeMillis = System.currentTimeMillis();
  final Snapshot snapshot = timer.getSnapshot();
  final String sanitizedName = sanitizeName(name);

  String[] metricMNames = cacheKafkaMetered(currentTimeMillis, sanitizedName, timer);
  String[] metricTNames = cacheKafkaSummarizable(currentTimeMillis, sanitizedName, timer);
  String[] metricSNames = cacheKafkaSnapshot(currentTimeMillis, sanitizedName, snapshot);

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

  populateMetricsList(context, MetricType.GAUGE, metricNames);
}
 
Example 6
Source File: CustomReporter.java    From netty4.0.27Learn with Apache License 2.0 5 votes vote down vote up
@Override
public void processTimer(final MetricName name, final Timer timer,
        final PrintStream stream) {
    processMeter(name, timer, stream);
    final String durationUnit = abbrev(timer.durationUnit());
    final Snapshot snapshot = timer.getSnapshot();
    stream.printf(locale, "               min = %,2.2f %s\n", timer.min(),
            durationUnit);
    stream.printf(locale, "               max = %,2.2f %s\n", timer.max(),
            durationUnit);
    stream.printf(locale, "              mean = %,2.2f %s\n", timer.mean(),
            durationUnit);
    stream.printf(locale, "            stddev = %,2.2f %s\n",
            timer.stdDev(), durationUnit);
    stream.printf(locale, "            median = %,2.2f %s\n",
            snapshot.getMedian(), durationUnit);
    stream.printf(locale, "              75%% <= %,2.2f %s\n",
            snapshot.get75thPercentile(), durationUnit);
    stream.printf(locale, "              95%% <= %,2.2f %s\n",
            snapshot.get95thPercentile(), durationUnit);
    stream.printf(locale, "              98%% <= %,2.2f %s\n",
            snapshot.get98thPercentile(), durationUnit);
    stream.printf(locale, "              99%% <= %,2.2f %s\n",
            snapshot.get99thPercentile(), durationUnit);
    stream.printf(locale, "            99.9%% <= %,2.2f %s\n",
            snapshot.get999thPercentile(), durationUnit);
}
 
Example 7
Source File: YammerMetricProcessor.java    From cruise-control with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@Override
public void processTimer(MetricName metricName, Timer timer, Context context) {
  if (MetricsUtils.isInterested(metricName)) {
    LOG.trace("Processing metric {} of type Timer.", metricName);

    CruiseControlMetric ccm = MetricsUtils.toCruiseControlMetric(context.time(),
                                                                 context.brokerId(),
                                                                 metricName,
                                                                 timer.fiveMinuteRate());
    context.reporter().sendCruiseControlMetric(ccm);
    // Get max metric value
    ccm = MetricsUtils.toCruiseControlMetric(context.time(),
                                             context.brokerId(),
                                             metricName,
                                             timer.max(),
                                             MetricsUtils.ATTRIBUTE_MAX);
    context.reporter().sendCruiseControlMetric(ccm);
    // Get mean metric value
    ccm = MetricsUtils.toCruiseControlMetric(context.time(),
                                             context.brokerId(),
                                             metricName,
                                             timer.mean(),
                                             MetricsUtils.ATTRIBUTE_MEAN);
    context.reporter().sendCruiseControlMetric(ccm);

    Snapshot snapshot = timer.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);
  }
}