本文整理汇总了Java中com.codahale.metrics.Metered类的典型用法代码示例。如果您正苦于以下问题:Java Metered类的具体用法?Java Metered怎么用?Java Metered使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Metered类属于com.codahale.metrics包,在下文中一共展示了Metered类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: reportMetered
import com.codahale.metrics.Metered; //导入依赖的package包/类
private void reportMetered(String name, Metered meter, long timestamp, List<String> tags)
throws IOException {
if (expansions.contains(Expansion.COUNT)) {
request.addGauge(new CirconusGauge(
appendExpansionSuffix(name, Expansion.COUNT),
meter.getCount(),
timestamp,
host,
tags));
}
double[] values = { meter.getOneMinuteRate(), meter.getFiveMinuteRate(),
meter.getFifteenMinuteRate(), meter.getMeanRate() };
for (int i = 0; i < RATE_EXPANSIONS.length; i++) {
if (expansions.contains(RATE_EXPANSIONS[i])) {
request.addGauge(new CirconusGauge(
appendExpansionSuffix(name, RATE_EXPANSIONS[i]),
toNumber(convertRate(values[i])),
timestamp,
host,
tags));
}
}
}
示例2: reportMeter
import com.codahale.metrics.Metered; //导入依赖的package包/类
private void reportMeter(String name, Metered meter, long now) {
if (canSkipMetric(name, meter)) {
return;
}
Map<String, Object> fields = new HashMap<String, Object>();
fields.put("count", meter.getCount());
fields.put("m1_rate", convertRate(meter.getOneMinuteRate()));
fields.put("m5_rate", convertRate(meter.getFiveMinuteRate()));
fields.put("m15_rate", convertRate(meter.getFifteenMinuteRate()));
fields.put("mean_rate", convertRate(meter.getMeanRate()));
if (includeMeterFields != null) {
fields.keySet().retainAll(includeMeterFields);
}
influxDb.appendPoints(
new InfluxDbPoint(
getMeasurementName(name),
getTags(name),
now,
fields));
}
示例3: reportMetered
import com.codahale.metrics.Metered; //导入依赖的package包/类
private void reportMetered(MetricContext context, String name, Metered metered, long timeStamp)
throws IOException {
this.graphiteSender.send(
MetricRegistry.name(context.getName(), name, Measurements.COUNT.getName()),
Long.toString(metered.getCount()),
timeStamp);
this.graphiteSender.send(
MetricRegistry.name(context.getName(), name, Measurements.RATE_1MIN.getName()),
Double.toHexString(convertRate(metered.getOneMinuteRate())),
timeStamp);
this.graphiteSender.send(
MetricRegistry.name(context.getName(), name, Measurements.RATE_5MIN.getName()),
Double.toString(convertRate(metered.getFiveMinuteRate())),
timeStamp);
this.graphiteSender.send(
MetricRegistry.name(context.getName(), name, Measurements.RATE_15MIN.getName()),
Double.toString(convertRate(metered.getFifteenMinuteRate())),
timeStamp);
this.graphiteSender.send(
MetricRegistry.name(context.getName(), name, Measurements.MEAN_RATE.getName()),
Double.toString(convertRate(metered.getMeanRate())),
timeStamp);
}
示例4: reportMetered
import com.codahale.metrics.Metered; //导入依赖的package包/类
private void reportMetered(String index, long timestamp, String name,
Metered meter) throws IOException {
StringWriter writer = new StringWriter();
JsonGenerator jsonGenerator = jsonFactory.createGenerator(writer);
jsonGenerator.writeStartObject();
jsonGenerator.writeNumberField(timestampFieldName, timestamp);
jsonGenerator.writeStringField("@name", prefixMetricName(name));
jsonGenerator.writeNumberField("count", meter.getCount());
jsonGenerator.writeNumberField("m1_rate",
convertRate(meter.getOneMinuteRate()));
jsonGenerator.writeNumberField("m5_rate",
convertRate(meter.getFiveMinuteRate()));
jsonGenerator.writeNumberField("m15_rate",
convertRate(meter.getFifteenMinuteRate()));
jsonGenerator.writeNumberField("mean_rate",
convertRate(meter.getMeanRate()));
jsonGenerator.writeEndObject();
jsonGenerator.flush();
addReportToBulkRequest(index, MetricElasticsearchTypes.METER,
writer.toString());
}
示例5: addMetered
import com.codahale.metrics.Metered; //导入依赖的package包/类
void addMetered(String baseName, Metered metered) {
addMetric(metered, baseName,
SignalFxReporter.MetricDetails.COUNT,
SignalFxProtocolBuffers.MetricType.CUMULATIVE_COUNTER, metered.getCount());
addMetric(metered, baseName,
SignalFxReporter.MetricDetails.RATE_15_MIN,
SignalFxProtocolBuffers.MetricType.GAUGE, metered.getFifteenMinuteRate());
addMetric(metered, baseName,
SignalFxReporter.MetricDetails.RATE_1_MIN,
SignalFxProtocolBuffers.MetricType.GAUGE, metered.getOneMinuteRate());
addMetric(metered, baseName,
SignalFxReporter.MetricDetails.RATE_5_MIN,
SignalFxProtocolBuffers.MetricType.GAUGE, metered.getFiveMinuteRate());
addMetric(metered, baseName,
SignalFxReporter.MetricDetails.RATE_MEAN,
SignalFxProtocolBuffers.MetricType.GAUGE, metered.getMeanRate());
}
示例6: printMetered
import com.codahale.metrics.Metered; //导入依赖的package包/类
private void printMetered(TagEncodedMetricName metric, Metered meter) {
addDataPoint(metric.submetric("rate").withTags("window", "1m"),
convertRate(meter.getOneMinuteRate()));
addDataPoint(metric.submetric("rate").withTags("window", "5m"),
convertRate(meter.getFiveMinuteRate()));
addDataPoint(metric.submetric("rate").withTags("window", "15m"),
convertRate(meter.getFifteenMinuteRate()));
//addDataPoint(rootMetric.submetric("rate", "window", "all"), epoch, meter.getMeanRate());
}
示例7: writeMetered
import com.codahale.metrics.Metered; //导入依赖的package包/类
private void writeMetered(String dropwizardName, Metered metered) throws IOException {
String name = sanitizeMetricName(dropwizardName);
writer.writeSample(name, mapOf("rate", "m1"), metered.getOneMinuteRate());
writer.writeSample(name, mapOf("rate", "m5"), metered.getFiveMinuteRate());
writer.writeSample(name, mapOf("rate", "m15"), metered.getFifteenMinuteRate());
writer.writeSample(name, mapOf("rate", "mean"), metered.getMeanRate());
}
示例8: reportMetered
import com.codahale.metrics.Metered; //导入依赖的package包/类
private void reportMetered(
final BatchBuilder builder, final Metered value
) {
final BatchBuilder b = builder.withUnit(builder.getUnit() + "/s");
b.buildPoint("1m", value.getOneMinuteRate());
b.buildPoint("5m", value.getFiveMinuteRate());
}
示例9: MeteredEntity
import com.codahale.metrics.Metered; //导入依赖的package包/类
public MeteredEntity(final Metered meter) {
count = meter.getCount();
m1Rate = meter.getOneMinuteRate();
m5Rate = meter.getFiveMinuteRate();
m15Rate = meter.getFifteenMinuteRate();
meanRate = meter.getMeanRate();
}
示例10: reportMetered
import com.codahale.metrics.Metered; //导入依赖的package包/类
private void reportMetered(String name, Metered meter) throws IOException {
statsdClient.send(prefix(name, "count"), format(meter.getCount()), StatsdClient.StatType.GAUGE);
statsdClient.send(prefix(name, "mean_rate"),
format(convertRate(meter.getMeanRate())),
StatsdClient.StatType.TIMER);
}
示例11: formatMetered
import com.codahale.metrics.Metered; //导入依赖的package包/类
private String formatMetered(String name, Metered meter, long timestamp) {
StringBuilder outputBuilder = new StringBuilder();
outputBuilder.append(formatLine(MetricNamingUtil.join(name, "count"), meter.getCount(), timestamp));
outputBuilder.append(formatLine(MetricNamingUtil.join(name, "m1_rate"), convertRate(meter.getOneMinuteRate()), timestamp));
outputBuilder.append(formatLine(MetricNamingUtil.join(name, "m5_rate"), convertRate(meter.getFiveMinuteRate()), timestamp));
outputBuilder.append(formatLine(MetricNamingUtil.join(name, "m15_rate"), convertRate(meter.getFifteenMinuteRate()), timestamp));
outputBuilder.append(formatLine(MetricNamingUtil.join(name, "mean_rate"), convertRate(meter.getMeanRate()), timestamp));
return outputBuilder.toString();
}
示例12: registerHealthCheck
import com.codahale.metrics.Metered; //导入依赖的package包/类
private void registerHealthCheck(String name, Optional<Double> ceiling, Metered errorMeter, Metered timer) {
final Gauge<Double> errorRate = Gauges.ratioOf(errorMeter, timer, Metered::getFifteenMinuteRate);
final HealthCheck healthCheck = HealthChecks.forDoubleGauge(
errorRate,
ceiling
);
healthCheckRegistry.register(name, healthCheck);
}
示例13: registerErrorGauges
import com.codahale.metrics.Metered; //导入依赖的package包/类
private void registerErrorGauges(String name, Meter errorMeter, Timer timer) {
final Gauge<Double> totalErrorPct = Gauges.ratioOf(errorMeter, timer, m -> Long.valueOf(m.getCount()).doubleValue());
final Gauge<Double> meanErrorPct = Gauges.ratioOf(errorMeter, timer, Metered::getMeanRate);
final Gauge<Double> m1ErrorPct = Gauges.ratioOf(errorMeter, timer, Metered::getOneMinuteRate);
final Gauge<Double> m5ErrorPct = Gauges.ratioOf(errorMeter, timer, Metered::getFiveMinuteRate);
final Gauge<Double> m15ErrorPct = Gauges.ratioOf(errorMeter, timer, Metered::getFifteenMinuteRate);
tryRegister(totalErrorPct, MetricRegistry.name(name, "errors", "total_pct"));
tryRegister(meanErrorPct, MetricRegistry.name(name, "errors", "mean_pct"));
tryRegister(m1ErrorPct, MetricRegistry.name(name, "errors", "m1_pct"));
tryRegister(m5ErrorPct, MetricRegistry.name(name, "errors", "m5_pct"));
tryRegister(m15ErrorPct, MetricRegistry.name(name, "errors", "m15_pct"));
}
示例14: ratioOf
import com.codahale.metrics.Metered; //导入依赖的package包/类
public static MeteredRatioGauge ratioOf(
Metered numerator,
Metered denominator,
Function<Metered, Double> accessor
) {
return new MeteredRatioGauge(numerator, denominator, accessor);
}
示例15: testOverrideAccessor
import com.codahale.metrics.Metered; //导入依赖的package包/类
@Test
public void testOverrideAccessor() throws Exception {
when(numerator.getFifteenMinuteRate()).thenReturn(10d);
when(denominator.getFifteenMinuteRate()).thenReturn(100d);
Gauge<Double> gauge = Gauges.ratioOf(
numerator,
denominator,
Metered::getFifteenMinuteRate
);
assertEquals((Double) 0.1d, gauge.getValue());
}