@ThreadSafe public interface DoubleCounter extends Counter<DoubleCounter.BoundDoubleCounter>
Example:
class YourClass {
private static final Meter meter = OpenTelemetry.getMeterRegistry().get("my_library_name");
private static final DoubleCounter counter =
meter.
.doubleCounterBuilder("processed_jobs")
.setDescription("Processed jobs")
.setUnit("1")
.setLabelKeys(Collections.singletonList("Key"))
.build();
// It is recommended that the API user keep references to a Bound Counters.
private static final BoundDoubleCounter someWorkBound =
counter.bind(Collections.singletonList("SomeWork"));
void doSomeWork() {
// Your code here.
someWorkBound.add(10.0);
}
}
| Modifier and Type | Interface and Description |
|---|---|
static interface |
DoubleCounter.BoundDoubleCounter
A
Bound Instrument for a CounterDouble. |
static interface |
DoubleCounter.Builder
Builder class for
DoubleCounter. |
InstrumentWithBinding.BoundInstrument| Modifier and Type | Method and Description |
|---|---|
void |
add(double delta,
String... labelKeyValuePairs)
Adds the given
delta to the current value. |
DoubleCounter.BoundDoubleCounter |
bind(String... labelKeyValuePairs)
Returns a
Bound Instrument associated with the specified labels. |
void add(double delta,
String... labelKeyValuePairs)
delta to the current value. The values can be negative iff monotonic was
set to false.
The value added is associated with the current Context and provided LabelSet.
delta - the value to add.labelKeyValuePairs - the labels to be associated to this recording.DoubleCounter.BoundDoubleCounter bind(String... labelKeyValuePairs)
InstrumentWithBindingBound Instrument associated with the specified labels. Multiples requests
with the same set of labels may return the same Bound Instrument instance.
It is recommended that callers keep a reference to the Bound Instrument instead of always calling this method for every operation.
bind in interface InstrumentWithBinding<DoubleCounter.BoundDoubleCounter>labelKeyValuePairs - the set of labels, as key-value pairs.Bound Instrument