Package io.opentelemetry.sdk.metrics
Class SdkLongGauge.SdkLongGaugeBuilder
- java.lang.Object
-
- io.opentelemetry.sdk.metrics.SdkLongGauge.SdkLongGaugeBuilder
-
- All Implemented Interfaces:
ExtendedLongGaugeBuilder
,LongGaugeBuilder
- Enclosing class:
- SdkLongGauge
static final class SdkLongGauge.SdkLongGaugeBuilder extends java.lang.Object implements ExtendedLongGaugeBuilder
-
-
Field Summary
Fields Modifier and Type Field Description private InstrumentBuilder
builder
-
Constructor Summary
Constructors Constructor Description SdkLongGaugeBuilder(SdkMeter sdkMeter, java.lang.String name, java.lang.String description, java.lang.String unit, Advice.AdviceBuilder adviceBuilder)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description SdkLongGauge
build()
Builds and returns a LongGauge instrument with the configuration.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.ExtendedLongGaugeBuilder
setAttributesAdvice(java.util.List<AttributeKey<?>> attributes)
Specify the attribute advice, which suggests the recommended set of attribute keys to be used for this gauge.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.java.lang.String
toString()
-
-
-
Field Detail
-
builder
private final InstrumentBuilder builder
-
-
Constructor Detail
-
SdkLongGaugeBuilder
SdkLongGaugeBuilder(SdkMeter sdkMeter, java.lang.String name, java.lang.String description, java.lang.String unit, Advice.AdviceBuilder adviceBuilder)
-
-
Method Detail
-
setDescription
public LongGaugeBuilder setDescription(java.lang.String description)
Description copied from interface:LongGaugeBuilder
Sets the description for this instrument.- Specified by:
setDescription
in interfaceLongGaugeBuilder
- Parameters:
description
- The description.- See Also:
- Instrument Description
-
setUnit
public LongGaugeBuilder setUnit(java.lang.String unit)
Description copied from interface:LongGaugeBuilder
Sets the unit of measure for this instrument.- Specified by:
setUnit
in interfaceLongGaugeBuilder
- Parameters:
unit
- The unit. Instrument units must be 63 or fewer ASCII characters.- See Also:
- Instrument Unit
-
build
public SdkLongGauge build()
Description copied from interface:LongGaugeBuilder
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
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:
build
in interfaceLongGaugeBuilder
- Returns:
- The LongGauge instrument.
-
setAttributesAdvice
public ExtendedLongGaugeBuilder setAttributesAdvice(java.util.List<AttributeKey<?>> attributes)
Description copied from interface:ExtendedLongGaugeBuilder
Specify the attribute advice, which suggests the recommended set of attribute keys to be used for this gauge.- Specified by:
setAttributesAdvice
in interfaceExtendedLongGaugeBuilder
-
buildWithCallback
public ObservableLongGauge buildWithCallback(java.util.function.Consumer<ObservableLongMeasurement> callback)
Description copied from interface:LongGaugeBuilder
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.
- Specified by:
buildWithCallback
in interfaceLongGaugeBuilder
- Parameters:
callback
- A callback which observes measurements when invoked.
-
buildObserver
public ObservableLongMeasurement buildObserver()
Description copied from interface:LongGaugeBuilder
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.- Specified by:
buildObserver
in interfaceLongGaugeBuilder
- Returns:
- an observable measurement that batch callbacks use to observe values.
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-