com.codahale.metrics.annotation.Gauge Java Examples

The following examples show how to use com.codahale.metrics.annotation.Gauge. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MetricResolver.java    From metrics-cdi with Apache License 2.0 6 votes vote down vote up
private boolean isMetricAbsolute(Annotation annotation) {
    if (extension.<Boolean>getParameter(UseAbsoluteName).orElse(false))
        return true;

    if (CachedGauge.class.isInstance(annotation))
        return ((CachedGauge) annotation).absolute();
    else if (Counted.class.isInstance(annotation))
        return ((Counted) annotation).absolute();
    else if (ExceptionMetered.class.isInstance(annotation))
        return ((ExceptionMetered) annotation).absolute();
    else if (Gauge.class.isInstance(annotation))
        return ((Gauge) annotation).absolute();
    else if (Metered.class.isInstance(annotation))
        return ((Metered) annotation).absolute();
    else if (Timed.class.isInstance(annotation))
        return ((Timed) annotation).absolute();
    else
        throw new IllegalArgumentException("Unsupported Metrics forMethod [" + annotation.getClass().getName() + "]");
}
 
Example #2
Source File: MetricResolver.java    From metrics-cdi with Apache License 2.0 6 votes vote down vote up
private String metricName(Annotation annotation) {
    if (CachedGauge.class.isInstance(annotation))
        return ((CachedGauge) annotation).name();
    else if (Counted.class.isInstance(annotation))
        return ((Counted) annotation).name();
    else if (ExceptionMetered.class.isInstance(annotation))
        return ((ExceptionMetered) annotation).name();
    else if (Gauge.class.isInstance(annotation))
        return ((Gauge) annotation).name();
    else if (Metered.class.isInstance(annotation))
        return ((Metered) annotation).name();
    else if (Timed.class.isInstance(annotation))
        return ((Timed) annotation).name();
    else
        throw new IllegalArgumentException("Unsupported Metrics forMethod [" + annotation.getClass().getName() + "]");
}
 
Example #3
Source File: MultipleMetricsStaticMethod.java    From metrics-aspectj with Apache License 2.0 5 votes vote down vote up
@ExceptionMetered(name = "exception")
@Gauge(name = "gauge")
@Metered(name = "meter")
@Timed(name = "timer")
public static String metricsMethod() {
    return "value";
}
 
Example #4
Source File: MultipleMetricsMethod.java    From metrics-aspectj with Apache License 2.0 5 votes vote down vote up
@ExceptionMetered(name = "exception")
@Gauge(name = "gauge")
@Metered(name = "meter")
@Timed(name = "timer")
public String metricsMethod() {
    return "value";
}
 
Example #5
Source File: MultipleMetricsMethodBean.java    From metrics-cdi with Apache License 2.0 5 votes vote down vote up
@Counted(name = "counter", monotonic = true)
@ExceptionMetered(name = "exception")
@Gauge(name = "gauge")
@Metered(name = "meter")
@Timed(name = "timer")
public String metricsMethod() {
    return "value";
}
 
Example #6
Source File: MultipleMetricsMethodWithRegistryFromBeanProperty.java    From metrics-aspectj with Apache License 2.0 5 votes vote down vote up
@ExceptionMetered(name = "exception")
@Gauge(name = "gauge")
@Metered(name = "meter")
@Timed(name = "timer")
public String metricsMethod() {
    return "value";
}
 
Example #7
Source File: GaugeMethodWithVisibilityModifiers.java    From metrics-aspectj with Apache License 2.0 4 votes vote down vote up
@Gauge(name = "privateGaugeMethod")
private long getPrivateGauge() {
    return privateGauge;
}
 
Example #8
Source File: MetricsExtension.java    From metrics-cdi with Apache License 2.0 4 votes vote down vote up
private <X> void metricsAnnotations(@Observes @WithAnnotations({CachedGauge.class, Counted.class, ExceptionMetered.class, Gauge.class, Metered.class, Timed.class}) ProcessAnnotatedType<X> pat) {
    pat.setAnnotatedType(new AnnotatedTypeDecorator<>(pat.getAnnotatedType(), METRICS_BINDING));
}
 
Example #9
Source File: MetricResolver.java    From metrics-cdi with Apache License 2.0 4 votes vote down vote up
Of<Gauge> gauge(Class<?> topClass, Method method) {
    return resolverOf(topClass, method, Gauge.class);
}
 
Example #10
Source File: MetricsInterceptor.java    From metrics-cdi with Apache License 2.0 4 votes vote down vote up
private CachingGauge(com.codahale.metrics.Gauge<?> gauge, long timeout, TimeUnit timeoutUnit) {
    super(timeout, timeoutUnit);
    this.gauge = gauge;
}
 
Example #11
Source File: GaugeMethodBean.java    From metrics-cdi with Apache License 2.0 4 votes vote down vote up
@Gauge(name = "gaugeMethod")
public long getGauge() {
    return gauge;
}
 
Example #12
Source File: InheritedGaugeMethodBean.java    From metrics-cdi with Apache License 2.0 4 votes vote down vote up
@Gauge(name = "childGaugeMethod")
public long getChildGauge() {
    return childGauge;
}
 
Example #13
Source File: PlayerServiceImpl.java    From JuniperBot with GNU General Public License v3.0 4 votes vote down vote up
@Gauge(name = ACTIVE_CONNECTIONS, absolute = true)
@Override
public long getActiveCount() {
    return instances.values().stream().filter(this::isActive).count();
}
 
Example #14
Source File: GaugeMethodWithVisibilityModifiers.java    From metrics-aspectj with Apache License 2.0 4 votes vote down vote up
@Gauge(name = "protectedGaugeMethod")
protected long getProtectedGauge() {
    return protectedGauge;
}
 
Example #15
Source File: GaugeMethodWithVisibilityModifiers.java    From metrics-aspectj with Apache License 2.0 4 votes vote down vote up
@Gauge(name = "packagePrivateGaugeMethod")
long getPackagePrivateGauge() {
    return packagePrivateGauge;
}
 
Example #16
Source File: GaugeMethodWithVisibilityModifiers.java    From metrics-aspectj with Apache License 2.0 4 votes vote down vote up
@Gauge(name = "publicGaugeMethod")
public long getPublicGaugeMethod() {
    return publicGauge;
}
 
Example #17
Source File: GaugeMethodWithRegistryFromString.java    From metrics-aspectj with Apache License 2.0 4 votes vote down vote up
@Gauge(name = "singleGaugeMethod")
public long getSingleGauge() {
    return singleGauge;
}
 
Example #18
Source File: GaugeStaticMethodWithRegistryFromString.java    From metrics-aspectj with Apache License 2.0 4 votes vote down vote up
@Gauge(name = "singleGaugeStaticMethod")
public static long getSingleGauge() {
    return singleStaticGauge;
}
 
Example #19
Source File: InMemoryTicketManager.java    From codenvy with Eclipse Public License 1.0 4 votes vote down vote up
/** @return number of access tickets. */
@Gauge(name = "auth.sso.access_ticket_number")
public int size() {
  return accessTickets.size();
}
 
Example #20
Source File: DiscordMetricsRegistryImpl.java    From JuniperBot with GNU General Public License v3.0 4 votes vote down vote up
@Override
@Gauge(name = GAUGE_PING, absolute = true)
public double getAveragePing() {
    return getShardManager() != null ? getShardManager().getAverageGatewayPing() : 0;
}