@ThreadSafe public interface LongCounter extends Counter<LongCounter.BoundLongCounter>
Example:
class YourClass {
private static final Meter meter = OpenTelemetry.getMeterRegistry().get("my_library_name");
private static final LongCounter counter =
meter.
.longCounterBuilder("processed_jobs")
.setDescription("Processed jobs")
.setUnit("1")
.setLabelKeys(Collections.singletonList("Key"))
.build();
// It is recommended that the API user keep a reference to a Bound Counter.
private static final BoundLongCounter someWorkBound =
counter.getBound(Collections.singletonList("SomeWork"));
void doSomeWork() {
// Your code here.
someWorkBound.add(10);
}
}
| Modifier and Type | Interface and Description |
|---|---|
static interface |
LongCounter.BoundLongCounter
A
Bound Instrument for a LongCounter. |
static interface |
LongCounter.Builder
Builder class for
LongCounter. |
InstrumentWithBinding.BoundInstrument| Modifier and Type | Method and Description |
|---|---|
void |
add(long delta,
String... labelKeyValuePairs)
Adds the given
delta to the current value. |
LongCounter.BoundLongCounter |
bind(String... labelKeyValuePairs)
Returns a
Bound Instrument associated with the specified labels. |
void add(long 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 set of labels to be associated to this recording.LongCounter.BoundLongCounter 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<LongCounter.BoundLongCounter>labelKeyValuePairs - the set of labels, as key-value pairs.Bound Instrument