Top Description Methods
org.eclipse.microprofile.metrics.annotation

public @Interface Gauge

extends Annotation
Annotations
@InterceptorBinding
@Retention:RUNTIME
@Target:METHOD, ANNOTATION_TYPE
Imports
java.lang.annotation.ElementType, .Retention, .RetentionPolicy, .Target, org.eclipse.microprofile.metrics.MetricRegistry, jakarta.enterprise.util.Nonbinding, jakarta.interceptor.InterceptorBinding

An annotation for marking a method or field as a gauge. The metric will be registered in the application MetricRegistry.

Given a method annotated with @Gauge like this:


    @Gauge(name = "queueSize")
    public int getQueueSize() {
        return queue.size;
    }

A gauge with the fully qualified class name + queueSize will be created which uses the annotated method's return value as its value. The annotated method/field must be of numeric type (extends java.lang.Number).

Method Summary

Modifier and TypeMethod and Description
public boolean

Returns:

If true, use the given name as an absolute name. If false (default), use the given name relative to the annotated class.
absolute
()

Denotes whether to use the absolute name or use the default given name relative to the annotated class.

public String

Returns:

The description of the gauge.
description
()

The description of the gauge.

public String

Returns:

The name of the gauge.
name
()

The name of the gauge.

public String

Returns:

The scope this gauge belongs to. By default, the value is MetricRegistry#APPLICATION_SCOPE.
scope
()

The scope that this gauge belongs to.

public String[]

Returns:

The tags of the gauge. Each String tag must be in the form of 'key=value'. If the input is empty or does not contain a '=' sign, the entry is ignored.
tags
()

The tags of the gauge.

public String

Returns:

(Required) The unit of the gauge.
unit
()

The unit of the gauge.

Inherited from java.lang.annotation.Annotation:
annotationTypeequalshashCodetoString

Method Detail

absoluteback to summary
public boolean absolute()

Denotes whether to use the absolute name or use the default given name relative to the annotated class.

Returns:boolean

If true, use the given name as an absolute name. If false (default), use the given name relative to the annotated class.

Annotations
@Nonbinding
descriptionback to summary
public String description()

The description of the gauge.

Returns:String

The description of the gauge.

Annotations
@Nonbinding
See Also
org.eclipse.microprofile.metrics.Metadata
nameback to summary
public String name()

The name of the gauge.

Returns:String

The name of the gauge.

Annotations
@Nonbinding
scopeback to summary
public String scope()

The scope that this gauge belongs to.

Returns:String

The scope this gauge belongs to. By default, the value is MetricRegistry#APPLICATION_SCOPE.

Annotations
@Nonbinding
tagsback to summary
public String[] tags()

The tags of the gauge.

Returns:String[]

The tags of the gauge. Each String tag must be in the form of 'key=value'. If the input is empty or does not contain a '=' sign, the entry is ignored.

Annotations
@Nonbinding
See Also
org.eclipse.microprofile.metrics.Metadata
unitback to summary
public String unit()

The unit of the gauge.

Returns:String

(Required) The unit of the gauge.

Annotations
@Nonbinding
See Also
org.eclipse.microprofile.metrics.Metadata, org.eclipse.microprofile.metrics.MetricUnits