本文整理汇总了Java中com.codahale.metrics.annotation.Metric类的典型用法代码示例。如果您正苦于以下问题:Java Metric类的具体用法?Java Metric怎么用?Java Metric使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Metric类属于com.codahale.metrics.annotation包,在下文中一共展示了Metric类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: incrementCountersFromInjection
import com.codahale.metrics.annotation.Metric; //导入依赖的package包/类
@Test
@InSequence(3)
public void incrementCountersFromInjection(@Metric(name = "ratioGauge", absolute = true) Gauge<Double> gauge,
@Metric(name = "counter1", absolute = true) Counter counter1,
@Metric(name = "counter2", absolute = true) Counter counter2) {
counter1.inc(Math.round(Math.random() * Integer.MAX_VALUE));
counter2.inc(Math.round(Math.random() * Integer.MAX_VALUE));
assertThat("Gauge value is incorrect", gauge.getValue(), is(equalTo(((double) counter1.getCount()) / ((double) counter2.getCount()))));
assertThat("Gauge is not registered correctly", registry.getGauges(), hasKey("ratioGauge"));
@SuppressWarnings("unchecked")
Gauge<Double> gaugeFromRegistry = (Gauge<Double>) registry.getGauges().get("ratioGauge");
assertThat("Gauge values from registry and injection do not match", gauge.getValue(), is(equalTo(gaugeFromRegistry.getValue())));
}
开发者ID:astefanutti,项目名称:metrics-cdi,代码行数:17,代码来源:MetricProducerFieldBeanTest.java
示例2: MeterResource
import com.codahale.metrics.annotation.Metric; //导入依赖的package包/类
@Inject
public MeterResource(
Meter unnamedMeter,
@Metric(name = "com.metric") Meter metricMeter,
@Metric(name = "com.absoluteMetric", absolute = true) Meter absoluteMetricMeter
) {
unnamedMeter.mark(123);
metricMeter.mark(456);
absoluteMetricMeter.mark(789);
}
开发者ID:baharclerode,项目名称:dropwizard-hk2,代码行数:11,代码来源:MeterFactoryTest.java
示例3: HistogramResource
import com.codahale.metrics.annotation.Metric; //导入依赖的package包/类
@Inject
public HistogramResource(
Histogram unnamedHistogram,
@Metric(name = "com.metric") Histogram metricHistogram,
@Metric(name = "com.absoluteMetric", absolute = true) Histogram absoluteMetricHistogram
) {
unnamedHistogram.update(123);
metricHistogram.update(456);
absoluteMetricHistogram.update(789);
}
开发者ID:baharclerode,项目名称:dropwizard-hk2,代码行数:11,代码来源:HistogramFactoryTest.java
示例4: TimerResource
import com.codahale.metrics.annotation.Metric; //导入依赖的package包/类
@Inject
@Timed
public TimerResource(
Timer unnamedTimer,
@Metric(name = "com.metric") Timer metricTimer,
@Metric(name = "com.absoluteMetric", absolute = true) Timer absoluteMetricTimer
) {
unnamedTimer.update(123, TimeUnit.DAYS);
metricTimer.update(123, TimeUnit.MICROSECONDS);
absoluteMetricTimer.update(123, TimeUnit.MILLISECONDS);
}
开发者ID:baharclerode,项目名称:dropwizard-hk2,代码行数:12,代码来源:TimerFactoryTest.java
示例5: CounterResource
import com.codahale.metrics.annotation.Metric; //导入依赖的package包/类
@Inject
public CounterResource(
Counter unnamedCounter,
@Metric(name = "com.metric") Counter metricCounter,
@Metric(name = "com.absoluteMetric", absolute = true) Counter absoluteMetricCounter
) {
unnamedCounter.inc();
metricCounter.inc(2);
absoluteMetricCounter.inc(3);
}
开发者ID:baharclerode,项目名称:dropwizard-hk2,代码行数:11,代码来源:CounterFactoryTest.java
示例6: cacheHitRatioGauge
import com.codahale.metrics.annotation.Metric; //导入依赖的package包/类
@Produces
@Metric(name = "cache-hits")
Gauge<Double> cacheHitRatioGauge(final @Metric(name = "hits") Meter hits,
final @Metric(name = "calls") Timer calls) {
return new RatioGauge() {
@Override
protected Ratio getRatio() {
return Ratio.of(hits.getCount(), calls.getCount());
}
};
}
开发者ID:astefanutti,项目名称:metrics-cdi,代码行数:12,代码来源:MetricProducerMethodBean.java
示例7: countedMethodNotCalledYet
import com.codahale.metrics.annotation.Metric; //导入依赖的package包/类
@Test
@InSequence(2)
public void countedMethodNotCalledYet(@Metric(name = "monotonicCountedMethod", absolute = true) Counter instance) {
assertThat("Counter is not registered correctly", registry.getCounters(), hasKey(COUNTER_NAME));
Counter counter = registry.getCounters().get(COUNTER_NAME);
// Make sure that the counter registered and the bean instance are the same
assertThat("Counter and bean instance are not equal", instance, is(equalTo(counter)));
}
开发者ID:astefanutti,项目名称:metrics-cdi,代码行数:10,代码来源:MonotonicCountedMethodBeanTest.java
示例8: callGaugeAfterSetterCall
import com.codahale.metrics.annotation.Metric; //导入依赖的package包/类
@Test
@InSequence(2)
public void callGaugeAfterSetterCall(@Metric(absolute = true, name = "io.astefanutti.metrics.cdi.se.GaugeMethodBean.gaugeMethod") Gauge<Long> gauge) {
// Call the setter method and assert the gauge is up-to-date
long value = 1L + Math.round(Math.random() * (Long.MAX_VALUE - 1L));
bean.setGauge(value);
assertThat("Gauge value is incorrect", gauge.getValue(), is(equalTo(value)));
}
开发者ID:astefanutti,项目名称:metrics-cdi,代码行数:10,代码来源:GaugeInjectionBeanTest.java
示例9: countedMethodNotCalledYet
import com.codahale.metrics.annotation.Metric; //导入依赖的package包/类
@Test
@InSequence(2)
public void countedMethodNotCalledYet(@Metric(name = "countedMethod", absolute = true) Counter instance) {
assertThat("Counter is not registered correctly", registry.getCounters(), hasKey(COUNTER_NAME));
Counter counter = registry.getCounters().get(COUNTER_NAME);
// Make sure that the counter registered and the bean instance are the same
assertThat("Counter and bean instance are not equal", instance, is(equalTo(counter)));
}
开发者ID:astefanutti,项目名称:metrics-cdi,代码行数:10,代码来源:CountedMethodBeanTest.java
示例10: of
import com.codahale.metrics.annotation.Metric; //导入依赖的package包/类
@Override
public String of(AnnotatedMember<?> member) {
if (member.isAnnotationPresent(Metric.class)) {
Metric metric = member.getAnnotation(Metric.class);
String name = (metric.name().isEmpty()) ? member.getJavaMember().getName() : of(metric.name());
return metric.absolute() | parameters.contains(useAbsoluteName) ? name : MetricRegistry.name(member.getJavaMember().getDeclaringClass(), name);
} else {
return parameters.contains(useAbsoluteName) ? member.getJavaMember().getName() : MetricRegistry.name(member.getJavaMember().getDeclaringClass(), member.getJavaMember().getName());
}
}
开发者ID:astefanutti,项目名称:metrics-cdi,代码行数:11,代码来源:SeMetricName.java
示例11: successRatio
import com.codahale.metrics.annotation.Metric; //导入依赖的package包/类
@Produces
@Metric(name = "success-ratio")
// Register a custom gauge that's the ratio of the 'success' meter on the 'generated' meter
Gauge<Double> successRatio(Meter success, Meter generated) {
return () -> Ratio.of(success.getOneMinuteRate(), generated.getOneMinuteRate()).getValue();
}
开发者ID:HydAu,项目名称:Camel,代码行数:7,代码来源:Application.java
示例12: successRatio
import com.codahale.metrics.annotation.Metric; //导入依赖的package包/类
@Produces
@Metric(name = "success-ratio")
Gauge<Double> successRatio(Meter generated, Meter success) {
return () -> Ratio.of(success.getOneMinuteRate(), generated.getOneMinuteRate()).getValue();
}
开发者ID:astefanutti,项目名称:camel-cdi,代码行数:6,代码来源:Application.java
示例13: cacheHitRatioGauge
import com.codahale.metrics.annotation.Metric; //导入依赖的package包/类
@Produces
@Metric(name = "cache-hits")
Gauge<Double> cacheHitRatioGauge(Meter hits, Timer calls) {
return () -> Ratio.of(hits.getCount(), calls.getCount()).getValue();
}
开发者ID:astefanutti,项目名称:metrics-cdi,代码行数:6,代码来源:MetricProducerMethodBeanJava8.java
示例14: not_registered_metric
import com.codahale.metrics.annotation.Metric; //导入依赖的package包/类
@Produces
@Metric(name = "not_registered_metric")
Counter not_registered_metric(MetricRegistry registry, InjectionPoint ip) {
return registry.counter("not_registered_metric");
}
开发者ID:astefanutti,项目名称:metrics-cdi,代码行数:6,代码来源:MetricProducerMethodBean.java
注:本文中的com.codahale.metrics.annotation.Metric类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论