Top Description Methods
io.opentelemetry.api.metrics

public Interface DoubleGaugeBuilder

Known Direct Implementers
io.opentelemetry.api.metrics.DefaultMeter.NoopDoubleGaugeBuilder
Imports
java.util.function.Consumer

A builder for Gauge metric types. These can only be asynchronously collected.
Since
1.10.0

Method Summary

Modifier and TypeMethod and Description
public default DoubleGauge

Returns:

The DoubleGauge instrument.
build
()

Builds and returns a DoubleGauge instrument with the configuration.

public default ObservableDoubleMeasurement

Returns:

an observable measurement that batch callbacks use to observe values.
buildObserver
()

Build an observer for this instrument to observe values from a BatchCallback.

public ObservableDoubleGauge
buildWithCallback(Consumer<ObservableDoubleMeasurement>
A callback which observes measurements when invoked.
callback
)

Builds an Asynchronous Gauge instrument with the given callback.

public LongGaugeBuilder
ofLongs()

Sets the Gauge for recording long values.

public DoubleGaugeBuilder
setDescription(String
The description.
description
)

Sets the description for this instrument.

public DoubleGaugeBuilder
setUnit(String
The unit. Instrument units must be 63 or fewer ASCII characters.
unit
)

Sets the unit of measure for this instrument.

Method Detail

buildback to summary
public default DoubleGauge build()

Builds and returns a DoubleGauge instrument with the configuration.

Note

This produces a synchronous gauge which records gauge values as they occur. Most users will want to instead register an buildWithCallback(Consumer) to asynchronously observe the value of the gauge when metrics are collected.

If using the OpenTelemetry SDK, by default gauges use last value aggregation, such that only the value of the last recorded measurement is exported.

Returns:DoubleGauge

The DoubleGauge instrument.

Since
1.38.0
buildObserverback to summary
public default ObservableDoubleMeasurement buildObserver()

Build an observer for this instrument to observe values from a BatchCallback.

This observer MUST be registered when creating a batchCallback, which records to it. Values observed outside registered callbacks are ignored.

Returns:ObservableDoubleMeasurement

an observable measurement that batch callbacks use to observe values.

Since
1.15.0
buildWithCallbackback to summary
public ObservableDoubleGauge buildWithCallback(Consumer<ObservableDoubleMeasurement> callback)

Builds an Asynchronous Gauge instrument with the given callback.

The callback will be called when the instrument is 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.
Parameters
callback:Consumer<ObservableDoubleMeasurement>

A callback which observes measurements when invoked.

ofLongsback to summary
public LongGaugeBuilder ofLongs()

Sets the Gauge for recording long values.

setDescriptionback to summary
public DoubleGaugeBuilder setDescription(String description)

Sets the description for this instrument.

Parameters
description:String

The description.

See Also
Instrument Description
setUnitback to summary
public DoubleGaugeBuilder setUnit(String unit)

Sets the unit of measure for this instrument.

Parameters
unit:String

The unit. Instrument units must be 63 or fewer ASCII characters.

See Also
Instrument Unit