Top Description Methods
io.opentelemetry.api.metrics

public Interface Meter

Known Direct Implementers
io.opentelemetry.api.metrics.DefaultMeter
Annotations
@ThreadSafe
Imports
javax.annotation.concurrent.ThreadSafe

Provides instruments used to record measurements which are aggregated to metrics.

Instruments are obtained through builders provided by this interface. Each builder has a default measurement type (long or double) that may be changed.

Choosing an instrument can be hard, but here's a rule of thumb for selecting the right instrument:

Since
1.10.0
See Also
Instrument Selection Guidelines

Method Summary

Modifier and TypeMethod and Description
public default BatchCallback
batchCallback(Runnable
a callback used to observe values on-demand.
callback
,
ObservableMeasurement
Instruments for which the callback may observe values.
observableMeasurement
,
ObservableMeasurement...
Instruments for which the callback may observe values.
additionalMeasurements
)

Constructs a batch callback.

public LongCounterBuilder

Returns:

a builder for configuring a Counter instrument. Defaults to recording long values, but may be changed.
counterBuilder
(String
the name of the Counter. Instrument names must consist of 255 or fewer characters including alphanumeric, _, ., -, /, and start with a letter.
name
)

Constructs a Counter instrument.

public DoubleGaugeBuilder

Returns:

a builder used for configuring a Gauge instrument. Defaults to recording double values, but may be changed.
gaugeBuilder
(String
the name of the Gauge. Instrument names must consist of 255 or fewer characters including alphanumeric, _, ., -, /, and start with a letter.
name
)

Constructs an Asynchronous Gauge instrument.

public DoubleHistogramBuilder

Returns:

a builder for configuring a Histogram synchronous instrument. Defaults to recording double values, but may be changed.
histogramBuilder
(String
the name of the Histogram. Instrument names must consist of 255 or fewer characters including alphanumeric, _, ., -, /, and start with a letter.
name
)

Constructs a Histogram instrument.

public LongUpDownCounterBuilder

Returns:

a builder for configuring an UpDownCounter instrument. Defaults to recording long values, but may be changed.
upDownCounterBuilder
(String
the name of the UpDownCounter. Instrument names must consist of 255 or fewer characters including alphanumeric, _, ., -, /, and start with a letter.
name
)

Constructs an UpDownCounter instrument.

Method Detail

batchCallbackback to summary
public default BatchCallback batchCallback(Runnable callback, ObservableMeasurement observableMeasurement, ObservableMeasurement... additionalMeasurements)

Constructs a batch callback.

Batch callbacks allow a single callback to observe measurements for multiple asynchronous instruments.

The callback will be called when the instruments are being observed.

Callbacks are expected to abide by the following restrictions:

  • Run in a finite amount of time.
  • Safe to call repeatedly, across multiple threads.
  • Only observe values to registered instruments (i.e. observableMeasurement and additionalMeasurements
Parameters
callback:Runnable

a callback used to observe values on-demand.

observableMeasurement:ObservableMeasurement

Instruments for which the callback may observe values.

additionalMeasurements:ObservableMeasurement[]

Instruments for which the callback may observe values.

Since
1.15.0
counterBuilderback to summary
public LongCounterBuilder counterBuilder(String name)

Constructs a Counter instrument.

This is used to build both synchronous instruments and asynchronous instruments (i.e. callbacks).

Parameters
name:String

the name of the Counter. Instrument names must consist of 255 or fewer characters including alphanumeric, _, ., -, /, and start with a letter.

Returns:LongCounterBuilder

a builder for configuring a Counter instrument. Defaults to recording long values, but may be changed.

See Also
Instrument Naming Rule
gaugeBuilderback to summary
public DoubleGaugeBuilder gaugeBuilder(String name)

Constructs an Asynchronous Gauge instrument.

Parameters
name:String

the name of the Gauge. Instrument names must consist of 255 or fewer characters including alphanumeric, _, ., -, /, and start with a letter.

Returns:DoubleGaugeBuilder

a builder used for configuring a Gauge instrument. Defaults to recording double values, but may be changed.

See Also
Instrument Naming Rule
histogramBuilderback to summary
public DoubleHistogramBuilder histogramBuilder(String name)

Constructs a Histogram instrument.

Parameters
name:String

the name of the Histogram. Instrument names must consist of 255 or fewer characters including alphanumeric, _, ., -, /, and start with a letter.

Returns:DoubleHistogramBuilder

a builder for configuring a Histogram synchronous instrument. Defaults to recording double values, but may be changed.

See Also
Instrument Naming Rule
upDownCounterBuilderback to summary
public LongUpDownCounterBuilder upDownCounterBuilder(String name)

Constructs an UpDownCounter instrument.

This is used to build both synchronous instruments and asynchronous instruments (i.e. callbacks).

Parameters
name:String

the name of the UpDownCounter. Instrument names must consist of 255 or fewer characters including alphanumeric, _, ., -, /, and start with a letter.

Returns:LongUpDownCounterBuilder

a builder for configuring an UpDownCounter instrument. Defaults to recording long values, but may be changed.

See Also
Instrument Naming Rule