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

public @Interface Metric

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

An annotation requesting that a metric be injected or registered. The metric will be registered in the application MetricRegistry. Given an injected field annotated with @Metric like this:

    @Inject
    @Metric(name="histogram")
    public Histogram histogram;

A meter of the field's type will be created and injected into managed objects. It will be up to the user to interact with the metric. This annotation can be used on fields of type Meter, Timer, SimpleTimer, Counter, and Histogram.

This may also be used to register a metric.

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 metric.
description
()

The description of the metric.

public String

Returns:

The name of the metric.
name
()

The name of the metric.

public String

Returns:

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

The scope that this metric belongs to.

public String[]

Returns:

The tags of the metric. 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 metric.

public String

Returns:

The unit of the metric. By default, the value is MetricUnits#NONE.
unit
()

The unit of the metric.

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 metric.

Returns:String

The description of the metric.

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

The name of the metric.

Returns:String

The name of the metric.

Annotations
@Nonbinding
scopeback to summary
public String scope()

The scope that this metric belongs to.

Returns:String

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

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

The tags of the metric.

Returns:String[]

The tags of the metric. 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 metric.

Returns:String

The unit of the metric. By default, the value is MetricUnits#NONE.

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