-
Notifications
You must be signed in to change notification settings - Fork 932
Add MeasurementProcessor to Metrics SDK #4318
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
Changes from 2 commits
3f3186a
a8f5de3
1ce9e4d
4b0a58d
449d2fb
60adbd3
9d60b12
17f650c
4cbc0ec
01bcc0a
d28e993
90d331d
ee72e3f
225000a
8fbc341
f57fe00
66c6926
e585028
83a81a5
dbaffa1
f4c26c1
ebcbda8
b97a231
e6eec36
20f2977
e4fbe83
e706183
3ef9483
00ce75f
c4c9a65
58baa69
fc8b59d
5c76f60
45fc676
edad787
e872b5d
cb769a7
b4710a3
7f22b07
42781a3
958cb86
0f5e3cd
4242cfa
c8b1e76
756de83
11d423b
9cedc06
3887c5d
c1a7627
94c43a5
d7254ec
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 |
---|---|---|
|
@@ -51,6 +51,11 @@ linkTitle: SDK | |
* [Instrument advisory parameters](#instrument-advisory-parameters) | ||
* [Instrument enabled](#instrument-enabled) | ||
- [Attribute limits](#attribute-limits) | ||
- [MeasurementProcessor](#measurementprocessor) | ||
* [MeasurementProcessor operations](#measurementprocessor-operations) | ||
+ [OnMeasure](#onmeasure) | ||
+ [Shutdown](#shutdown-1) | ||
+ [ForceFlush](#forceflush-1) | ||
- [Exemplar](#exemplar) | ||
* [ExemplarFilter](#exemplarfilter) | ||
+ [AlwaysOn](#alwayson) | ||
|
@@ -64,9 +69,9 @@ linkTitle: SDK | |
- [MetricReader](#metricreader) | ||
* [MetricReader operations](#metricreader-operations) | ||
+ [Collect](#collect) | ||
+ [Shutdown](#shutdown-1) | ||
+ [Shutdown](#shutdown-2) | ||
* [Periodic exporting MetricReader](#periodic-exporting-metricreader) | ||
+ [ForceFlush](#forceflush-1) | ||
+ [ForceFlush](#forceflush-2) | ||
- [MetricExporter](#metricexporter) | ||
* [Push Metric Exporter](#push-metric-exporter) | ||
+ [Interface Definition](#interface-definition) | ||
|
@@ -986,6 +991,75 @@ Attributes which belong to Metrics are exempt from the | |
time. Attribute truncation or deletion could affect identity of metric time | ||
series and the topic requires further analysis. | ||
|
||
## MeasurementProcessor | ||
|
||
`MeasurementProcessor` is an interface which allows hooks when a `Measurement` is recorded by an `Instrument`. | ||
Blinkuu marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
`MeasurementProcessors` can be registered directly on SDK `MeterProvider` and they are invoked in the same order as they were registered. | ||
cijothomas marked this conversation as resolved.
Show resolved
Hide resolved
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. It seems like it would be good to specify how these are meant to be registered, similar to what we have for span processors. Can they be provided when the MeterProvider is instantiated (similar to span processors)? Does it need to be possible to dynamically register/unregister them (similar to callbacks)? 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. My suggestion is to use the same wording as we use for Provider configuration in general. 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. I used the exact same wording we use for LogRecordProcessor and SpanProcessor. I think it should be consistent, it's the same concept. 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. We should specify how MeterProviders are configured in the MeterProvider spec, not in the MeasurementProcessors spec. See this section of TracerProvider: https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/trace/sdk.md#configuration that @cijothomas quoted above. Make sure anything related to MeasurementProcessor is marked as Development status. |
||
|
||
SDK MUST allow users to implement and configure custom processors. | ||
|
||
The following diagram shows `MeasurementProcessor`'s relationship to other components in the SDK: | ||
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. Please include Views in this diagram. Importantly, is View configuration applied before the Measurement processor, or after, or both? We clearly want it to be applied before the aggregation portion of views is applied, but it would be nice if it was applied after the View's attribute filter so processors don't need to consider attributes that aren't going to be kept. 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. Views are meant to be applied after Measurement Processors. They operate on a higher level of abstraction. 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. I realized cardinality limits should probably also be included, but we can wait until the discussion below is resolved. |
||
|
||
```plaintext | ||
+------------------+ | ||
| MeterProvider | +----------------------+ +-----------------+ | ||
| Meter A | Measurements... | | Metrics... | | | ||
| Instrument X |-----------------> MeasurementProcessor +------------> In-memory state | | ||
| Instrument Y + | | | | | ||
| Meter B | +----------------------+ +-----------------+ | ||
| Instrument Z | | ||
| ... | +----------------------+ +-----------------+ | ||
| ... | Measurements... | | Metrics... | | | ||
| ... |-----------------> MeasurementProcessor +------------> In-memory state | | ||
| ... | | | | | | ||
| ... | +----------------------+ +-----------------+ | ||
+------------------+ | ||
``` | ||
|
||
### MeasurementProcessor operations | ||
|
||
#### OnMeasure | ||
|
||
`OnMeasure` is called when a `Measurement` is recorded. This method is called synchronously on the thread that emitted the `Measurement`, therefore it SHOULD NOT block or throw exceptions. | ||
|
||
**Parameters:** | ||
Blinkuu marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
* `measurement` - a [Measurement](./api.md#measurement) that was recorded | ||
Blinkuu marked this conversation as resolved.
Show resolved
Hide resolved
|
||
* `context` - the resolved `Context` (the explicitly passed `Context` or the current `Contex`) | ||
pellared marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
||
**Returns:** Void | ||
|
||
For a `MeasurementProcessor` registered directly on SDK `MeterProvider`, the `measurement` mutations MUST be visible in next registered processors. | ||
|
||
jmacd marked this conversation as resolved.
Show resolved
Hide resolved
|
||
A `MeasuremenetProcessor` may freely modify `measurement` for the duration of the `OnMeasure` call. | ||
Blinkuu marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
||
#### Shutdown | ||
|
||
Shuts down the processor. Called when the SDK is shut down. This is an opportunity for the processor to do any cleanup required. | ||
|
||
`Shutdown` SHOULD be called only once for each`MeasurementProcessor` instance. After the call to `Shutdow`, subsequent calls to `OnMeasure` are not allowed. SDKs SHOULD ignore these calls gracefully, if possible. | ||
pellared marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
||
`Shutdown` SHOULD provide a way to let the caller know whether it succeeded, failed or timed out. | ||
|
||
`Shutdown` MUST include the effects of `ForceFlush`. | ||
|
||
`Shutdown` SHOULD complete or abort within some timeout. `Shutdown` can be implemented as a blocking API or an asynchronous API which notifies the caller via a callback or an event. OpenTelemetry SDK authors can decide if they want to make the shutdown timeout configurable. | ||
|
||
#### ForceFlush | ||
Blinkuu marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
||
This is a hint to ensure that any tasks associated with `Measurements` for which the `MeasurementProcessor` had already received events prior to the call to `ForceFlush` SHOULD be completed as soon as possible, preferably before returning from this method. | ||
|
||
<!-- TODO: Should we mingle with the Exporter concept here? For metrics, the only thing we care is that Measuremenets are processed before aggregation happens --> | ||
|
||
In particular, if any `MeasurementProcessor` has any associated exporter, it SHOULD try to call the exporter's `Export` with all `Measurements` for which this was not already done and then invoke `ForceFlush` on it. If a timeout is specified (see below), the `MeasurementProcessor` MUST prioritize honoring the timeout over finishing all calls. It MAY skip or abort some or all `Export` or `ForceFlush` calls it has made to achieve this goal. | ||
Blinkuu marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
||
`ForceFlush` SHOULD provide a way to let the caller know whether it succeeded, failed or timed out. | ||
|
||
`ForceFlush` SHOULD only be called in cases where it is absolutely necessary, such as when using some FaaS providers that may suspend the process after an invocation, but before the `MeasurementProcessor` exports the emitted `Measuremenets`. | ||
|
||
`ForceFlush` SHOULD complete or abort within some timeout. `ForceFlush` can be implemented as a blocking API or an asynchronous API which notifies the caller via a callback or an event. OpenTelemetry SDK authors can decide if they want to make the flush timeout configurable. | ||
|
||
Blinkuu marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
## Exemplar | ||
|
||
**Status**: [Stable](../document-status.md) | ||
|
Uh oh!
There was an error while loading. Please reload this page.