You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
`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.
1025
+
1026
+
**Parameters:**
1027
+
1028
+
*`measurement` - a [Measurement](./api.md#measurement) that was recorded
1029
+
*`context` - the resolved `Context` (the explicitly passed `Context` or the current `Contex`)
1030
+
1031
+
**Returns:** Void
1032
+
1033
+
For a `MeasurementProcessor` registered directly on SDK `MeterProvider`, the `measurement` mutations MUST be visible in next registered processors.
1034
+
1035
+
A `MeasuremenetProcessor` may freely modify `measurement` for the duration of the `OnMeasure` call.
1036
+
1037
+
#### Shutdown
1038
+
1039
+
Shuts down the processor. Called when the SDK is shut down. This is an opportunity for the processor to do any cleanup required.
1040
+
1041
+
`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.
1042
+
1043
+
`Shutdown` SHOULD provide a way to let the caller know whether it succeeded, failed or timed out.
1044
+
1045
+
`Shutdown` MUST include the effects of `ForceFlush`.
1046
+
1047
+
`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.
1048
+
1049
+
#### ForceFlush
1050
+
1051
+
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.
1052
+
1053
+
<!-- TODO: Should we mingle with the Exporter concept here? For metrics, the only thing we care is that Measuremenets can be processed before aggregation happens -->
1054
+
1055
+
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.
1056
+
1057
+
`ForceFlush` SHOULD provide a way to let the caller know whether it succeeded, failed or timed out.
1058
+
1059
+
`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`.
1060
+
1061
+
`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.
0 commit comments