本文整理汇总了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();
}
示例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();
}
示例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());
}
示例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());
}
}
示例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);
}
示例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();
}
示例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));
}
}
}
示例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();
}