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

Commit 4954074

Browse files
authored
Add Exemplars specification. (#122)
1 parent 017d7c5 commit 4954074

2 files changed

Lines changed: 16 additions & 2 deletions

File tree

stats/Export.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ The library SHOULD provide support for multiple types of Aggregations:
1515
type.
1616
* `LastValueDataDouble` and `LastValueDataInt64`: data generated for a `LastValue` aggregation based
1717
on the `Measure` type.
18-
* `DistributionData`: data generated for a `Distribution` aggregation.
18+
* `DistributionData`: data generated for a `Distribution` aggregation. If there is a histogram in
19+
the `Distribution`, `DistributionData` may contain a list of `Exemplar`s.
1920

2021
### ViewData
2122
A ViewData is defined from the following:

stats/Record.md

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,15 @@ measure name instead of the `Measure`.
4444

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.
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

5052
Users should record Measurements against a context, either an explicit context or the implicit
5153
current 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

5357
Implementations SHOULD provide a means of recording multiple Measurements at once. This
5458
functionality can be provided through one of the following options:
@@ -68,5 +72,14 @@ MeasurementMap measurementMap = new MeasurementMap();
6872
measurementMap.put(RPC_LATENCY, 10.3);
6973
measurementMap.put(RPC_BYTES_SENT, 124);
7074
measurementMap.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

Comments
 (0)