-
Notifications
You must be signed in to change notification settings - Fork 873
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Set attribute on exemplar spans #3723
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -993,6 +993,13 @@ span context and baggage can be inspected at this point. | |
The "offer" method does not need to store all measurements it is given and | ||
MAY further sample beyond the `ExemplarFilter`. | ||
|
||
If a span might be used as an exemplar, the ExemplarReservoir MUST set the | ||
span attribute `otel.exemplar` to the value `true`, otherwise it MUST | ||
not change the attribute. The number of spans with this annotation | ||
that are not being used as exemplars SHOULD be kept as small as possible. This | ||
allows tail-based span sampling to keep spans that are used as exemplars, | ||
without unnecessarily keeping too many spans. | ||
|
||
The "collect" method MUST return accumulated `Exemplar`s. Exemplars are expected | ||
to abide by the `AggregationTemporality` of any metric point they are recorded | ||
with. In other words, Exemplars reported against a metric data point SHOULD have | ||
|
@@ -1030,6 +1037,7 @@ algorithm](https://en.wikipedia.org/wiki/Reservoir_sampling) can be used: | |
bucket = random_integer(0, num_measurements_seen) | ||
if bucket < num_buckets then | ||
reservoir[bucket] = measurement | ||
current_span.set_attribute("otel.example", true) | ||
end | ||
``` | ||
|
||
|
@@ -1044,14 +1052,15 @@ SHOULD be used. | |
#### AlignedHistogramBucketExemplarReservoir | ||
|
||
This Exemplar reservoir MUST take a configuration parameter that is the | ||
configuration of a Histogram. This implementation MUST keep the last seen | ||
configuration of a Histogram. This implementation MUST keep the first seen | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This reservoir is designed to match Prometheus behavior of today. Rather than changing this specification, I'd prefer instead to expose a mechanism for users to specify their own custom Exemplar Reservoirs. This is the right way going forward to allow users to better sample the exemplars for their own use case or do more intelligent per-application sampling (similarly to how we expose Samplers for tracing). |
||
measurement that falls within a histogram bucket. The reservoir will accept | ||
measurements using the equivalent of the following naive algorithm: | ||
|
||
``` | ||
bucket = find_histogram_bucket(measurement) | ||
if bucket < num_buckets then | ||
if bucket < num_buckets && reservoir[bucket] == null then | ||
reservoir[bucket] = measurement | ||
current_span.set_attribute("otel.example", true) | ||
end | ||
|
||
def find_histogram_bucket(measurement): | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This only makes sense if you put a restriction to guarantee that an exemplar is preserved once added to a reservoir (which is not true at all today).
This could have poor interaction w/ cumulative streams.
I'd rather see this function exposed via a custom Exemplar Reservoir hook. Imagine this:
The only thing you're missing is the ability to provide custom reservoirs, which is something we should absoutely be adding to the exemplar specification.