diff --git a/api/src/main/java/org/eclipse/microprofile/metrics/annotation/Gauge.java b/api/src/main/java/org/eclipse/microprofile/metrics/annotation/Gauge.java index e097b16e..be0fdb3c 100644 --- a/api/src/main/java/org/eclipse/microprofile/metrics/annotation/Gauge.java +++ b/api/src/main/java/org/eclipse/microprofile/metrics/annotation/Gauge.java @@ -58,7 +58,7 @@ */ @InterceptorBinding @Retention(RetentionPolicy.RUNTIME) -@Target({ ElementType.METHOD, ElementType.FIELD, ElementType.ANNOTATION_TYPE }) +@Target({ ElementType.METHOD, ElementType.ANNOTATION_TYPE }) public @interface Gauge { /** diff --git a/spec/src/main/asciidoc/metrics_spec.adoc b/spec/src/main/asciidoc/metrics_spec.adoc index 073c23ad..8ae8d2db 100644 --- a/spec/src/main/asciidoc/metrics_spec.adoc +++ b/spec/src/main/asciidoc/metrics_spec.adoc @@ -1079,7 +1079,7 @@ The following Annotations exist, see below for common fields: |Annotation | Applies to | Description | Default Unit |@Counted | M, C, T | Denotes a counter, which counts the invocations of the annotated object. | MetricUnits.NONE -|@Gauge | M, F | Denotes a gauge, which samples the value of the annotated object. | _none_ Must be supplied by the user +|@Gauge | M | Denotes a gauge, which samples the value of the annotated object. | _none_ Must be supplied by the user |@Metered | M, C, T | Denotes a meter, which tracks the frequency of invocations of the annotated object. | MetricUnits.PER_SECOND |@Metric | M, F, P | An annotation requesting that a metric should be injected. This annotation can be used on the fields of type `Meter`, `Timer`, `Counter`, and `Histogram`. | MetricUnits.NONE @@ -1207,27 +1207,15 @@ public class CounterBean { ---- ==== @Gauge -An annotation for marking a method or field as a gauge. +An annotation for marking a method as a gauge. -The implementation must support the following annotation targets: +The implementation must support the following annotation target: - * `FIELD` * `METHOD` The following lists the behavior for each annotation target. -===== FIELD - -When a field is annotated, the implementation must register a gauge for the field using the <>. The gauge value and type is equal to the annotated field value and type. - -.Example of an annotated field -[source, java] ----- -@Gauge -long value; ----- - ===== METHOD When a method is annotated, the implementation must register a gauge for the method using the <>. The gauge value and type is equal to the annotated method return value and type. @@ -1346,7 +1334,7 @@ public class TimedBean { ==== @Metric -An annotation requesting that a metric should be injected or registered. This annotation can be used on the fields of type `Meter`, `Timer`, `Counter`, and `Histogram`. +An annotation requesting that a metric should be injected or registered. The implementation must support the following annotation targets: @@ -1375,6 +1363,7 @@ Gauge hitPercentage = new Gauge() { ---- When a metric injected field is annotated, the implementation must provide the registered metric with the given name (using the <>) if the metric already exist. If no metric exists with the given name then the implementation must produce and register the requested metric. +`@Metric` can only be used on injected fields of type `Meter`, `Timer`, `Counter`, and `Histogram`. .Example of an injected field [source, java]