Package io.opentelemetry.sdk.metrics
Class SdkDoubleGauge.SdkDoubleGaugeBuilder
- java.lang.Object
-
- io.opentelemetry.sdk.metrics.SdkDoubleGauge.SdkDoubleGaugeBuilder
-
- All Implemented Interfaces:
ExtendedDoubleGaugeBuilder,DoubleGaugeBuilder
- Enclosing class:
- SdkDoubleGauge
static final class SdkDoubleGauge.SdkDoubleGaugeBuilder extends java.lang.Object implements ExtendedDoubleGaugeBuilder
-
-
Field Summary
Fields Modifier and Type Field Description private InstrumentBuilderbuilder
-
Constructor Summary
Constructors Constructor Description SdkDoubleGaugeBuilder(SdkMeter sdkMeter, java.lang.String name)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description SdkDoubleGaugebuild()Builds and returns a DoubleGauge instrument with the configuration.ObservableDoubleMeasurementbuildObserver()Build an observer for this instrument to observe values from aBatchCallback.ObservableDoubleGaugebuildWithCallback(java.util.function.Consumer<ObservableDoubleMeasurement> callback)Builds an Asynchronous Gauge instrument with the given callback.LongGaugeBuilderofLongs()Sets the Gauge for recordinglongvalues.ExtendedDoubleGaugeBuildersetAttributesAdvice(java.util.List<AttributeKey<?>> attributes)Specify the attribute advice, which suggests the recommended set of attribute keys to be used for this gauge.DoubleGaugeBuildersetDescription(java.lang.String description)Sets the description for this instrument.DoubleGaugeBuildersetUnit(java.lang.String unit)Sets the unit of measure for this instrument.java.lang.StringtoString()
-
-
-
Field Detail
-
builder
private final InstrumentBuilder builder
-
-
Constructor Detail
-
SdkDoubleGaugeBuilder
SdkDoubleGaugeBuilder(SdkMeter sdkMeter, java.lang.String name)
-
-
Method Detail
-
setDescription
public DoubleGaugeBuilder setDescription(java.lang.String description)
Description copied from interface:DoubleGaugeBuilderSets the description for this instrument.- Specified by:
setDescriptionin interfaceDoubleGaugeBuilder- Parameters:
description- The description.- See Also:
- Instrument Description
-
setUnit
public DoubleGaugeBuilder setUnit(java.lang.String unit)
Description copied from interface:DoubleGaugeBuilderSets the unit of measure for this instrument.- Specified by:
setUnitin interfaceDoubleGaugeBuilder- Parameters:
unit- The unit. Instrument units must be 63 or fewer ASCII characters.- See Also:
- Instrument Unit
-
build
public SdkDoubleGauge build()
Description copied from interface:DoubleGaugeBuilderBuilds 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
DoubleGaugeBuilder.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 interfaceDoubleGaugeBuilder- Returns:
- The DoubleGauge instrument.
-
setAttributesAdvice
public ExtendedDoubleGaugeBuilder setAttributesAdvice(java.util.List<AttributeKey<?>> attributes)
Description copied from interface:ExtendedDoubleGaugeBuilderSpecify the attribute advice, which suggests the recommended set of attribute keys to be used for this gauge.- Specified by:
setAttributesAdvicein interfaceExtendedDoubleGaugeBuilder
-
ofLongs
public LongGaugeBuilder ofLongs()
Description copied from interface:DoubleGaugeBuilderSets the Gauge for recordinglongvalues.- Specified by:
ofLongsin interfaceDoubleGaugeBuilder
-
buildWithCallback
public ObservableDoubleGauge buildWithCallback(java.util.function.Consumer<ObservableDoubleMeasurement> callback)
Description copied from interface:DoubleGaugeBuilderBuilds 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 interfaceDoubleGaugeBuilder- Parameters:
callback- A callback which observes measurements when invoked.
-
buildObserver
public ObservableDoubleMeasurement buildObserver()
Description copied from interface:DoubleGaugeBuilderBuild 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 interfaceDoubleGaugeBuilder- Returns:
- an observable measurement that batch callbacks use to observe values.
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-