|
2 | 2 |
|
3 | 3 | import io.prometheus.client.exemplars.tracer.common.SpanContextSupplier;
|
4 | 4 |
|
5 |
| -import static io.prometheus.client.exemplars.Exemplar.SPAN_ID; |
6 |
| -import static io.prometheus.client.exemplars.Exemplar.TRACE_ID; |
7 |
| - |
8 | 5 | /**
|
9 | 6 | * Default Exemplar sampler.
|
10 | 7 | * <p/>
|
11 | 8 | * Keeps each Exemplar for a minimum of ~7 seconds, then samples a new one.
|
12 | 9 | */
|
13 | 10 | public class DefaultExemplarSampler implements ExemplarSampler {
|
14 | 11 |
|
| 12 | + private static final String SPAN_ID = "span_id"; |
| 13 | + private static final String TRACE_ID = "trace_id"; |
| 14 | + |
15 | 15 | private final SpanContextSupplier spanContextSupplier;
|
16 | 16 | // Choosing a prime number for the retention interval makes behavior more predictable,
|
17 | 17 | // because it is unlikely that retention happens at the exact same time as a Prometheus scrape.
|
@@ -43,10 +43,10 @@ private Exemplar doSample(double value, Exemplar previous) {
|
43 | 43 | long timestampMs = clock.currentTimeMillis();
|
44 | 44 | if (previous == null || previous.getTimestampMs() == null
|
45 | 45 | || timestampMs - previous.getTimestampMs() > minRetentionIntervalMs) {
|
46 |
| - String traceId = spanContextSupplier.getTraceId(); |
47 | 46 | String spanId = spanContextSupplier.getSpanId();
|
| 47 | + String traceId = spanContextSupplier.getTraceId(); |
48 | 48 | if (traceId != null && spanId != null) {
|
49 |
| - return new Exemplar(value, timestampMs, TRACE_ID, traceId, SPAN_ID, spanId); |
| 49 | + return new Exemplar(value, timestampMs, SPAN_ID, spanId, TRACE_ID, traceId); |
50 | 50 | }
|
51 | 51 | }
|
52 | 52 | return null;
|
|
0 commit comments