當前位置: 首頁>>代碼示例>>Java>>正文


Java Histogram.getSnapshot方法代碼示例

本文整理匯總了Java中com.codahale.metrics.Histogram.getSnapshot方法的典型用法代碼示例。如果您正苦於以下問題:Java Histogram.getSnapshot方法的具體用法?Java Histogram.getSnapshot怎麽用?Java Histogram.getSnapshot使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.codahale.metrics.Histogram的用法示例。


在下文中一共展示了Histogram.getSnapshot方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: fromHistogram

import com.codahale.metrics.Histogram; //導入方法依賴的package包/類
/**
 * 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();
}
 
開發者ID:kickstarter,項目名稱:dropwizard-influxdb-reporter,代碼行數:26,代碼來源:DropwizardTransformer.java

示例2: serialize

import com.codahale.metrics.Histogram; //導入方法依賴的package包/類
@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();
}
 
開發者ID:oneops,項目名稱:oneops,代碼行數:26,代碼來源:MetricsElasticsearchModule.java

示例3: reportHistogram

import com.codahale.metrics.Histogram; //導入方法依賴的package包/類
/** */
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());
}
 
開發者ID:epam,項目名稱:Lagerta,代碼行數:22,代碼來源:HumanReadableCsvReporter.java

示例4: reportHistogram

import com.codahale.metrics.Histogram; //導入方法依賴的package包/類
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());
	}

}
 
開發者ID:ibmruntimes,項目名稱:spelk,代碼行數:27,代碼來源:ElasticsearchReporter.java

示例5: processHistogram

import com.codahale.metrics.Histogram; //導入方法依賴的package包/類
/**
 * 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);
    }
}
 
開發者ID:azagniotov,項目名稱:codahale-aggregated-metrics-cloudwatch-reporter,代碼行數:32,代碼來源:CloudWatchReporter.java

示例6: reportHistogram

import com.codahale.metrics.Histogram; //導入方法依賴的package包/類
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);

}
 
開發者ID:Microsoft,項目名稱:Availability-Monitor-for-Kafka,代碼行數:18,代碼來源:StatsdReporter.java

示例7: BasicMetricsContext

import com.codahale.metrics.Histogram; //導入方法依賴的package包/類
public BasicMetricsContext(
	final String stepId, final IoType ioType, final IntSupplier actualConcurrencyGauge,
	final int driverCount, final int concurrency, final int thresholdConcurrency,
	final SizeInBytes itemDataSize, final int updateIntervalSec, final boolean stdOutColorFlag,
	final boolean avgPersistFlag, final boolean sumPersistFlag,
	final boolean perfDbResultsFileFlag
) {
	this.stepId = stepId;
	this.ioType = ioType;
	this.actualConcurrencyGauge = actualConcurrencyGauge;
	this.driverCount = driverCount;
	this.concurrency = concurrency;
	this.thresholdConcurrency = thresholdConcurrency > 0 ?
		thresholdConcurrency : Integer.MAX_VALUE;
	this.itemDataSize = itemDataSize;

	this.stdOutColorFlag = stdOutColorFlag;
	this.avgPersistFlag = avgPersistFlag;
	this.sumPersistFlag = sumPersistFlag;
	this.perfDbResultsFileFlag = perfDbResultsFileFlag;
	this.outputPeriodMillis = TimeUnit.SECONDS.toMillis(updateIntervalSec);

	respLatency = new Histogram(new SlidingWindowReservoir(DEFAULT_RESERVOIR_SIZE));
	respLatSnapshot = respLatency.getSnapshot();
	respLatencySum = new LongAdder();
	reqDuration = new Histogram(new SlidingWindowReservoir(DEFAULT_RESERVOIR_SIZE));
	reqDurSnapshot = reqDuration.getSnapshot();
	actualConcurrency = new Histogram(new SlidingWindowReservoir(DEFAULT_RESERVOIR_SIZE));
	actualConcurrencySnapshot = actualConcurrency.getSnapshot();
	reqDurationSum = new LongAdder();
	throughputSuccess = new CustomMeter(clock, updateIntervalSec);
	throughputFail = new CustomMeter(clock, updateIntervalSec);
	reqBytes = new CustomMeter(clock, updateIntervalSec);
	ts = System.nanoTime();
}
 
開發者ID:emc-mongoose,項目名稱:mongoose-base,代碼行數:36,代碼來源:BasicMetricsContext.java

示例8: reportHistogram

import com.codahale.metrics.Histogram; //導入方法依賴的package包/類
private void reportHistogram(String name, Histogram histogram, long timestamp, List<String> tags)
    throws IOException {
  final Snapshot snapshot = histogram.getSnapshot();

  if(histogram instanceof HistImplContainer) {
    HistImpl take = ((HistImplContainer)histogram).getHistImpl().copyAndReset();
    LOG.debug("Adding Circonus Histogram to report: " + name);
    request.addHistogram(new CirconusHistogram(
          name, take, timestamp, host, tags));
    if(suppress_bad_analytics) return;
  }

  if (expansions.contains(Expansion.COUNT)) {
    request.addGauge(new CirconusGauge(
        appendExpansionSuffix(name, Expansion.COUNT),
        histogram.getCount(),
        timestamp,
        host,
        tags));
  }

  Number[] values = { snapshot.getMax(), snapshot.getMean(), snapshot.getMin(), snapshot.getStdDev(),
      snapshot.getMedian(), snapshot.get75thPercentile(), snapshot.get95thPercentile(), snapshot.get98thPercentile(),
      snapshot.get99thPercentile(), snapshot.get999thPercentile() };

  for (int i = 0; i < STATS_EXPANSIONS.length; i++) {
    if (expansions.contains(STATS_EXPANSIONS[i])) {
      request.addGauge(new CirconusGauge(
          appendExpansionSuffix(name, STATS_EXPANSIONS[i]),
          toNumber(values[i]),
          timestamp,
          host,
          tags));
    }
  }
}
 
開發者ID:circonus-labs,項目名稱:metrics-circonus,代碼行數:37,代碼來源:CirconusReporter.java

示例9: formatHistogram

import com.codahale.metrics.Histogram; //導入方法依賴的package包/類
private String formatHistogram(String name, Histogram histogram, long timestamp) {
    final Snapshot snapshot = histogram.getSnapshot();

    StringBuilder outputBuilder = new StringBuilder();

    outputBuilder.append(formatLine(MetricNamingUtil.join(name, "count"), histogram.getCount(), timestamp));
    outputBuilder.append(formatSamplingSnapshot(name, snapshot, timestamp, false));

    return outputBuilder.toString();
}
 
開發者ID:centro,項目名稱:monitoring-center,代碼行數:11,代碼來源:GraphiteMetricFormatter.java


注:本文中的com.codahale.metrics.Histogram.getSnapshot方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。