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


Java Snapshot.size方法代碼示例

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


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

示例1: 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

示例2: 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

示例3: reportTimer

import com.codahale.metrics.Snapshot; //導入方法依賴的package包/類
private void reportTimer(String name, Timer timer, long timestamp) {
	if (canSkipMetric(name, timer)) {
		return;
	}
	final Snapshot snapshot = timer.getSnapshot();
	Object[] p = pointsTimer[0];
	p[0] = influxdb.convertTimestamp(timestamp);
	p[1] = snapshot.size();
	p[2] = convertDuration(snapshot.getMin());
	p[3] = convertDuration(snapshot.getMax());
	p[4] = convertDuration(snapshot.getMean());
	p[5] = convertDuration(snapshot.getStdDev());
	p[6] = convertDuration(snapshot.getMedian());
	p[7] = convertDuration(snapshot.get75thPercentile());
	p[8] = convertDuration(snapshot.get95thPercentile());
	p[9] = convertDuration(snapshot.get99thPercentile());
	p[10] = convertDuration(snapshot.get999thPercentile());
	p[11] = convertRate(timer.getOneMinuteRate());
	p[12] = convertRate(timer.getFiveMinuteRate());
	p[13] = convertRate(timer.getFifteenMinuteRate());
	p[14] = convertRate(timer.getMeanRate());
	p[15] = timer.getCount();
	assert (p.length == COLUMNS_TIMER.length);
	influxdb.appendSeries(prefix, name, ".timer", COLUMNS_TIMER, pointsTimer);
}
 
開發者ID:davidB,項目名稱:metrics-influxdb,代碼行數:26,代碼來源:ReporterV08.java

示例4: reportHistogram

import com.codahale.metrics.Snapshot; //導入方法依賴的package包/類
private void reportHistogram(String name, Histogram histogram, long timestamp) {
	if (canSkipMetric(name, histogram)) {
		return;
	}
	final Snapshot snapshot = histogram.getSnapshot();
	Object[] p = pointsHistogram[0];
	p[0] = influxdb.convertTimestamp(timestamp);
	p[1] = snapshot.size();
	p[2] = snapshot.getMin();
	p[3] = snapshot.getMax();
	p[4] = snapshot.getMean();
	p[5] = snapshot.getStdDev();
	p[6] = snapshot.getMedian();
	p[7] = snapshot.get75thPercentile();
	p[8] = snapshot.get95thPercentile();
	p[9] = snapshot.get99thPercentile();
	p[10] = snapshot.get999thPercentile();
	p[11] = histogram.getCount();
	assert (p.length == COLUMNS_HISTOGRAM.length);
	influxdb.appendSeries(prefix, name, ".histogram", COLUMNS_HISTOGRAM, pointsHistogram);
}
 
開發者ID:davidB,項目名稱:metrics-influxdb,代碼行數:22,代碼來源:ReporterV08.java

示例5: serialise

import com.codahale.metrics.Snapshot; //導入方法依賴的package包/類
public MetricsHistogram serialise(String name, Histogram histo)
{
	Snapshot snapshot = histo.getSnapshot();
	final long count = histo.getCount();
	return new MetricsHistogram(name,
	                            count,
	                            snapshot.size(),
	                            snapshot.getMin(),
	                            snapshot.getMax(),
	                            snapshot.getStdDev(),
	                            snapshot.getMean(),
	                            snapshot.getMedian(),
	                            snapshot.get75thPercentile(),
	                            snapshot.get95thPercentile(),
	                            snapshot.get98thPercentile(),
	                            snapshot.get99thPercentile(),
	                            snapshot.get999thPercentile());
}
 
開發者ID:petergeneric,項目名稱:stdlib,代碼行數:19,代碼來源:MetricSerialiser.java

示例6: reportTimer

import com.codahale.metrics.Snapshot; //導入方法依賴的package包/類
private void reportTimer(String key, Collection<MetricDatum> data, Map.Entry<String, Timer> met) {
    Timer timer = met.getValue();
    Snapshot snapshot = timer.getSnapshot();
    if (reportAggregates) {
        reportAggregate(key, data, "count", null, timer.getCount());
        reportAggregate(key, data, "rate", "1minute", timer.getOneMinuteRate());
        reportAggregate(key, data, "rate", "5minute", timer.getFiveMinuteRate());
        reportAggregate(key, data, "rate", "15minute", timer.getFifteenMinuteRate());
        reportAggregate(key, data, "rate", "mean", timer.getMeanRate());
        reportSnapshot(data, snapshot, key);
    } else {
        // if no data, don't bother Amazon with it.
        if (snapshot.size() == 0) {
            return;
        }
        double sum = 0;
        for (double val : snapshot.getValues()) {
            sum += val;
        }
        // Metrics works in Nanoseconds, which is not one of Amazon's favorites.
        double max = (double) TimeUnit.NANOSECONDS.toMicros(snapshot.getMax());
        double min = (double) TimeUnit.NANOSECONDS.toMicros(snapshot.getMin());
        double sumMicros = TimeUnit.NANOSECONDS.toMicros((long) sum);
        StatisticSet stats = new StatisticSet()
                .withMaximum(max)
                .withMinimum(min)
                .withSum(sumMicros)
                .withSampleCount((double) snapshot.getValues().length);
        if (LOG.isDebugEnabled()) {
            LOG.debug("timer {}: {}", met.getKey(), stats);
        }
        data.add(new MetricDatum().withMetricName(met.getKey())
                .withDimensions(dimensions)
                .withStatisticValues(stats)
                .withUnit(StandardUnit.Microseconds));
    }
}
 
開發者ID:basis-technology-corp,項目名稱:metrics-cloudwatch-reporter,代碼行數:38,代碼來源:CloudWatchReporter.java

示例7: reportHistogram

import com.codahale.metrics.Snapshot; //導入方法依賴的package包/類
private void reportHistogram(Collection<MetricDatum> data, Map.Entry<String, Histogram> meh) {
    Snapshot snapshot = meh.getValue().getSnapshot();

    if (reportAggregates) {
        String key = meh.getKey();
        reportSnapshot(data, snapshot, key);
    } else {
        // if no data, don't bother Amazon with it.
        if (snapshot.size() == 0) {
            return;
        }
        double sum = 0;
        for (double val : snapshot.getValues()) {
            sum += val;
        }
        StatisticSet stats = new StatisticSet().withMaximum((double) snapshot.getMax())
                .withMinimum((double) snapshot.getMin())
                .withSum(sum)
                .withSampleCount((double) snapshot.getValues().length);
        if (LOG.isDebugEnabled()) {
            LOG.debug("histogram {}: {}", meh.getKey(), stats);
        }
        data.add(new MetricDatum().withMetricName(meh.getKey())
                .withDimensions(dimensions)
                .withStatisticValues(stats));
    }
}
 
開發者ID:basis-technology-corp,項目名稱:metrics-cloudwatch-reporter,代碼行數:28,代碼來源:CloudWatchReporter.java


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