com.yammer.metrics.core.Sampling Java Examples

The following examples show how to use com.yammer.metrics.core.Sampling. 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: StatsDReporterTest.java    From kafka-statsd-metrics2 with Apache License 2.0 5 votes vote down vote up
static void setupSamplingMock(Sampling sampling) {  //be careful how snapshot defines statistics
  final double[] values = new double[1001];
  for (int i = 0; i < values.length; i++) {
    values[i] = i / 1000.0;
  }
  when(sampling.getSnapshot()).thenReturn(new Snapshot(values));
}
 
Example #2
Source File: AggregateMetricSenderSessionWrapper.java    From signalfx-java with Apache License 2.0 4 votes vote down vote up
/**
 * Add sampling
 * @param baseName
 * @param sampling
 */

private void addSampling(MetricName baseName, Sampling sampling) {
    Metric metric = (Metric)sampling;
    final Snapshot snapshot = sampling.getSnapshot();
    addMetric(metric, baseName,
            SignalFxReporter.MetricDetails.MEDIAN,
            SignalFxProtocolBuffers.MetricType.GAUGE, snapshot.getMedian());
    addMetric(metric, baseName,
            SignalFxReporter.MetricDetails.PERCENT_75,
            SignalFxProtocolBuffers.MetricType.GAUGE, snapshot.get75thPercentile());
    addMetric(metric, baseName,
            SignalFxReporter.MetricDetails.PERCENT_95,
            SignalFxProtocolBuffers.MetricType.GAUGE, snapshot.get95thPercentile());
    addMetric(metric, baseName,
            SignalFxReporter.MetricDetails.PERCENT_98,
            SignalFxProtocolBuffers.MetricType.GAUGE, snapshot.get98thPercentile());
    addMetric(metric, baseName,
            SignalFxReporter.MetricDetails.PERCENT_99,
            SignalFxProtocolBuffers.MetricType.GAUGE, snapshot.get99thPercentile());
    addMetric(metric, baseName,
            SignalFxReporter.MetricDetails.PERCENT_999,
            SignalFxProtocolBuffers.MetricType.GAUGE, snapshot.get999thPercentile());
    addMetric(metric, baseName,
            SignalFxReporter.MetricDetails.MAX,
            SignalFxProtocolBuffers.MetricType.GAUGE, getMax(snapshot));
    addMetric(metric, baseName,
            SignalFxReporter.MetricDetails.MIN,
            SignalFxProtocolBuffers.MetricType.GAUGE, getMin(snapshot));


    // These are slower to calculate.  Only calculate if we need.
    if (detailsToAdd.contains(SignalFxReporter.MetricDetails.STD_DEV)) {
        addMetric(metric, baseName,
                SignalFxReporter.MetricDetails.STD_DEV,
                SignalFxProtocolBuffers.MetricType.GAUGE, getStdDev(snapshot));
    }
    if (detailsToAdd.contains(SignalFxReporter.MetricDetails.MEAN)) {
        addMetric(metric, baseName,
                SignalFxReporter.MetricDetails.MEAN,
                SignalFxProtocolBuffers.MetricType.GAUGE, getMean(snapshot));
    }
}
 
Example #3
Source File: MetricsHelper.java    From incubator-pinot with Apache License 2.0 3 votes vote down vote up
/**
 *
 * Return an existing aggregated histogram if registry is not null and a aggregated histogram already exist
 * with the same metric name. Otherwise, creates a new aggregated histogram and registers (if registry not null)
 *
 * @param registry MetricsRegistry
 * @param name metric name
 * @return AggregatedHistogram
 */
public static <T extends Sampling> AggregatedHistogram<T> newAggregatedHistogram(AggregatedMetricsRegistry registry,
    MetricName name) {
  if (registry != null) {
    return registry.newAggregatedHistogram(name);
  } else {
    return new AggregatedHistogram<T>();
  }
}
 
Example #4
Source File: AggregatedMetricsRegistry.java    From incubator-pinot with Apache License 2.0 2 votes vote down vote up
/**
 * Creates a new {@link AggregatedHistogram} and registers it under the given metric name.
 *
 * @param metricName the name of the metric
 * @return a new {@link AggregatedHistogram}
 */
public <T extends Sampling> AggregatedHistogram<T> newAggregatedHistogram(MetricName metricName) {
  return getOrAdd(metricName, new AggregatedHistogram<T>());
}