Package io.opentelemetry.api.metrics
Interface LongGaugeBuilder
-
- All Known Subinterfaces:
ExtendedLongGaugeBuilder
- All Known Implementing Classes:
DefaultMeter.NoopLongGaugeBuilder
,ExtendedDefaultMeter.NoopLongGaugeBuilder
,SdkLongGauge.SdkLongGaugeBuilder
public interface LongGaugeBuilder
A builder for Gauge metric types. These can only be asynchronously collected.- Since:
- 1.10.0
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default LongGauge
build()
Builds and returns a LongGauge instrument with the configuration.default ObservableLongMeasurement
buildObserver()
Build an observer for this instrument to observe values from aBatchCallback
.ObservableLongGauge
buildWithCallback(java.util.function.Consumer<ObservableLongMeasurement> callback)
Builds an Asynchronous Gauge instrument with the given callback.LongGaugeBuilder
setDescription(java.lang.String description)
Sets the description for this instrument.LongGaugeBuilder
setUnit(java.lang.String unit)
Sets the unit of measure for this instrument.
-
-
-
Method Detail
-
setDescription
LongGaugeBuilder setDescription(java.lang.String description)
Sets the description for this instrument.- Parameters:
description
- The description.- See Also:
- Instrument Description
-
setUnit
LongGaugeBuilder setUnit(java.lang.String unit)
Sets the unit of measure for this instrument.- Parameters:
unit
- The unit. Instrument units must be 63 or fewer ASCII characters.- See Also:
- Instrument Unit
-
buildWithCallback
ObservableLongGauge buildWithCallback(java.util.function.Consumer<ObservableLongMeasurement> 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
- A callback which observes measurements when invoked.
-
buildObserver
default ObservableLongMeasurement buildObserver()
Build an observer for this instrument to observe values from aBatchCallback
.This observer MUST be registered when creating a
batchCallback
, which records to it. Values observed outside registered callbacks are ignored.- Returns:
- an observable measurement that batch callbacks use to observe values.
- Since:
- 1.15.0
-
build
default LongGauge build()
Builds and returns a LongGauge 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:
- The LongGauge instrument.
- Since:
- 1.38.0
-
-