POC: Set attribute on span if used as exemplar #5915
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Proof of Concept for a way to support metric exemplars and tail-based sampling at the same time. Hopefully this will spur discussion on how we want to support this use-case.
Relevant issue: open-telemetry/opentelemetry-specification#2922
This makes a few big changes:
HistogramExemplarReservoir
andRandomFixedSizeExemplarReservoir
now collect thefirst
instead of thelast
exemplar sample they see. This lets us know whether or not a span will be used as an exemplar while it is still current.ExemplarReservoir.offerXXXMeasurement
now returnsboolean
so callers know whether or not the span is being used as an exemplar.otel.exemplar
as a potential new attribute that, when set totrue
means the sample is being used as an exemplar.This approach allows tail-based samplers to ensure that all traces containing spans with
otel.exemplar == true
are kept, while the rest can be sampled without accidentally dropping a span used as an exemplar.