@@ -45,7 +45,8 @@ measure name instead of the `Measure`.
4545Implementations MAY define a ` MeasurementMap ` which describes a set of data points to be collected
4646for a set of Measures. Adding this functionality may improve the efficiency of the record usage API.
4747Additionally, 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.
7778SpanContext spanContext = tracer. getCurrentSpan(). getContext();
7879if (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