diff --git a/CHANGELOG.md b/CHANGELOG.md index b0dbb8ce85d..96eb112f960 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,8 @@ release. - Increase metric name maximum length from 63 to 255 characters. ([#3648](https://github.com/open-telemetry/opentelemetry-specification/pull/3648)) +- MetricReader.Collect ignores Resource from MetricProducer.Produce. + ([#3636](https://github.com/open-telemetry/opentelemetry-specification/pull/3636)) ### Logs diff --git a/specification/metrics/sdk.md b/specification/metrics/sdk.md index 68d6a60dfe6..8e348315d78 100644 --- a/specification/metrics/sdk.md +++ b/specification/metrics/sdk.md @@ -1141,6 +1141,12 @@ SDK](../overview.md#sdk) authors MAY choose to add parameters (e.g. callback, filter, timeout). [OpenTelemetry SDK](../overview.md#sdk) authors MAY choose the return value type, or do not return anything. +`Collect` SHOULD invoke [Produce](#produce-batch) on registered +[MetricProducers](#metricproducer). If the batch of metric points from +`Produce` includes [Resource](../resource/sdk.md) information, `Collect` MAY +replace the `Resource` from the MetricProducer with the `Resource` provided +when constructing the MeterProvider instead. + Note: it is expected that the `MetricReader.Collect` implementations will be provided by the SDK, so it is RECOMMENDED to prevent the user from accidentally overriding it, if possible (e.g. `final` in C++ and Java, `sealed` in C#). @@ -1431,10 +1437,6 @@ in-memory state MAY implement the `MetricProducer` interface for convenience. `AggregationTemporality` of produced metrics. SDK authors MAY provide utility libraries to facilitate conversion between delta and cumulative temporalities. -If the batch of [Metric points](./data-model.md#metric-points) returned by -`Produce()` includes a [Resource](../resource/sdk.md), the `MetricProducer` MUST -accept configuration for the [Resource](../resource/sdk.md). - ```text +-----------------+ +--------------+ | | Metrics... | | @@ -1457,7 +1459,9 @@ A `MetricProducer` MUST support the following functions: `Produce` provides metrics from the MetricProducer to the caller. `Produce` MUST return a batch of [Metric points](./data-model.md#metric-points). -`Produce` does not have any required parameters, however, [OpenTelemetry +If the batch of [Metric points](./data-model.md#metric-points) includes +resource information, `Produce` SHOULD require a resource as a parameter. +`Produce` does not have any other required parameters, however, [OpenTelemetry SDK](../overview.md#sdk) authors MAY choose to add required or optional parameters (e.g. timeout).