本文整理匯總了Java中com.codahale.metrics.Snapshot類的典型用法代碼示例。如果您正苦於以下問題:Java Snapshot類的具體用法?Java Snapshot怎麽用?Java Snapshot使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
Snapshot類屬於com.codahale.metrics包,在下文中一共展示了Snapshot類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getSnapshot
import com.codahale.metrics.Snapshot; //導入依賴的package包/類
/**
* 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();
}
}
示例2: reportSnapshot
import com.codahale.metrics.Snapshot; //導入依賴的package包/類
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()));
}
示例3: fromHistogram
import com.codahale.metrics.Snapshot; //導入依賴的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();
}
示例4: serialize
import com.codahale.metrics.Snapshot; //導入依賴的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();
}
示例5: reportTimer
import com.codahale.metrics.Snapshot; //導入依賴的package包/類
/** */
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());
}
示例6: reportHistogram
import com.codahale.metrics.Snapshot; //導入依賴的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());
}
示例7: writeSnapshotAndCount
import com.codahale.metrics.Snapshot; //導入依賴的package包/類
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);
}
示例8: reportHistogram
import com.codahale.metrics.Snapshot; //導入依賴的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());
}
}
示例9: processTimer
import com.codahale.metrics.Snapshot; //導入依賴的package包/類
/**
* 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);
}
}
開發者ID:azagniotov,項目名稱:codahale-aggregated-metrics-cloudwatch-reporter,代碼行數:35,代碼來源:CloudWatchReporter.java
示例10: processHistogram
import com.codahale.metrics.Snapshot; //導入依賴的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
示例11: stageMetricDatumWithConvertedSnapshot
import com.codahale.metrics.Snapshot; //導入依賴的package包/類
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));
}
}
開發者ID:azagniotov,項目名稱:codahale-aggregated-metrics-cloudwatch-reporter,代碼行數:25,代碼來源:CloudWatchReporter.java
示例12: stageMetricDatumWithRawSnapshot
import com.codahale.metrics.Snapshot; //導入依賴的package包/類
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));
}
}
開發者ID:azagniotov,項目名稱:codahale-aggregated-metrics-cloudwatch-reporter,代碼行數:25,代碼來源:CloudWatchReporter.java
示例13: reportHistogram
import com.codahale.metrics.Snapshot; //導入依賴的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);
}
示例14: formatSamplingSnapshot
import com.codahale.metrics.Snapshot; //導入依賴的package包/類
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();
}
示例15: serialize
import com.codahale.metrics.Snapshot; //導入依賴的package包/類
@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;
}