当前位置: 首页>>代码示例>>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;未经允许,请勿转载。