Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ release.

- Changes of `MeterConfig.disabled` MUST be eventually visible.
([#4645](https://github.com/open-telemetry/opentelemetry-specification/pull/4645))
- `AlignedHistogramBucketExemplarReservoir` SHOULD use a time-weighted algorithm.
([#4678](https://github.com/open-telemetry/opentelemetry-specification/pull/4678))

### Logs

Expand Down
17 changes: 13 additions & 4 deletions specification/metrics/sdk.md
Original file line number Diff line number Diff line change
Expand Up @@ -1203,6 +1203,7 @@ algorithm](https://en.wikipedia.org/wiki/Reservoir_sampling) can be used:
if bucket < num_buckets then
reservoir[bucket] = measurement
end
num_measurements_seen += 1
```

Any stateful portion of sampling computation SHOULD be reset every collection
Expand All @@ -1217,15 +1218,23 @@ contention. Otherwise, a default size of `1` 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
measurement that falls within a histogram bucket. The reservoir will accept
measurements using the equivalent of the following naive algorithm:
configuration of a Histogram. This implementation MUST store at most one
measurement that falls within a histogram bucket, and SHOULD use a
uniformly-weighted sampling algorithm based on the number of measurements the
bucket has seen so far to determine if the offered measurements should be
sampled. Alternatively, the implementation MAY instead keep the last seen
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
num_measurements_seen_bucket = num_measurements_seen[bucket]
if random_integer(0, num_measurements_seen_bucket) == 0 then
reservoir[bucket] = measurement
end
num_measurements_seen[bucket] += 1

def find_histogram_bucket(measurement):
for boundary, idx in bucket_boundaries do
Expand Down