@ThreadSafe public interface LongMeasure extends Measure<LongMeasure.BoundLongMeasure>
Example:
class YourClass {
private static final Meter meter = OpenTelemetry.getMeterRegistry().get("my_library_name");
private static final LongMeasure measure =
meter.
.longMeasureBuilder("doWork_latency")
.setDescription("gRPC Latency")
.setUnit("ns")
.build();
private static final LongMeasure.BoundLongMeasure boundMeasure = measure.bind(labelset);
void doWork() {
long startTime = System.nanoTime();
// Your code here.
boundMeasure.record(System.nanoTime() - startTime);
}
}
| Modifier and Type | Interface and Description |
|---|---|
static interface |
LongMeasure.BoundLongMeasure
A
Bound Instrument for a LongMeasure. |
static interface |
LongMeasure.Builder
Builder class for
LongMeasure. |
InstrumentWithBinding.BoundInstrument| Modifier and Type | Method and Description |
|---|---|
LongMeasure.BoundLongMeasure |
bind(String... labelKeyValuePairs)
Returns a
Bound Instrument associated with the specified labels. |
void |
record(long value,
String... labelKeyValuePairs)
Records the given measurement, associated with the current
Context and provided
LabelSet. |
void record(long value,
String... labelKeyValuePairs)
Context and provided
LabelSet.value - the measurement to record.labelKeyValuePairs - the set of labels to be associated to this recordingIllegalArgumentException - if value is negative.LongMeasure.BoundLongMeasure 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<LongMeasure.BoundLongMeasure>labelKeyValuePairs - the set of labels, as key-value pairs.Bound Instrument