Skip to content
This repository was archived by the owner on Oct 3, 2023. It is now read-only.

Commit eac275b

Browse files
authored
Stats: Update the Java code snippet on recording Exemplar. (#129)
* Stats: Update the Java code snippet on recording Exemplar. * Add a description of the term 'attachment'. * Quote 'attachment'.
1 parent 729cedb commit eac275b

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

stats/Record.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ measure name instead of the `Measure`.
4545
Implementations MAY define a `MeasurementMap` which describes a set of data points to be collected
4646
for a set of Measures. Adding this functionality may improve the efficiency of the record usage API.
4747
Additionally, when recording Measurements, `MeasurementMap` should optionally take a map of string
48-
key-value pairs to record an exemplar.
48+
key-value pairs to record an exemplar. The string map is called `attachments` and represents the
49+
contextual information of an exemplar, for example trace id, span id or dropped labels.
4950

5051
## Recording Stats
5152

@@ -76,10 +77,10 @@ measurementMap.record(); // reads context from thread-local.
7677
// Another example on recording against sampled SpanContext.
7778
SpanContext spanContext = tracer.getCurrentSpan().getContext();
7879
if (spanContext.getTraceOptions().isSampled()) {
79-
Map<String, String> map = new HashMap<>();
8080
// Client code needs to take care of encoding.
81-
map.put("TraceId", encode(spanContext.getTraceId()));
82-
map.put("SpanId", encode(spanContext.getSpanId()));
83-
measurementMap.record(tagContext, map);
81+
// 'Attachment' is the string representation of the contextual information of an exemplar.
82+
measurementMap.putAttachment("TraceId", encode(spanContext.getTraceId()));
83+
measurementMap.putAttachment("SpanId", encode(spanContext.getSpanId()));
84+
measurementMap.record(tagContext);
8485
}
8586
```

0 commit comments

Comments
 (0)