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


Java Timer.getSnapshot方法代碼示例

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


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

示例1: reportTimer

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

示例2: fromTimer

import com.codahale.metrics.Timer; //導入方法依賴的package包/類
/**
 * Build an {@link InfluxDbMeasurement} from a timer.
 */
@VisibleForTesting InfluxDbMeasurement fromTimer(final String metricName, final Timer t, final long timestamp) {
  final Snapshot snapshot = t.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", convertDuration(snapshot.getMin()))
    .putField("max", convertDuration(snapshot.getMax()))
    .putField("mean", convertDuration(snapshot.getMean()))
    .putField("std-dev", convertDuration(snapshot.getStdDev()))
    .putField("50-percentile", convertDuration(snapshot.getMedian()))
    .putField("75-percentile", convertDuration(snapshot.get75thPercentile()))
    .putField("95-percentile", convertDuration(snapshot.get95thPercentile()))
    .putField("99-percentile", convertDuration(snapshot.get99thPercentile()))
    .putField("999-percentile", convertDuration(snapshot.get999thPercentile()))
    .putField("one-minute", convertRate(t.getOneMinuteRate()))
    .putField("five-minute", convertRate(t.getFiveMinuteRate()))
    .putField("fifteen-minute", convertRate(t.getFifteenMinuteRate()))
    .putField("mean-minute", convertRate(t.getMeanRate()))
    .putField("run-count", t.getCount())
    .build();
}
 
開發者ID:kickstarter,項目名稱:dropwizard-influxdb-reporter,代碼行數:30,代碼來源:DropwizardTransformer.java

示例3: calculateNewRateLimit

import com.codahale.metrics.Timer; //導入方法依賴的package包/類
private static double calculateNewRateLimit(Timer commitTimer, long commitTimeoutInSeconds) {
    if (commitTimer == null) {
        // This can happen in unit tests.
        return 0;
    }

    Snapshot timerSnapshot = commitTimer.getSnapshot();
    double newRateLimit = 0;

    long commitTimeoutInNanos = TimeUnit.SECONDS.toNanos(commitTimeoutInSeconds);

    // Find the time that it takes for transactions to get executed in every 10th percentile
    // Compute the rate limit for that percentile and sum it up
    for (int i = 1; i <= 10; i++) {
        // Get the amount of time transactions take in the i*10th percentile
        double percentileTimeInNanos = timerSnapshot.getValue(i * 0.1D);

        if (percentileTimeInNanos > 0) {
            // Figure out the rate limit for the i*10th percentile in nanos
            double percentileRateLimit = commitTimeoutInNanos / percentileTimeInNanos;

            // Add the percentileRateLimit to the total rate limit
            newRateLimit += percentileRateLimit;
        }
    }

    // Compute the rate limit per second
    return newRateLimit / (commitTimeoutInSeconds * 10);
}
 
開發者ID:hashsdn,項目名稱:hashsdn-controller,代碼行數:30,代碼來源:TransactionRateLimiter.java

示例4: serialize

import com.codahale.metrics.Timer; //導入方法依賴的package包/類
@Override
public void serialize(JsonTimer jsonTimer,
                      JsonGenerator json,
                      SerializerProvider provider) throws IOException {
    json.writeStartObject();
    json.writeStringField("name", jsonTimer.name());
    json.writeObjectField(timestampFieldname, jsonTimer.timestampAsDate());
    Timer timer = jsonTimer.value();
    final Snapshot snapshot = timer.getSnapshot();
    json.writeNumberField("count", timer.getCount());
    json.writeNumberField("max", snapshot.getMax() * durationFactor);
    json.writeNumberField("mean", snapshot.getMean() * durationFactor);
    json.writeNumberField("min", snapshot.getMin() * durationFactor);

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

    /*
    if (showSamples) {
        final long[] values = snapshot.getValues();
        final double[] scaledValues = new double[values.length];
        for (int i = 0; i < values.length; i++) {
            scaledValues[i] = values[i] * durationFactor;
        }
        json.writeObjectField("values", scaledValues);
    }
    */

    json.writeNumberField("stddev", snapshot.getStdDev() * durationFactor);
    json.writeNumberField("m1_rate", timer.getOneMinuteRate() * rateFactor);
    json.writeNumberField("m5_rate", timer.getFiveMinuteRate() * rateFactor);
    json.writeNumberField("m15_rate", timer.getFifteenMinuteRate() * rateFactor);
    json.writeNumberField("mean_rate", timer.getMeanRate() * rateFactor);
    json.writeStringField("duration_units", durationUnit);
    json.writeStringField("rate_units", rateUnit);
    addOneOpsMetadata(json);
    json.writeEndObject();
}
 
開發者ID:oneops,項目名稱:oneops,代碼行數:43,代碼來源:MetricsElasticsearchModule.java


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