Java 类com.codahale.metrics.Snapshot 实例源码

项目:sstable-adaptor    文件:DecayingEstimatedHistogramReservoir.java   
/**
 * Returns a snapshot of the decaying values in this reservoir.
 *
 * Non-decaying reservoir will not be included in the snapshot.
 *
 * @return the snapshot
 */
public Snapshot getSnapshot()
{
    rescaleIfNeeded();

    lockForRegularUsage();

    try
    {
        return new EstimatedHistogramReservoirSnapshot(this);
    }
    finally
    {
        unlockForRegularUsage();
    }
}
项目:JInsight    文件:ApptuitReporter.java   
private void reportSnapshot(TagEncodedMetricName metric, Snapshot snapshot) {
  addDataPoint(metric.submetric("duration.min"), convertDuration(snapshot.getMin()));
  addDataPoint(metric.submetric("duration.max"), convertDuration(snapshot.getMax()));
  addDataPoint(metric.submetric("duration.mean"), convertDuration(snapshot.getMean()));
  addDataPoint(metric.submetric("duration.stddev"), convertDuration(snapshot.getStdDev()));
  addDataPoint(metric.submetric("duration").withTags("quantile", "p50"),
      convertDuration(snapshot.getMedian()));
  addDataPoint(metric.submetric("duration").withTags("quantile", "p75"),
      convertDuration(snapshot.get75thPercentile()));
  addDataPoint(metric.submetric("duration").withTags("quantile", "p95"),
      convertDuration(snapshot.get95thPercentile()));
  addDataPoint(metric.submetric("duration").withTags("quantile", "p98"),
      convertDuration(snapshot.get98thPercentile()));
  addDataPoint(metric.submetric("duration").withTags("quantile", "p99"),
      convertDuration(snapshot.get99thPercentile()));
  addDataPoint(metric.submetric("duration").withTags("quantile", "p999"),
      convertDuration(snapshot.get999thPercentile()));
}
项目:dropwizard-influxdb-reporter    文件:DropwizardTransformer.java   
/**
 * Build an {@link InfluxDbMeasurement} from a histogram.
 */
@VisibleForTesting InfluxDbMeasurement fromHistogram(final String metricName, final Histogram h, final long timestamp) {
  final Snapshot snapshot = h.getSnapshot();
  final DropwizardMeasurement measurement = parser.parse(metricName);

  final Map<String, String> tags = new HashMap<>(baseTags);
  tags.putAll(measurement.tags());

  return new InfluxDbMeasurement.Builder(measurement.name(), timestamp)
    .putTags(tags)
    .putField("count", snapshot.size())
    .putField("min", snapshot.getMin())
    .putField("max", snapshot.getMax())
    .putField("mean", snapshot.getMean())
    .putField("std-dev", snapshot.getStdDev())
    .putField("50-percentile", snapshot.getMedian())
    .putField("75-percentile", snapshot.get75thPercentile())
    .putField("95-percentile", snapshot.get95thPercentile())
    .putField("99-percentile", snapshot.get99thPercentile())
    .putField("999-percentile", snapshot.get999thPercentile())
    .putField("run-count", h.getCount())
    .build();
}
项目:oneops    文件:MetricsElasticsearchModule.java   
@Override
public void serialize(JsonHistogram jsonHistogram,
                      JsonGenerator json,
                      SerializerProvider provider) throws IOException {
    json.writeStartObject();
    json.writeStringField("name", jsonHistogram.name());
    json.writeObjectField(timestampFieldname, jsonHistogram.timestampAsDate());
    Histogram histogram = jsonHistogram.value();

    final Snapshot snapshot = histogram.getSnapshot();
    json.writeNumberField("count", histogram.getCount());
    json.writeNumberField("max", snapshot.getMax());
    json.writeNumberField("mean", snapshot.getMean());
    json.writeNumberField("min", snapshot.getMin());
    json.writeNumberField("p50", snapshot.getMedian());
    json.writeNumberField("p75", snapshot.get75thPercentile());
    json.writeNumberField("p95", snapshot.get95thPercentile());
    json.writeNumberField("p98", snapshot.get98thPercentile());
    json.writeNumberField("p99", snapshot.get99thPercentile());
    json.writeNumberField("p999", snapshot.get999thPercentile());

    json.writeNumberField("stddev", snapshot.getStdDev());
    addOneOpsMetadata(json);
    json.writeEndObject();
}
项目:Lagerta    文件:HumanReadableCsvReporter.java   
/** */
private void reportTimer(String timestamp, String name, Timer timer) {
    final Snapshot snapshot = timer.getSnapshot();

    report(timestamp,
        name,
        "count,max,mean,min,stddev,p50,p75,p95,p98,p99,p999,mean_rate,m1_rate,m5_rate,m15_rate,rate_unit,duration_unit",
        "%d,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,calls/%s,%s",
        timer.getCount(),
        convertDuration(snapshot.getMax()),
        convertDuration(snapshot.getMean()),
        convertDuration(snapshot.getMin()),
        convertDuration(snapshot.getStdDev()),
        convertDuration(snapshot.getMedian()),
        convertDuration(snapshot.get75thPercentile()),
        convertDuration(snapshot.get95thPercentile()),
        convertDuration(snapshot.get98thPercentile()),
        convertDuration(snapshot.get99thPercentile()),
        convertDuration(snapshot.get999thPercentile()),
        convertRate(timer.getMeanRate()),
        convertRate(timer.getOneMinuteRate()),
        convertRate(timer.getFiveMinuteRate()),
        convertRate(timer.getFifteenMinuteRate()),
        getRateUnit(),
        getDurationUnit());
}
项目:Lagerta    文件:HumanReadableCsvReporter.java   
/** */
private void reportHistogram(String timestamp, String name, Histogram histogram) {
    final Snapshot snapshot = histogram.getSnapshot();

    report(timestamp,
        name,
        "count,max,mean,min,stddev,p50,p75,p90,p95,p98,p99,p999",
        "%d,%d,%f,%d,%f,%f,%f,%f,%f,%f,%f,%f",
        histogram.getCount(),
        snapshot.getMax(),
        snapshot.getMean(),
        snapshot.getMin(),
        snapshot.getStdDev(),
        snapshot.getMedian(),
        snapshot.get75thPercentile(),
        snapshot.getValue(0.9), // Add 90-th percentile to report.
        snapshot.get95thPercentile(),
        snapshot.get98thPercentile(),
        snapshot.get99thPercentile(),
        snapshot.get999thPercentile());
}
项目:dropwizard-prometheus    文件:DropwizardMetricsExporter.java   
private void writeSnapshotAndCount(String dropwizardName, Snapshot snapshot, long count, double factor, MetricType type, String helpMessage) throws IOException {
    String name = sanitizeMetricName(dropwizardName);
    writer.writeHelp(name, helpMessage);
    writer.writeType(name, type);
    writer.writeSample(name, mapOf("quantile", "0.5"), snapshot.getMedian() * factor);
    writer.writeSample(name, mapOf("quantile", "0.75"), snapshot.get75thPercentile() * factor);
    writer.writeSample(name, mapOf("quantile", "0.95"), snapshot.get95thPercentile() * factor);
    writer.writeSample(name, mapOf("quantile", "0.98"), snapshot.get98thPercentile() * factor);
    writer.writeSample(name, mapOf("quantile", "0.99"), snapshot.get99thPercentile() * factor);
    writer.writeSample(name, mapOf("quantile", "0.999"), snapshot.get999thPercentile() * factor);
    writer.writeSample(name + "_min", emptyMap(), snapshot.getMin());
    writer.writeSample(name + "_max", emptyMap(), snapshot.getMax());
    writer.writeSample(name + "_median", emptyMap(), snapshot.getMedian());
    writer.writeSample(name + "_mean", emptyMap(), snapshot.getMean());
    writer.writeSample(name + "_stddev", emptyMap(), snapshot.getStdDev());
    writer.writeSample(name + "_count", emptyMap(), count);
}
项目:spelk    文件:ElasticsearchReporter.java   
private void reportHistogram(JsonGenerator jsonGenerator, Entry<String, Histogram> entry, String timestampString) {
    try {
        writeStartMetric(entry.getKey(), jsonGenerator, timestampString);
        jsonGenerator.writeStartObject();
        final Histogram histogram = entry.getValue();
        final Snapshot snapshot = histogram.getSnapshot();
        jsonGenerator.writeNumberField("count", histogram.getCount());
        jsonGenerator.writeNumberField("min", convertDuration(snapshot.getMin()));
        jsonGenerator.writeNumberField("max", convertDuration(snapshot.getMax()));
        jsonGenerator.writeNumberField("mean", convertDuration(snapshot.getMean()));
        jsonGenerator.writeNumberField("stddev", convertDuration(snapshot.getStdDev()));
        jsonGenerator.writeNumberField("median", convertDuration(snapshot.getMedian()));
        jsonGenerator.writeNumberField("75th percentile", convertDuration(snapshot.get75thPercentile()));
        jsonGenerator.writeNumberField("95th percentile", convertDuration(snapshot.get95thPercentile()));
        jsonGenerator.writeNumberField("98th percentile", convertDuration(snapshot.get98thPercentile()));
        jsonGenerator.writeNumberField("99th percentile", convertDuration(snapshot.get99thPercentile()));
        jsonGenerator.writeNumberField("999th percentile", convertDuration(snapshot.get999thPercentile()));

        jsonGenerator.writeEndObject();
        writeEndMetric(jsonGenerator);

    } catch (IOException ioe) {
        LOGGER.error("Exception writing metrics to Elasticsearch index: " + ioe.toString());
    }

}
项目:codahale-aggregated-metrics-cloudwatch-reporter    文件:CloudWatchReporter.java   
/**
 * The {@link Snapshot} values of {@link Timer} are reported as {@link StatisticSet} after conversion. The
 * conversion is done using the duration factor, which is deduced from the set duration unit.
 * <p>
 * Please note, the reported values submitted only if they show some data (greater than zero) in order to:
 * <p>
 * 1. save some money
 * 2. prevent com.amazonaws.services.cloudwatch.model.InvalidParameterValueException if empty {@link Snapshot}
 * is submitted
 * <p>
 * If {@link Builder#withZeroValuesSubmission()} is {@code true}, then all values will be submitted
 *
 * @see Timer#getSnapshot
 * @see #getDurationUnit
 * @see #convertDuration(double)
 */
private void processTimer(final String metricName, final Timer timer, final List<MetricDatum> metricData) {
    final Snapshot snapshot = timer.getSnapshot();

    if (builder.withZeroValuesSubmission || snapshot.size() > 0) {
        for (final Percentile percentile : builder.percentiles) {
            final double convertedDuration = convertDuration(snapshot.getValue(percentile.getQuantile()));
            stageMetricDatum(true, metricName, convertedDuration, durationUnit, percentile.getDesc(), metricData);
        }
    }

    // prevent empty snapshot from causing InvalidParameterValueException
    if (snapshot.size() > 0) {
        final String formattedDuration = String.format(" [in-%s]", getDurationUnit());
        stageMetricDatum(builder.withArithmeticMean, metricName, convertDuration(snapshot.getMean()), durationUnit, DIMENSION_SNAPSHOT_MEAN + formattedDuration, metricData);
        stageMetricDatum(builder.withStdDev, metricName, convertDuration(snapshot.getStdDev()), durationUnit, DIMENSION_SNAPSHOT_STD_DEV + formattedDuration, metricData);
        stageMetricDatumWithConvertedSnapshot(builder.withStatisticSet, metricName, snapshot, durationUnit, metricData);
    }
}
项目:codahale-aggregated-metrics-cloudwatch-reporter    文件:CloudWatchReporter.java   
/**
 * The {@link Snapshot} values of {@link Histogram} are reported as {@link StatisticSet} raw. In other words, the
 * conversion using the duration factor does NOT apply.
 * <p>
 * Please note, the reported values submitted only if they show some data (greater than zero) in order to:
 * <p>
 * 1. save some money
 * 2. prevent com.amazonaws.services.cloudwatch.model.InvalidParameterValueException if empty {@link Snapshot}
 * is submitted
 * <p>
 * If {@link Builder#withZeroValuesSubmission()} is {@code true}, then all values will be submitted
 *
 * @see Histogram#getSnapshot
 */
private void processHistogram(final String metricName, final Histogram histogram, final List<MetricDatum> metricData) {
    final Snapshot snapshot = histogram.getSnapshot();

    if (builder.withZeroValuesSubmission || snapshot.size() > 0) {
        for (final Percentile percentile : builder.percentiles) {
            final double value = snapshot.getValue(percentile.getQuantile());
            stageMetricDatum(true, metricName, value, StandardUnit.None, percentile.getDesc(), metricData);
        }
    }

    // prevent empty snapshot from causing InvalidParameterValueException
    if (snapshot.size() > 0) {
        stageMetricDatum(builder.withArithmeticMean, metricName, snapshot.getMean(), StandardUnit.None, DIMENSION_SNAPSHOT_MEAN, metricData);
        stageMetricDatum(builder.withStdDev, metricName, snapshot.getStdDev(), StandardUnit.None, DIMENSION_SNAPSHOT_STD_DEV, metricData);
        stageMetricDatumWithRawSnapshot(builder.withStatisticSet, metricName, snapshot, StandardUnit.None, metricData);
    }
}
项目:codahale-aggregated-metrics-cloudwatch-reporter    文件:CloudWatchReporter.java   
private void stageMetricDatumWithConvertedSnapshot(final boolean metricConfigured,
                                                   final String metricName,
                                                   final Snapshot snapshot,
                                                   final StandardUnit standardUnit,
                                                   final List<MetricDatum> metricData) {
    if (metricConfigured) {
        double scaledSum = convertDuration(LongStream.of(snapshot.getValues()).sum());
        final StatisticSet statisticSet = new StatisticSet()
                .withSum(scaledSum)
                .withSampleCount((double) snapshot.size())
                .withMinimum(convertDuration(snapshot.getMin()))
                .withMaximum(convertDuration(snapshot.getMax()));

        final Set<Dimension> dimensions = new LinkedHashSet<>(builder.globalDimensions);
        dimensions.add(new Dimension().withName(DIMENSION_NAME_TYPE).withValue(DIMENSION_SNAPSHOT_SUMMARY));

        metricData.add(new MetricDatum()
                .withTimestamp(new Date(builder.clock.getTime()))
                .withMetricName(metricName)
                .withDimensions(dimensions)
                .withStatisticValues(statisticSet)
                .withUnit(standardUnit));
    }
}
项目:codahale-aggregated-metrics-cloudwatch-reporter    文件:CloudWatchReporter.java   
private void stageMetricDatumWithRawSnapshot(final boolean metricConfigured,
                                             final String metricName,
                                             final Snapshot snapshot,
                                             final StandardUnit standardUnit,
                                             final List<MetricDatum> metricData) {
    if (metricConfigured) {
        double total = LongStream.of(snapshot.getValues()).sum();
        final StatisticSet statisticSet = new StatisticSet()
                .withSum(total)
                .withSampleCount((double) snapshot.size())
                .withMinimum((double) snapshot.getMin())
                .withMaximum((double) snapshot.getMax());

        final Set<Dimension> dimensions = new LinkedHashSet<>(builder.globalDimensions);
        dimensions.add(new Dimension().withName(DIMENSION_NAME_TYPE).withValue(DIMENSION_SNAPSHOT_SUMMARY));

        metricData.add(new MetricDatum()
                .withTimestamp(new Date(builder.clock.getTime()))
                .withMetricName(metricName)
                .withDimensions(dimensions)
                .withStatisticValues(statisticSet)
                .withUnit(standardUnit));
    }
}
项目:Availability-Monitor-for-Kafka    文件:StatsdReporter.java   
private void reportHistogram(String name, Histogram histogram) throws IOException {
    final Snapshot snapshot = histogram.getSnapshot();
    statsdClient.send(prefix(name, "count"),
            format(histogram.getCount()),
            StatsdClient.StatType.GAUGE);
    statsdClient.send(prefix(name, "max"),
            format(snapshot.getMax()),
            StatsdClient.StatType.TIMER);
    statsdClient.send(prefix(name, "mean"),
            format(snapshot.getMean()),
            StatsdClient.StatType.TIMER);

    statsdClient.send(prefix(name, "p95"),
            format(snapshot.get95thPercentile()),
            StatsdClient.StatType.TIMER);

}
项目:monitoring-center    文件:GraphiteMetricFormatter.java   
private String formatSamplingSnapshot(String name, Snapshot snapshot, long timestamp, boolean convertValuesToDurations) {
    StringBuilder outputBuilder = new StringBuilder();

    outputBuilder.append(formatLine(MetricNamingUtil.join(name, "max"), convertValuesToDurations ? convertDuration(snapshot.getMax()) : snapshot.getMax(), timestamp));
    outputBuilder.append(formatLine(MetricNamingUtil.join(name, "mean"), convertValuesToDurations ? convertDuration(snapshot.getMean()) : snapshot.getMean(), timestamp));
    outputBuilder.append(formatLine(MetricNamingUtil.join(name, "min"), convertValuesToDurations ? convertDuration(snapshot.getMin()) : snapshot.getMin(), timestamp));
    outputBuilder.append(formatLine(MetricNamingUtil.join(name, "stddev"), convertValuesToDurations ? convertDuration(snapshot.getStdDev()) : snapshot.getStdDev(), timestamp));
    outputBuilder.append(formatLine(MetricNamingUtil.join(name, "p50"), convertValuesToDurations ? convertDuration(snapshot.getMedian()) : snapshot.getMedian(), timestamp));
    outputBuilder.append(formatLine(MetricNamingUtil.join(name, "p75"), convertValuesToDurations ? convertDuration(snapshot.get75thPercentile()) : snapshot.get75thPercentile(), timestamp));
    outputBuilder.append(formatLine(MetricNamingUtil.join(name, "p95"), convertValuesToDurations ? convertDuration(snapshot.get95thPercentile()) : snapshot.get95thPercentile(), timestamp));
    outputBuilder.append(formatLine(MetricNamingUtil.join(name, "p98"), convertValuesToDurations ? convertDuration(snapshot.get98thPercentile()) : snapshot.get98thPercentile(), timestamp));
    outputBuilder.append(formatLine(MetricNamingUtil.join(name, "p99"), convertValuesToDurations ? convertDuration(snapshot.get99thPercentile()) : snapshot.get99thPercentile(), timestamp));
    outputBuilder.append(formatLine(MetricNamingUtil.join(name, "p999"), convertValuesToDurations ? convertDuration(snapshot.get999thPercentile()) : snapshot.get999thPercentile(), timestamp));

    return outputBuilder.toString();
}
项目:microbule    文件:MetricsGsonBuilderCustomizer.java   
@Override
public JsonElement serialize(Timer timer, Type typeOfSrc, JsonSerializationContext context) {
    JsonObject json = new JsonObject();
    final Snapshot snapshot = timer.getSnapshot();
    json.addProperty("count", timer.getCount());
    json.addProperty("max", snapshot.getMax() * DURATION_FACTOR);
    json.addProperty("mean", snapshot.getMean() * DURATION_FACTOR);
    json.addProperty("min", snapshot.getMin() * DURATION_FACTOR);

    json.addProperty("p50", snapshot.getMedian() * DURATION_FACTOR);
    json.addProperty("p75", snapshot.get75thPercentile() * DURATION_FACTOR);
    json.addProperty("p95", snapshot.get95thPercentile() * DURATION_FACTOR);
    json.addProperty("p98", snapshot.get98thPercentile() * DURATION_FACTOR);
    json.addProperty("p99", snapshot.get99thPercentile() * DURATION_FACTOR);
    json.addProperty("p999", snapshot.get999thPercentile() * DURATION_FACTOR);

    json.addProperty("stddev", snapshot.getStdDev() * DURATION_FACTOR);
    json.addProperty("m15_rate", timer.getFifteenMinuteRate());
    json.addProperty("m1_rate", timer.getOneMinuteRate());
    json.addProperty("m5_rate", timer.getFiveMinuteRate());
    json.addProperty("mean_rate", timer.getMeanRate());
    json.addProperty("duration_units", "seconds");
    json.addProperty("rate_units", "calls/second");
    return json;
}
项目:dropwizard-hadoop-metrics2    文件:HadoopMetrics2Reporter.java   
/**
 * Add Dropwizard-Metrics value-distribution data to a Hadoop-Metrics2 record building, converting
 * the durations to the appropriate unit.
 *
 * @param builder A Hadoop-Metrics2 record builder.
 * @param name A base name for this record.
 * @param desc A description for this record.
 * @param snapshot The distribution of measured values.
 */
private void addSnapshot(MetricsRecordBuilder builder, String name, String desc,
    Snapshot snapshot) {
  builder.addGauge(Interns.info(name + "_mean", desc), convertDuration(snapshot.getMean()));
  builder.addGauge(Interns.info(name + "_min", desc), convertDuration(snapshot.getMin()));
  builder.addGauge(Interns.info(name + "_max", desc), convertDuration(snapshot.getMax()));
  builder.addGauge(Interns.info(name + "_median", desc), convertDuration(snapshot.getMedian()));
  builder.addGauge(Interns.info(name + "_stddev", desc), convertDuration(snapshot.getStdDev()));

  builder.addGauge(Interns.info(name + "_75thpercentile", desc),
      convertDuration(snapshot.get75thPercentile()));
  builder.addGauge(Interns.info(name + "_95thpercentile", desc),
      convertDuration(snapshot.get95thPercentile()));
  builder.addGauge(Interns.info(name + "_98thpercentile", desc),
      convertDuration(snapshot.get98thPercentile()));
  builder.addGauge(Interns.info(name + "_99thpercentile", desc),
      convertDuration(snapshot.get99thPercentile()));
  builder.addGauge(Interns.info(name + "_999thpercentile", desc),
      convertDuration(snapshot.get999thPercentile()));
}
项目:flink    文件:DropwizardFlinkHistogramWrapperTest.java   
Future<Snapshot> getNextHistogramSnapshot(String name) {
    synchronized (histogramSnapshotFutures) {
        List<CompletableFuture<Snapshot>> futures;
        if (histogramSnapshotFutures.containsKey(name)) {
            futures = histogramSnapshotFutures.get(name);
        } else {
            futures = new ArrayList<>();
            histogramSnapshotFutures.put(name, futures);
        }

        CompletableFuture<Snapshot> future = new CompletableFuture<>();
        futures.add(future);

        return future;
    }
}
项目:raml-module-builder    文件:StatsTracker.java   
public static JsonObject calculateStatsFor(String type){
  JsonObject j = new JsonObject();
  Snapshot snap = METRICS.histogram(type).getSnapshot();
  if(snap != null){
    j.put("entryCount", snap.size());
    j.put("min", snap.getMin());
    j.put("max", snap.getMax());
    j.put("mean", snap.getMean());
    j.put("median", snap.getMedian());
    j.put("75th", snap.get75thPercentile());
    j.put("95th", snap.get95thPercentile());
    j.put("99th", snap.get99thPercentile());
    j.put("stdDev", snap.getStdDev());
  }
  return j;
}
项目:graylog-plugin-anonymous-usage-statistics    文件:Histogram.java   
public static Histogram fromMetricsTimer(com.codahale.metrics.Timer timer) {
    final Snapshot snapshot = timer.getSnapshot();
    return create(
            timer.getCount(),
            snapshot.getMin(),
            snapshot.getMax(),
            snapshot.getMean(),
            snapshot.getMedian(),
            snapshot.get75thPercentile(),
            snapshot.get95thPercentile(),
            snapshot.get98thPercentile(),
            snapshot.get99thPercentile(),
            snapshot.get999thPercentile(),
            snapshot.getStdDev()
    );
}
项目:graylog-plugin-anonymous-usage-statistics    文件:Histogram.java   
public static Histogram fromMetricsHistogram(com.codahale.metrics.Histogram histogram) {
    final Snapshot snapshot = histogram.getSnapshot();
    return create(
            histogram.getCount(),
            snapshot.getMin(),
            snapshot.getMax(),
            snapshot.getMean(),
            snapshot.getMedian(),
            snapshot.get75thPercentile(),
            snapshot.get95thPercentile(),
            snapshot.get98thPercentile(),
            snapshot.get99thPercentile(),
            snapshot.get999thPercentile(),
            snapshot.getStdDev()
    );
}
项目:dropwizard-metrics-influxdb    文件:InfluxDbReporter.java   
private void reportHistogram(String name, Histogram histogram, long now) {
    if (canSkipMetric(name, histogram)) {
        return;
    }
    final Snapshot snapshot = histogram.getSnapshot();
    Map<String, Object> fields = new HashMap<String, Object>();
    fields.put("count", histogram.getCount());
    fields.put("min", snapshot.getMin());
    fields.put("max", snapshot.getMax());
    fields.put("mean", snapshot.getMean());
    fields.put("stddev", snapshot.getStdDev());
    fields.put("p50", snapshot.getMedian());
    fields.put("p75", snapshot.get75thPercentile());
    fields.put("p95", snapshot.get95thPercentile());
    fields.put("p98", snapshot.get98thPercentile());
    fields.put("p99", snapshot.get99thPercentile());
    fields.put("p999", snapshot.get999thPercentile());

    influxDb.appendPoints(
        new InfluxDbPoint(
            getMeasurementName(name),
            getTags(name),
            now,
            fields));
}
项目:jstorm-0.9.6.3-    文件:StormMetricReporter.java   
private void logHistogram(String name, Histogram histogram) {
    final Snapshot snapshot = histogram.getSnapshot();
    logger.info(marker,
                "type=HISTOGRAM, name={}, count={}, min={}, max={}, mean={}, stddev={}, " +
                        "median={}, p75={}, p95={}, p98={}, p99={}, p999={}",
                name,
                histogram.getCount(),
                snapshot.getMin(),
                snapshot.getMax(),
                snapshot.getMean(),
                snapshot.getStdDev(),
                snapshot.getMedian(),
                snapshot.get75thPercentile(),
                snapshot.get95thPercentile(),
                snapshot.get98thPercentile(),
                snapshot.get99thPercentile(),
                snapshot.get999thPercentile());
}
项目:Gobblin    文件:InfluxDBReporter.java   
private void reportSnapshot(List<Serie> series, MetricContext context, String name, Snapshot snapshot,
    long timeStamp, boolean convertDuration) {
  series.add(buildSerie(context, name, Optional.of(Measurements.MIN), timeStamp,
      convertDuration ? convertDuration(snapshot.getMin()) : snapshot.getMin()));
  series.add(buildSerie(context, name, Optional.of(Measurements.MAX), timeStamp,
      convertDuration ? convertDuration(snapshot.getMax()) : snapshot.getMax()));
  series.add(buildSerie(context, name, Optional.of(Measurements.MEAN), timeStamp,
      convertDuration ? convertDuration(snapshot.getMean()) : snapshot.getMean()));
  series.add(buildSerie(context, name, Optional.of(Measurements.STDDEV), timeStamp,
      convertDuration ? convertDuration(snapshot.getStdDev()) : snapshot.getStdDev()));
  series.add(buildSerie(context, name, Optional.of(Measurements.MEDIAN), timeStamp,
      convertDuration ? convertDuration(snapshot.getMedian()) : snapshot.getMedian()));
  series.add(buildSerie(context, name, Optional.of(Measurements.PERCENTILE_75TH), timeStamp,
      convertDuration ? convertDuration(snapshot.get75thPercentile()) : snapshot.get75thPercentile()));
  series.add(buildSerie(context, name, Optional.of(Measurements.PERCENTILE_95TH), timeStamp,
      convertDuration ? convertDuration(snapshot.get95thPercentile()) : snapshot.get95thPercentile()));
  series.add(buildSerie(context, name, Optional.of(Measurements.PERCENTILE_98TH), timeStamp,
      convertDuration ? convertDuration(snapshot.get98thPercentile()) : snapshot.get98thPercentile()));
  series.add(buildSerie(context, name, Optional.of(Measurements.PERCENTILE_99TH), timeStamp,
      convertDuration ? convertDuration(snapshot.get99thPercentile()) : snapshot.get99thPercentile()));
  series.add(buildSerie(context, name, Optional.of(Measurements.PERCENTILE_999TH), timeStamp,
      convertDuration ? convertDuration(snapshot.get999thPercentile()) : snapshot.get999thPercentile()));
}
项目:Gobblin    文件:OutputStreamReporter.java   
private void printTimer(Timer timer) {
  final Snapshot snapshot = timer.getSnapshot();
  this.outputBufferPrintStream.printf(locale, "             count = %d%n", timer.getCount());
  this.outputBufferPrintStream.printf(locale, "         mean rate = %2.2f calls/%s%n", convertRate(timer.getMeanRate()), getRateUnit());
  this.outputBufferPrintStream.printf(locale, "     1-minute rate = %2.2f calls/%s%n", convertRate(timer.getOneMinuteRate()), getRateUnit());
  this.outputBufferPrintStream.printf(locale, "     5-minute rate = %2.2f calls/%s%n", convertRate(timer.getFiveMinuteRate()), getRateUnit());
  this.outputBufferPrintStream.printf(locale, "    15-minute rate = %2.2f calls/%s%n", convertRate(timer.getFifteenMinuteRate()), getRateUnit());

  this.outputBufferPrintStream.printf(locale, "               min = %2.2f %s%n", convertDuration(snapshot.getMin()), getDurationUnit());
  this.outputBufferPrintStream.printf(locale, "               max = %2.2f %s%n", convertDuration(snapshot.getMax()), getDurationUnit());
  this.outputBufferPrintStream.printf(locale, "              mean = %2.2f %s%n", convertDuration(snapshot.getMean()), getDurationUnit());
  this.outputBufferPrintStream.printf(locale, "            stddev = %2.2f %s%n", convertDuration(snapshot.getStdDev()), getDurationUnit());
  this.outputBufferPrintStream.printf(locale, "            median = %2.2f %s%n", convertDuration(snapshot.getMedian()), getDurationUnit());
  this.outputBufferPrintStream.printf(locale, "              75%% <= %2.2f %s%n", convertDuration(snapshot.get75thPercentile()), getDurationUnit());
  this.outputBufferPrintStream.printf(locale, "              95%% <= %2.2f %s%n", convertDuration(snapshot.get95thPercentile()), getDurationUnit());
  this.outputBufferPrintStream.printf(locale, "              98%% <= %2.2f %s%n", convertDuration(snapshot.get98thPercentile()), getDurationUnit());
  this.outputBufferPrintStream.printf(locale, "              99%% <= %2.2f %s%n", convertDuration(snapshot.get99thPercentile()), getDurationUnit());
  this.outputBufferPrintStream.printf(locale, "            99.9%% <= %2.2f %s%n", convertDuration(snapshot.get999thPercentile()), getDurationUnit());
}
项目:learn_jstorm    文件:StormMetricReporter.java   
private void logHistogram(String name, Histogram histogram) {
    final Snapshot snapshot = histogram.getSnapshot();
    logger.info(marker,
                "type=HISTOGRAM, name={}, count={}, min={}, max={}, mean={}, stddev={}, " +
                        "median={}, p75={}, p95={}, p98={}, p99={}, p999={}",
                        new Object[]{name,
                histogram.getCount(),
                snapshot.getMin(),
                snapshot.getMax(),
                snapshot.getMean(),
                snapshot.getStdDev(),
                snapshot.getMedian(),
                snapshot.get75thPercentile(),
                snapshot.get95thPercentile(),
                snapshot.get98thPercentile(),
                snapshot.get99thPercentile(),
                snapshot.get999thPercentile()});
}
项目:carbon-metrics    文件:DasReporter.java   
private void reportHistograms(final long timestamp, final SortedMap<String, Histogram> histograms) {
    Object[] meta = new Object[]{timestamp};
    for (Map.Entry<String, Histogram> entry : histograms.entrySet()) {
        String name = entry.getKey();
        Histogram histogram = entry.getValue();
        Snapshot snapshot = histogram.getSnapshot();
        Object[] payload = new Object[13];
        payload[0] = source;
        payload[1] = name;
        payload[2] = histogram.getCount();
        payload[3] = snapshot.getMax();
        payload[4] = snapshot.getMean();
        payload[5] = snapshot.getMin();
        payload[6] = snapshot.getStdDev();
        payload[7] = snapshot.getMedian();
        payload[8] = snapshot.get75thPercentile();
        payload[9] = snapshot.get95thPercentile();
        payload[10] = snapshot.get98thPercentile();
        payload[11] = snapshot.get99thPercentile();
        payload[12] = snapshot.get999thPercentile();
        Event event = new Event(HISTOGRAM_STREAM_ID, timestamp, meta, null, payload);
        dataPublisher.publish(event);
    }
}
项目:carbon-metrics    文件:JdbcReporter.java   
private void reportHistogram(final long timestamp, PreparedStatement ps, String name, Histogram histogram)
        throws SQLException {
    final Snapshot snapshot = histogram.getSnapshot();

    ps.setString(1, source);
    ps.setLong(2, timestamp);
    ps.setString(3, name);
    ps.setLong(4, histogram.getCount());
    ps.setDouble(5, snapshot.getMax());
    ps.setDouble(6, snapshot.getMean());
    ps.setDouble(7, snapshot.getMin());
    ps.setDouble(8, snapshot.getStdDev());
    ps.setDouble(9, snapshot.getMedian());
    ps.setDouble(10, snapshot.get75thPercentile());
    ps.setDouble(11, snapshot.get95thPercentile());
    ps.setDouble(12, snapshot.get98thPercentile());
    ps.setDouble(13, snapshot.get99thPercentile());
    ps.setDouble(14, snapshot.get999thPercentile());
}
项目:carbon-metrics    文件:JdbcReporter.java   
private void reportTimer(final long timestamp, PreparedStatement ps, String name, Timer timer) throws SQLException {
    final Snapshot snapshot = timer.getSnapshot();

    ps.setString(1, source);
    ps.setLong(2, timestamp);
    ps.setString(3, name);
    ps.setLong(4, timer.getCount());
    ps.setDouble(5, convertDuration(snapshot.getMax()));
    ps.setDouble(6, convertDuration(snapshot.getMean()));
    ps.setDouble(7, convertDuration(snapshot.getMin()));
    ps.setDouble(8, convertDuration(snapshot.getStdDev()));
    ps.setDouble(9, convertDuration(snapshot.getMedian()));
    ps.setDouble(10, convertDuration(snapshot.get75thPercentile()));
    ps.setDouble(11, convertDuration(snapshot.get95thPercentile()));
    ps.setDouble(12, convertDuration(snapshot.get98thPercentile()));
    ps.setDouble(13, convertDuration(snapshot.get99thPercentile()));
    ps.setDouble(14, convertDuration(snapshot.get999thPercentile()));
    ps.setDouble(15, convertRate(timer.getMeanRate()));
    ps.setDouble(16, convertRate(timer.getOneMinuteRate()));
    ps.setDouble(17, convertRate(timer.getFiveMinuteRate()));
    ps.setDouble(18, convertRate(timer.getFifteenMinuteRate()));
    ps.setString(19, String.format("calls/%s", getRateUnit()));
    ps.setString(20, getDurationUnit());
}
项目:heroic    文件:MinMaxSlidingTimeReservoirTest.java   
@Test
public void testMinMaxCalculation1Step() {

    reservoir.update(200L);
    reservoir.update(-200L);

    // jump forward 1 step in time, but not enough to drop values
    clock.set(STEP * 1);

    reservoir.update(100L);
    reservoir.update(-100L);

    final Snapshot snapshot = reservoir.getSnapshot();

    assertArrayEquals(new long[]{-200L, 1L, 200L}, snapshot.getValues());
    assertEquals(-200L, snapshot.getMin());
    assertEquals(200L, snapshot.getMax());
}
项目:heroic    文件:MinMaxSlidingTimeReservoirTest.java   
@Test
public void testMinMaxCalculation2Step() {

    reservoir.update(200L);
    reservoir.update(-200L);

    // jump forward 2 steps in time, but not enough to drop values
    clock.set(STEP * 2);

    reservoir.update(100L);
    reservoir.update(-100L);

    final Snapshot snapshot = reservoir.getSnapshot();

    assertArrayEquals(new long[]{-200L, 1L, 200L}, snapshot.getValues());
    assertEquals(-200L, snapshot.getMin());
    assertEquals(200L, snapshot.getMax());
}
项目:heroic    文件:MinMaxSlidingTimeReservoirTest.java   
@Test
public void testMinMaxCalculationTrim() {

    reservoir.update(200L);
    reservoir.update(-200L);

    // jump forward size+1 steps in time, enough so that we drop values
    clock.set(STEP * (SIZE + 1));

    reservoir.update(100L);
    reservoir.update(-100L);

    final Snapshot snapshot = reservoir.getSnapshot();

    assertArrayEquals(new long[]{-100L, 1L, 100L}, snapshot.getValues());
    assertEquals(-100L, snapshot.getMin());
    assertEquals(100L, snapshot.getMax());
}
项目:alfresco-apache-storm-demo    文件:HistogramMetric.java   
public Object getValueAndReset() {
    final Map<String, Number> ret = new HashMap<String, Number>();

    for (Map.Entry<String, Histogram> entry : registry.getHistograms()
            .entrySet()) {
        String prefix = entry.getKey() + "/";
        Histogram histogram = entry.getValue();
        Snapshot snapshot = histogram.getSnapshot();

        ret.put(prefix + "count", histogram.getCount());
        ret.put(prefix + "max", snapshot.getMax());
        ret.put(prefix + "min", snapshot.getMin());
        ret.put(prefix + "stddev", snapshot.getStdDev());
        ret.put(prefix + "p50", snapshot.getMedian());
        ret.put(prefix + "p75", snapshot.get75thPercentile());
        ret.put(prefix + "p95", snapshot.get95thPercentile());
        ret.put(prefix + "p98", snapshot.get98thPercentile());
        ret.put(prefix + "p99", snapshot.get99thPercentile());
        ret.put(prefix + "p999", snapshot.get999thPercentile());

    }
    return ret;
}
项目:alfresco-apache-storm-demo    文件:TimerMetric.java   
public Object getValueAndReset() {
    final Map<String, Number> ret = new HashMap<String, Number>();

    for (Map.Entry<String, Timer> entry : registry.getTimers().entrySet()) {
        String prefix = entry.getKey() + "/";
        Timer timer = entry.getValue();
        Snapshot snapshot = timer.getSnapshot();

        ret.put(prefix + "count", timer.getCount());
        ret.put(prefix + "max", snapshot.getMax());
        ret.put(prefix + "mean", snapshot.getMean());
        ret.put(prefix + "min", snapshot.getMin());
        ret.put(prefix + "stddev", snapshot.getStdDev());
        ret.put(prefix + "p50", snapshot.getMedian());
        ret.put(prefix + "p75", snapshot.get75thPercentile());
        ret.put(prefix + "p95", snapshot.get95thPercentile());
        ret.put(prefix + "p98", snapshot.get98thPercentile());
        ret.put(prefix + "p99", snapshot.get99thPercentile());
        ret.put(prefix + "p999", snapshot.get999thPercentile());
        ret.put(prefix + "mean_rate", timer.getMeanRate());
        ret.put(prefix + "m1_rate", timer.getOneMinuteRate());
        ret.put(prefix + "m5_rate", timer.getFiveMinuteRate());
        ret.put(prefix + "m15_rate", timer.getFifteenMinuteRate());
    }
    return ret;
}
项目:Pinot    文件:AggregationStats.java   
private Map<String, Object> toMap(Histogram histogram) {
  Map<String, Object> map = new LinkedHashMap<String, Object>();
  Snapshot snapshot = histogram.getSnapshot();
  map.put("75th", format.format(snapshot.get75thPercentile()));
  map.put("95th", format.format(snapshot.get95thPercentile()));
  map.put("98th", format.format(snapshot.get98thPercentile()));
  map.put("99th", format.format(snapshot.get99thPercentile()));
  map.put("999th", format.format(snapshot.get999thPercentile()));
  map.put("Max", format.format(snapshot.getMax()));
  map.put("Min", format.format(snapshot.getMin()));
  map.put("StdDev", format.format(snapshot.getStdDev()));
  map.put("Mean", format.format(snapshot.getMean()));
  map.put("Median", format.format(snapshot.getMedian()));
  map.put("size", format.format(snapshot.size()));
  map.put("count", format.format(histogram.getCount()));
  return map;
}
项目:astrix    文件:DropwizardMetrics.java   
@Override
        public TimerSnaphot getSnapshot() {
            // Rates are are in seconds by default
            // Duration are in NANO_SECONDS
            TimeUnit rateUnit = TimeUnit.SECONDS;
            TimeUnit durationUnit = TimeUnit.MILLISECONDS;
            double durationFactor = 1.0 / durationUnit.toNanos(1);
//          double rateFactor = 1.0 / rateUnit.toSeconds(1);
            Snapshot snapshot = timer.getSnapshot();
            return TimerSnaphot.builder()
                               .count(timer.getCount())
                               .meanRate(timer.getMeanRate()) // No need to convert rate since its already in SECONDS 
                               .oneMinuteRate(timer.getOneMinuteRate()) // No need to convert rate since its already in SECONDS
                               .maxLatency(snapshot.getMax() * durationFactor)
                               .minLatency(snapshot.getMin() * durationFactor)
                               .set50thPercentileLatency(snapshot.getMedian() * durationFactor)
                               .set90thPercentileLatency(snapshot.getValue(0.9) * durationFactor)
                               .set99thPercentileLatency(snapshot.get99thPercentile() * durationFactor)
                               .rateUnit(rateUnit)
                               .durationUnit(durationUnit)
                               .build();
        }
项目:Tstream    文件:StormMetricReporter.java   
private void logHistogram(String name, Histogram histogram) {
    final Snapshot snapshot = histogram.getSnapshot();
    logger.info(marker,
                "type=HISTOGRAM, name={}, count={}, min={}, max={}, mean={}, stddev={}, " +
                        "median={}, p75={}, p95={}, p98={}, p99={}, p999={}",
                name,
                histogram.getCount(),
                snapshot.getMin(),
                snapshot.getMax(),
                snapshot.getMean(),
                snapshot.getStdDev(),
                snapshot.getMedian(),
                snapshot.get75thPercentile(),
                snapshot.get95thPercentile(),
                snapshot.get98thPercentile(),
                snapshot.get99thPercentile(),
                snapshot.get999thPercentile());
}
项目:cassandra-loader    文件:RateLimiter.java   
protected void printStats() {
    Snapshot snapshot = timer.getSnapshot();
    stream.println(String.format("%d,%d,%d,%.4f,%.4f,%.4f,%.4f,%.4f,%.4f,%.4f,%.4f,%.4f,%.4f,%.4f,%.4f",
                                 timer.getCount(),
                                 snapshot.getMin(),
                                 snapshot.getMax(),
                                 snapshot.getMean(),
                                 snapshot.getStdDev(),
                                 snapshot.getMedian(),
                                 snapshot.get75thPercentile(),
                                 snapshot.get95thPercentile(),
                                 snapshot.get98thPercentile(),
                                 snapshot.get99thPercentile(),
                                 snapshot.get999thPercentile(),
                                 timer.getMeanRate(),
                                 timer.getOneMinuteRate(),
                                 timer.getFiveMinuteRate(),
                                 timer.getFifteenMinuteRate())
                   );
}
项目:watcher    文件:TimerSerializer.java   
@Override
public void write(JSONSerializer serializer, Object object, Object fieldName, Type fieldType, int features) throws IOException {
    Timer timer = (Timer) object;
    final Snapshot snapshot = timer.getSnapshot();
    SerializeWriter writer = serializer.getWriter();
    writer.writeFieldValue('{', "count", timer.getCount());
    writer.writeFieldValue(',', "max", snapshot.getMax() * durationFactor);
    writer.writeFieldValue(',', "mean", snapshot.getMean() * durationFactor);
    writer.writeFieldValue(',', "min", snapshot.getMin() * durationFactor);

    writer.writeFieldValue(',', "p50", snapshot.getMedian() * durationFactor);
    writer.writeFieldValue(',', "p75", snapshot.get75thPercentile() * durationFactor);
    writer.writeFieldValue(',', "p95", snapshot.get95thPercentile() * durationFactor);
    writer.writeFieldValue(',', "p98", snapshot.get98thPercentile() * durationFactor);
    writer.writeFieldValue(',', "p99", snapshot.get99thPercentile() * durationFactor);
    writer.writeFieldValue(',', "p999", snapshot.get999thPercentile() * durationFactor);

    writer.writeFieldValue(',', "stddev", snapshot.getStdDev() * durationFactor);
    writer.writeFieldValue(',', "m15_rate", timer.getFifteenMinuteRate() * rateFactor);
    writer.writeFieldValue(',', "m1_rate", timer.getOneMinuteRate() * rateFactor);
    writer.writeFieldValue(',', "m5_rate", timer.getFiveMinuteRate() * rateFactor);
    writer.writeFieldValue(',', "mean_rate", timer.getMeanRate() * rateFactor);
    writer.writeFieldValue(',', "duration_units", durationUnit);
    writer.writeFieldValue(',', "rate_units", rateUnit);
    writer.write('}');
}
项目:watcher    文件:HistogramSerializer.java   
@Override
public void write(JSONSerializer serializer, Object object, Object fieldName, Type fieldType, int features) throws IOException {
    Histogram histogram = (Histogram) object;
    SerializeWriter writer = serializer.getWriter();
    final Snapshot snapshot = histogram.getSnapshot();
    writer.writeFieldValue('{', "count", histogram.getCount());
    writer.writeFieldValue(',', "max", snapshot.getMax());
    writer.writeFieldValue(',', "mean", snapshot.getMean());
    writer.writeFieldValue(',', "min", snapshot.getMin());
    writer.writeFieldValue(',', "p50", snapshot.getMedian());
    writer.writeFieldValue(',', "p75", snapshot.get75thPercentile());
    writer.writeFieldValue(',', "p95", snapshot.get95thPercentile());
    writer.writeFieldValue(',', "p98", snapshot.get98thPercentile());
    writer.writeFieldValue(',', "p99", snapshot.get99thPercentile());
    writer.writeFieldValue(',', "p999", snapshot.get999thPercentile());
    writer.writeFieldValue(',', "stddev", snapshot.getStdDev());
    writer.write('}');
}
项目:hawkular-agent    文件:JBossLoggingReporter.java   
private String logTimer(String name, Timer timer) {
    final Snapshot snapshot = timer.getSnapshot();
    return String.format(
            "%s: type=[timer], count=[%d], min=[%f], max=[%f], mean=[%f], stddev=[%f], median=[%f], " +
                    "p75=[%f], p95=[%f], p98=[%f], p99=[%f], p999=[%f], mean_rate=[%f], m1=[%f], m5=[%f], " +
                    "m15=[%f], rate_unit=[%s], duration_unit=[%s]",
            name,
            timer.getCount(),
            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()),
            convertRate(timer.getMeanRate()),
            convertRate(timer.getOneMinuteRate()),
            convertRate(timer.getFiveMinuteRate()),
            convertRate(timer.getFifteenMinuteRate()),
            getRateUnit(),
            getDurationUnit());
}