Skip to content

Commit

Permalink
MetricProducer.Produce can include a Resource parameter (#3636)
Browse files Browse the repository at this point in the history
  • Loading branch information
dashpole authored Aug 10, 2023
1 parent 0a12882 commit fce0a69
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
14 changes: 9 additions & 5 deletions specification/metrics/sdk.md
Original file line number Diff line number Diff line change
Expand Up @@ -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#).
Expand Down Expand Up @@ -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... | |
Expand All @@ -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).

Expand Down

0 comments on commit fce0a69

Please sign in to comment.