Package io.opentelemetry.sdk.metrics
Class SdkLongCounter
java.lang.Object
io.opentelemetry.sdk.metrics.AbstractInstrument
io.opentelemetry.sdk.metrics.SdkLongCounter
- All Implemented Interfaces:
ExtendedLongCounter
,LongCounter
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static final class
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final Logger
private final SdkMeter
private final WriteableMetricStorage
private final ThrottlingLogger
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprivate
SdkLongCounter
(InstrumentDescriptor descriptor, SdkMeter sdkMeter, WriteableMetricStorage storage) -
Method Summary
Modifier and TypeMethodDescriptionvoid
add
(long increment) Records a value.void
add
(long increment, Attributes attributes) Records a value with a set of attributes.void
add
(long increment, Attributes attributes, Context context) Records a value with a set of attributes.boolean
Returnstrue
if the counter is enabled.Methods inherited from class io.opentelemetry.sdk.metrics.AbstractInstrument
equals, getDescriptor, hashCode, toString
-
Field Details
-
logger
-
throttlingLogger
-
sdkMeter
-
storage
-
-
Constructor Details
-
SdkLongCounter
private SdkLongCounter(InstrumentDescriptor descriptor, SdkMeter sdkMeter, WriteableMetricStorage storage)
-
-
Method Details
-
add
Description copied from interface:LongCounter
Records a value with a set of attributes.- Specified by:
add
in interfaceLongCounter
- Parameters:
increment
- The increment amount. MUST be non-negative.attributes
- A set of attributes to associate with the value.context
- The explicit context to associate with this measurement.
-
add
Description copied from interface:LongCounter
Records a value with a set of attributes.Note: This may use
Context.current()
to pull the context associated with this measurement.- Specified by:
add
in interfaceLongCounter
- Parameters:
increment
- The increment amount. MUST be non-negative.attributes
- A set of attributes to associate with the value.
-
add
public void add(long increment) Description copied from interface:LongCounter
Records a value.Note: This may use
Context.current()
to pull the context associated with this measurement.- Specified by:
add
in interfaceLongCounter
- Parameters:
increment
- The increment amount. MUST be non-negative.
-
isEnabled
public boolean isEnabled()Description copied from interface:ExtendedLongCounter
Returnstrue
if the counter is enabled.This allows callers to avoid unnecessary compute when nothing is consuming the data. Because the response is subject to change over the application, callers should call this before each call to
LongCounter.add(long)
,LongCounter.add(long, Attributes)
, orLongCounter.add(long, Attributes, Context)
.- Specified by:
isEnabled
in interfaceExtendedLongCounter
-