Package io.opentelemetry.api.metrics
Class DefaultMeter.NoopLongGaugeBuilder
- java.lang.Object
-
- io.opentelemetry.api.metrics.DefaultMeter.NoopLongGaugeBuilder
-
- All Implemented Interfaces:
LongGaugeBuilder
- Enclosing class:
- DefaultMeter
private static class DefaultMeter.NoopLongGaugeBuilder extends java.lang.Object implements LongGaugeBuilder
-
-
Field Summary
Fields Modifier and Type Field Description private static DefaultMeter.NoopLongGaugeNOOP_GAUGEprivate static ObservableLongGaugeNOOP_OBSERVABLE_GAUGE
-
Constructor Summary
Constructors Modifier Constructor Description privateNoopLongGaugeBuilder()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description LongGaugebuild()Builds and returns a LongGauge instrument with the configuration.ObservableLongMeasurementbuildObserver()Build an observer for this instrument to observe values from aBatchCallback.ObservableLongGaugebuildWithCallback(java.util.function.Consumer<ObservableLongMeasurement> callback)Builds an Asynchronous Gauge instrument with the given callback.LongGaugeBuildersetDescription(java.lang.String description)Sets the description for this instrument.LongGaugeBuildersetUnit(java.lang.String unit)Sets the unit of measure for this instrument.
-
-
-
Field Detail
-
NOOP_OBSERVABLE_GAUGE
private static final ObservableLongGauge NOOP_OBSERVABLE_GAUGE
-
NOOP_GAUGE
private static final DefaultMeter.NoopLongGauge NOOP_GAUGE
-
-
Method Detail
-
setDescription
public LongGaugeBuilder setDescription(java.lang.String description)
Description copied from interface:LongGaugeBuilderSets the description for this instrument.- Specified by:
setDescriptionin interfaceLongGaugeBuilder- Parameters:
description- The description.- See Also:
- Instrument Description
-
setUnit
public LongGaugeBuilder setUnit(java.lang.String unit)
Description copied from interface:LongGaugeBuilderSets the unit of measure for this instrument.- Specified by:
setUnitin interfaceLongGaugeBuilder- Parameters:
unit- The unit. Instrument units must be 63 or fewer ASCII characters.- See Also:
- Instrument Unit
-
buildWithCallback
public ObservableLongGauge buildWithCallback(java.util.function.Consumer<ObservableLongMeasurement> callback)
Description copied from interface:LongGaugeBuilderBuilds 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.
- Specified by:
buildWithCallbackin interfaceLongGaugeBuilder- Parameters:
callback- A callback which observes measurements when invoked.
-
buildObserver
public ObservableLongMeasurement buildObserver()
Description copied from interface:LongGaugeBuilderBuild 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.- Specified by:
buildObserverin interfaceLongGaugeBuilder- Returns:
- an observable measurement that batch callbacks use to observe values.
-
build
public LongGauge build()
Description copied from interface:LongGaugeBuilderBuilds 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
LongGaugeBuilder.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.
- Specified by:
buildin interfaceLongGaugeBuilder- Returns:
- The LongGauge instrument.
-
-