-
Notifications
You must be signed in to change notification settings - Fork 896
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
Metric Exemplars SDK Specification #1828
Merged
Merged
Changes from 4 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
7c83af6
First cut at exemplar spec.
jsuereth 11eb9e1
Update exemplar specification.
jsuereth 08a94ee
Merge branch 'main' into wip-exemplar
jsuereth 1177b05
Merge branch 'main' into wip-exemplar
jsuereth 2e6db06
Remove the word parent
jsuereth 8a9b6a9
Update specification/metrics/sdk.md
jsuereth 26b5957
Update specification/metrics/sdk.md
jsuereth 09dd010
Update specification/metrics/sdk.md
jsuereth ff106f4
Update specification/metrics/sdk.md
jsuereth 4c7e082
Update specification/metrics/sdk.md
jsuereth 67e4ff6
Merge remote-tracking branch 'origin/main' into wip-exemplar
jsuereth b451a7b
Merge branch 'wip-exemplar' of https://github.com/jsuereth/openteleme…
jsuereth 530859b
Fixes from review.
jsuereth a8ef58c
Clarify a confusing paragraph.
jsuereth File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -128,6 +128,8 @@ are the inputs: | |
applies to [synchronous Instruments](./api.md#synchronous-instrument). | ||
* The `aggregation` (optional) to be used. If not provided, a default | ||
aggregation will be applied by the SDK. The default aggregation is a TODO. | ||
* The `exemplar_reservoir` to use for storing exemplars. | ||
The exact parameters are TODO pending further aggregator specification. | ||
|
||
The SDK SHOULD use the following logic to determine how to process Measurements | ||
made with an Instrument: | ||
|
@@ -405,6 +407,118 @@ active span](../trace/api.md#context-interaction)). | |
+------------------+ | ||
``` | ||
|
||
## Exemplars | ||
|
||
An [Exemplar](./datamodel.md#exemplars) is a recorded measurement that exposes | ||
the following pieces of information: | ||
|
||
- The `value` that was recorded. | ||
- The `time` the measurement was seen. | ||
- The set of [Attributes](../common/common.md#attributes) associated with the measurement not already included in a metric data point. | ||
- The associated [trace id and span id](../trace/api.md#retrieving-the-traceid-and-spanid) of the active parent [Span within Context](../trace/api.md#determining-the-parent-span-from-a-context) of the measurement. | ||
jsuereth marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
A Metric SDK MUST provide a mechanism to sample `Exemplar`s from measurements. | ||
|
||
A Metric SDK MUST allow `Exemplar` sampling to be disabled. In this instance the SDK SHOULD not have memory overhead related to exemplar sampling. | ||
jsuereth marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
A Metric SDK MUST sample `Exemplar`s only from measurements within the context of a sampled trace BY DEFAULT. | ||
jmacd marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
A Metric SDK MUST allow exemplar sampling to leverage the configuration of a metric aggregator. | ||
For example, Exemplar sampling of histograms should be able to leverage bucket boundaries. | ||
|
||
A Metric SDK SHOULD provide extensible hooks for Exemplar sampling, specifically: | ||
|
||
- `ExemplarFilter`: filter which measurements can become exemplars | ||
- `ExemplarReservoir`: determine how to store exemplars. | ||
jmacd marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
### Exemplar Filter | ||
|
||
The `ExemplarFilter` interface MUST provide a method to determine if a | ||
jmacd marked this conversation as resolved.
Show resolved
Hide resolved
|
||
measurement should be sampled. | ||
|
||
This interface SHOULD have access to: | ||
|
||
- The value of the measurement. | ||
- The `Attributes` of the measurment. | ||
jmacd marked this conversation as resolved.
Show resolved
Hide resolved
|
||
- the `Context` of the measuremnt. | ||
- The timestamp of the measurement. | ||
|
||
See [Defaults and Configuration](#defaults-and-configuration) for built-in | ||
filters. | ||
|
||
### Exemplar Reservoir | ||
|
||
The `ExemplarReservoir` interface MUST provide a method to offer measurements | ||
to the reservoir and another to collect accumulated Exemplars. | ||
|
||
The "offer" method SHOULD accept measurements, including: | ||
|
||
- value | ||
- `Attributes` | ||
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. Same comment as above |
||
- `Context` | ||
- timestamp | ||
|
||
The "offer" method SHOULD have the ability to pull associated trace and span | ||
information without needing to record full context. In other words, current | ||
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`. | ||
jmacd marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
The "collect" method MUST return accumulated `Exemplar`s. | ||
|
||
These `Exemplar`s MUST have their attributes filtered by an aggregator | ||
jmacd marked this conversation as resolved.
Show resolved
Hide resolved
|
||
(or after the aggregator) when generating final Metric data points to ensure a | ||
complete view of the attributes from the original measurement. This does not | ||
need to be part of the `ExemplarReservoir` interface, but SDKs may choose to | ||
include it. | ||
jmacd marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
The `ExemplarReservoir` SHOULD avoid allocations when sampling exemplars. | ||
|
||
### Exemplar Defaults | ||
|
||
The SDK will come with two types of built-in exemplar resorvoirs: | ||
jsuereth marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
1. SimpleFixedSizeExemplarReservoir | ||
2. AlignedHistogramBucketExemplarReservoir | ||
|
||
By default, fixed sized histogram aggregators will use | ||
`AlignedHistogramBucketExemplarReservoir` and all other aggregaators will use | ||
`SimpleFixedSizeExemplarReservoir`. | ||
|
||
*SimpleExemplarReservoir* | ||
This Exemplar reservoir MAY take a configuration parameter for the size of | ||
the reservoir pool. The reservoir will accept measurements using an equivalent | ||
jsuereth marked this conversation as resolved.
Show resolved
Hide resolved
|
||
the [naive reservoir sampling algorithm](https://en.wikipedia.org/wiki/Reservoir_sampling) | ||
|
||
``` | ||
bucket = random_integer(0, num_measurements_seen) | ||
if bucket < num_buckets then | ||
reservoir[bucket] = meaasurement | ||
jsuereth marked this conversation as resolved.
Show resolved
Hide resolved
|
||
end | ||
``` | ||
|
||
*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: | ||
|
||
``` | ||
bucket = find_histogram_bucket(measurement) | ||
if bucket < num_buckets then | ||
reservoir[bucket] = measurement | ||
jmacd marked this conversation as resolved.
Show resolved
Hide resolved
|
||
end | ||
|
||
def find_histogram_bucket(measurement): | ||
for boundary, idx in bucket_boundaries do | ||
if value <= boundary then | ||
return idx | ||
end | ||
end | ||
return boundaries.length | ||
``` | ||
|
||
## MetricExporter | ||
|
||
`MetricExporter` defines the interface that protocol-specific exporters MUST | ||
|
@@ -458,3 +572,18 @@ Push Metric Exporter sends the data on its own schedule. Here are some examples: | |
Pull Metric Exporter reacts to the metrics scrapers and reports the data | ||
passively. This pattern has been widely adopted by | ||
[Prometheus](https://prometheus.io/). | ||
|
||
## Defaults and Configuration | ||
|
||
And SDK MUST provide the following configuration parameters for Exemplar | ||
jsuereth marked this conversation as resolved.
Show resolved
Hide resolved
|
||
sampling: | ||
|
||
| Name | Description | Default | Notes | | ||
|-----------------|---------|-------------|---------| | ||
| `OTEL_METRICS_EXEMPLAR_FILTER` | Filter for which measurements can become Exemplars. | `"WITH_SAMPLED_TRACE"` | | | ||
|
||
Known values for `OTEL_METRICS_EXEMPLAR_FILTER` are: | ||
|
||
- `"NONE"`: No measurements are eligble for exemplar sampling. | ||
- `"ALL"`: All measurements are eligible for exemplar sampling. | ||
- `"WITH_SAMPLED_TRACE"`: Only allow measurements with a sampled parent span in context. |
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.
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 should be marked optional right?