@@ -44,11 +44,15 @@ measure name instead of the `Measure`.
4444
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.
47+ Additionally, when recording Measurements, ` MeasurementMap ` should optionally take a map of string
48+ key-value pairs to record an exemplar.
4749
4850## Recording Stats
4951
5052Users should record Measurements against a context, either an explicit context or the implicit
5153current context. Tags from the context are recorded with the Measurements if they are any.
54+ Note that there is no implicit recording for exemplars. If you want to record a ` Measurement `
55+ against an exemplar, you have to explicitly pass a string-string map.
5256
5357Implementations SHOULD provide a means of recording multiple Measurements at once. This
5458functionality can be provided through one of the following options:
@@ -68,5 +72,14 @@ MeasurementMap measurementMap = new MeasurementMap();
6872measurementMap. put(RPC_LATENCY , 10.3 );
6973measurementMap. put(RPC_BYTES_SENT , 124 );
7074measurementMap. record(); // reads context from thread-local.
75+
76+ // Another example on recording against sampled SpanContext.
77+ SpanContext spanContext = tracer. getCurrentSpan(). getContext();
78+ if (spanContext. getTraceOptions(). isSampled()) {
79+ Map<String , String > map = new HashMap<> ();
80+ // 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);
7184}
72- ```
85+ ```
0 commit comments