本文整理匯總了Java中com.codahale.metrics.Gauge.getValue方法的典型用法代碼示例。如果您正苦於以下問題:Java Gauge.getValue方法的具體用法?Java Gauge.getValue怎麽用?Java Gauge.getValue使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.codahale.metrics.Gauge
的用法示例。
在下文中一共展示了Gauge.getValue方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: writeGauge
import com.codahale.metrics.Gauge; //導入方法依賴的package包/類
public void writeGauge(String name, Gauge<?> gauge) throws IOException {
final String sanitizedName = sanitizeMetricName(name);
writer.writeHelp(sanitizedName, getHelpMessage(name, gauge));
writer.writeType(sanitizedName, MetricType.GAUGE);
Object obj = gauge.getValue();
double value;
if (obj instanceof Number) {
value = ((Number) obj).doubleValue();
} else if (obj instanceof Boolean) {
value = ((Boolean) obj) ? 1 : 0;
} else {
LOG.warn("Invalid type for Gauge {}: {}", name, obj.getClass().getName());
return;
}
writer.writeSample(sanitizedName, emptyMap(), value);
}
示例2: collectGauge
import com.codahale.metrics.Gauge; //導入方法依賴的package包/類
private void collectGauge(String name, Gauge gauge) {
Object value = gauge.getValue();
if (value instanceof BigDecimal) {
addDataPoint(name, ((BigDecimal) value).doubleValue());
} else if (value instanceof BigInteger) {
addDataPoint(name, ((BigInteger) value).doubleValue());
} else if (value != null && value.getClass().isAssignableFrom(Double.class)) {
if (!Double.isNaN((Double) value) && Double.isFinite((Double) value)) {
addDataPoint(name, (Double) value);
}
} else if (value != null && value instanceof Number) {
addDataPoint(name, ((Number) value).doubleValue());
}
}
示例3: processGauge
import com.codahale.metrics.Gauge; //導入方法依賴的package包/類
private void processGauge(final String metricName, final Gauge gauge, final List<MetricDatum> metricData) {
if (gauge.getValue() instanceof Number) {
final Number number = (Number) gauge.getValue();
stageMetricDatum(true, metricName, number.doubleValue(), StandardUnit.None, DIMENSION_GAUGE, metricData);
}
}
開發者ID:azagniotov,項目名稱:codahale-aggregated-metrics-cloudwatch-reporter,代碼行數:7,代碼來源:CloudWatchReporter.java
示例4: testClassUnloading
import com.codahale.metrics.Gauge; //導入方法依賴的package包/類
@Test
public void testClassUnloading() {
final Injector injector = Guice.createInjector(
new InMemoryServicesModule(),
new ProcessorFunctionsModule(),
new SchedulerBindings(),
binder -> binder.install(new FactoryModuleBuilder().build(PipelineInterpreter.State.Factory.class)),
binder -> binder.bindConstant().annotatedWith(Names.named("generate_native_code")).to(true),
binder -> binder.bindConstant().annotatedWith(Names.named("cached_stageiterators")).to(true),
binder -> binder.bindConstant().annotatedWith(Names.named("processbuffer_processors")).to(1),
binder -> binder.bind(StreamService.class).to(DummyStreamService.class),
binder -> binder.bind(GrokPatternService.class).to(InMemoryGrokPatternService.class),
binder -> binder.bind(FunctionRegistry.class).asEagerSingleton(),
binder -> binder.bind(MetricRegistry.class).toProvider(MetricRegistryProvider.class).asEagerSingleton()
);
final MetricRegistry metricRegistry = injector.getInstance(MetricRegistry.class);
final Gauge<Long> pipelineLoadedClasses = metricRegistry.register("jvm.cl.loaded-classes", (Gauge<Long>) () -> PipelineClassloader.loadedClasses.get());
final RuleService ruleService = injector.getInstance(RuleService.class);
ruleService.save(RuleDao.create("00001", "some rule", "awesome rule", "rule \"arrsome\" when true then let x = now(); end", null, null));
final ConfigurationStateUpdater updater = injector.getInstance(ConfigurationStateUpdater.class);
//noinspection unchecked
final Gauge<Long> unloadedClasses = metricRegistry.getGauges((name, metric) -> name.startsWith("jvm.cl.unloaded")).get("jvm.cl.unloaded");
long i = 0;
final Long initialLoaded = pipelineLoadedClasses.getValue();
while (i++ < 100) {
final long initialUnloaded = unloadedClasses.getValue();
this.reload = null;
reload = updater.reload();
if (i % 10 == 0) {
System.gc();
log.info("\nClassloading metrics:\n=====================");
metricRegistry.getGauges((name, metric) -> name.startsWith("jvm.cl")).forEach((s, gauge) -> {
log.info("{} : {}", s, gauge.getValue());
});
Assertions.assertThat(unloadedClasses.getValue()).isGreaterThan(initialUnloaded);
}
}
Assertions.assertThat(pipelineLoadedClasses.getValue()).isGreaterThan(initialLoaded);
}
開發者ID:Graylog2,項目名稱:graylog-plugin-pipeline-processor,代碼行數:45,代碼來源:ConfigurationStateUpdaterTest.java