Skip to content

Commit 2903e64

Browse files
authored
Clarify reader / exporter relationship for temporality preference and default aggregation (#4142)
Reviewing @dashpole's [comments](#4124 (review)) on #4124, I realize that a key clarification is missing for the contract between readers and exporters, and for the configuration of built-in exporters. We [state that](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/metrics/sdk.md#metricreader) MetricReaders should be constructed with: - "The default output aggregation (optional), a function of instrument kind. If not configured, the [default aggregation](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/metrics/sdk.md#default-aggregation) SHOULD be used." - "The default output temporality (optional), a function of instrument kind. If not configured, the Cumulative temporality SHOULD be used." And for MetricExporters, we [state that](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/metrics/sdk.md#metricexporter) "The aggregation and temporality properties used by the OpenTelemetry Metric SDK are determined when registering Metric Exporters through their associated MetricReader." But we don't connect the dots that the `aggregation` and `temporality` options for the MetricReader should be obtained from a MetricExporter. I think this is understood, since the whole reason these are configurable at the MetricReader level is that MetricExporters and their associated backends have different requirements around temporality and default aggregation (especially in the case of base2 exponential histogram). This PR clarifies that the MetricReader `aggregation` and `temporality` options SHOULD come from the associated MetricExporter, NOT from the caller. Furthermore, because these are now clearly spelled out as preferences of MetricExporter, I've updated all the built-in metric exporter definitions to make expectations clear around what defaults and configuration of `aggregation` and `temporality` should be supported. This achieves the goals of #4124 in a more generic way. | Exporter | default `aggregation` | `temporality` | |---|---|---| | Prometheus | configurable | always cumulative | | OTLP | configurable | configurable | | Standard Output | configurable | configurable | | InMemory | configurable | configurable |
1 parent b1c4e78 commit 2903e64

File tree

7 files changed

+112
-75
lines changed

7 files changed

+112
-75
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ release.
1818

1919
- Clarify prometheus exporter should have `host` and `port` configuration options.
2020
([#4147](https://github.com/open-telemetry/opentelemetry-specification/pull/4147))
21+
- Clarify metric reader / metric exporter relationship for temporality
22+
preference and default aggregation. Explicitly define configuration options
23+
for temporality preference and default aggregation of built-in exporters, and
24+
make default values explicit.
25+
([#4142](https://github.com/open-telemetry/opentelemetry-specification/pull/4142))
2126

2227
### Logs
2328

spec-compliance-matrix.md

Lines changed: 62 additions & 60 deletions
Large diffs are not rendered by default.

specification/metrics/sdk.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1221,12 +1221,12 @@ determines the following capabilities:
12211221
* Handling the [ForceFlush](#forceflush) and [Shutdown](#shutdown) signals from
12221222
the SDK.
12231223

1224-
To construct a `MetricReader` when setting up an SDK, the caller
1225-
SHOULD provide at least the following:
1224+
To construct a `MetricReader` when setting up an SDK, at least the following
1225+
SHOULD be provided:
12261226

12271227
* The `exporter` to use, which is a `MetricExporter` instance.
1228-
* The default output `aggregation` (optional), a function of instrument kind. If not configured, the [default aggregation](#default-aggregation) SHOULD be used.
1229-
* The default output `temporality` (optional), a function of instrument kind. If not configured, the Cumulative temporality SHOULD be used.
1228+
* The default output `aggregation` (optional), a function of instrument kind. This function SHOULD be obtained from the `exporter`. If not configured, the [default aggregation](#default-aggregation) SHOULD be used.
1229+
* The output `temporality` (optional), a function of instrument kind. This function SHOULD be obtained from the `exporter`. If not configured, the Cumulative temporality SHOULD be used.
12301230
* **Status**: [Development](../document-status.md) - The default aggregation cardinality limit to use, a function of instrument kind. If not configured, a default value of 2000 SHOULD be used.
12311231
* **Status**: [Development](../document-status.md) - The [MetricFilter](#metricfilter) to apply to metrics and attributes during `MetricReader#Collect`.
12321232
* Zero of more [MetricProducer](#metricproducer)s (optional) to collect metrics from in addition to metrics from the SDK.

specification/metrics/sdk_exporters/in-memory.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,15 @@ In-memory Metrics Exporter is a [Push Metric
1010
Exporter](../sdk.md#push-metric-exporter) which accumulates metrics data in the
1111
local memory and allows to inspect it (useful for e.g. unit tests).
1212

13-
In-memory Metrics Exporter MUST support both Cumulative and Delta
14-
[Temporality](../data-model.md#temporality).
13+
In-memory Metrics Exporter MUST provide configuration to set
14+
the [MetricReader](../sdk.md#metricreader) output `temporality` as a function of
15+
instrument kind. This option MAY be named `temporality`, and MUST set
16+
temporality to Cumulative for all instrument kinds by default.
17+
18+
In-memory Metrics Exporter MAY provide configuration to set
19+
the [MetricReader](../sdk.md#metricreader) default `aggregation` as a function
20+
of instrument kind. This option MAY be named `default_aggregation`, and MUST use
21+
the [default aggregation](../sdk.md#default-aggregation) by default.
1522

1623
If a language provides a mechanism to automatically configure a
1724
[MetricReader](../sdk.md#metricreader) to pair with the associated

specification/metrics/sdk_exporters/otlp.md

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,15 @@ OTLP Metrics Exporter is a [Push Metric
1212
Exporter](../sdk.md#push-metric-exporter) which sends metrics via the
1313
[OpenTelemetry Protocol](../../protocol/README.md).
1414

15-
OTLP Metrics Exporter MUST support both Cumulative and Delta
16-
[Aggregation Temporality](../data-model.md#temporality).
15+
OTLP Metrics Exporter MUST provide configuration to influence
16+
the [MetricReader](../sdk.md#metricreader) output `temporality` as a function of
17+
instrument kind. This option MAY be named `temporality`, and MUST set
18+
temporality preference to Cumulative for all instrument kinds by default.
19+
20+
OTLP Metrics Exporter MUST provide configuration to influence
21+
the [MetricReader](../sdk.md#metricreader) default `aggregation` as a function
22+
of instrument kind. This option MAY be named `default_aggregation`, and MUST set
23+
the [default aggregation](../sdk.md#default-aggregation) for all instrument kinds by default.
1724

1825
The exporter MUST provide configuration according to the [OpenTelemetry Protocol
1926
Exporter](../../protocol/exporter.md) specification.
@@ -33,12 +40,12 @@ then by default:
3340
* The exporter MUST configure the default aggregation on the basis of instrument kind using
3441
the `OTEL_EXPORTER_OTLP_METRICS_DEFAULT_HISTOGRAM_AGGREGATION` variable as described below if it is implemented.
3542

36-
## Additional Configuration
43+
## Additional Environment Variable Configuration
3744

38-
| Name | Description | Default |
39-
|------------------------------------------------------------|---------------------------------------------------------------------|-----------------------------|
40-
| `OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE` | The aggregation temporality to use on the basis of instrument kind. | `cumulative` |
41-
| `OTEL_EXPORTER_OTLP_METRICS_DEFAULT_HISTOGRAM_AGGREGATION` | The default aggregation to use for histogram instruments. | `explicit_bucket_histogram` |
45+
| Name | Description | Default |
46+
|------------------------------------------------------------|--------------------------------------------------------------------------------------------------------|-----------------------------|
47+
| `OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE` | Configure the exporter's aggregation `temporality` option (see above) on the basis of instrument kind. | `cumulative` |
48+
| `OTEL_EXPORTER_OTLP_METRICS_DEFAULT_HISTOGRAM_AGGREGATION` | Configure the exporter's `default_aggregation` option (see above) for Histogram instrument kind. | `explicit_bucket_histogram` |
4249

4350
The recognized (case-insensitive) values for `OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE` are:
4451

specification/metrics/sdk_exporters/prometheus.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ A Prometheus Exporter for an OpenTelemetry metrics SDK MUST NOT add
3838
There MUST be at most one `target` info metric exposed by an SDK
3939
Prometheus exporter.
4040

41+
A Prometheus Exporter MUST set
42+
the [MetricReader](../sdk.md#metricreader) `temporality` as a function of
43+
instrument kind to be `cumulative` for all instrument kinds.
44+
4145
## Configuration
4246

4347
A Prometheus Exporter SHOULD support a configuration option to set the host
@@ -48,6 +52,11 @@ A Prometheus Exporter SHOULD support a configuration option to set the port
4852
that metrics are served on. The option MAY be named `port`, and MUST be `9464` by
4953
default.
5054

55+
A Prometheus Exporter SHOULD support a configuration option to set
56+
the [MetricReader](../sdk.md#metricreader) default `aggregation` as a function
57+
of instrument kind. This option MAY be named `default_aggregation`, and MUST use
58+
the [default aggregation](../sdk.md#default-aggregation) by default.
59+
5160
A Prometheus Exporter MAY offer configuration to add resource attributes as metric attributes.
5261
By default, it MUST NOT add any resource attributes as metric attributes.
5362
The configuration SHOULD allow the user to select which resource attributes to copy (e.g.

specification/metrics/sdk_exporters/stdout.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,15 @@ stdout/console.
1414
name for their language. For example, ConsoleExporter, StdoutExporter,
1515
StreamExporter, etc.
1616

17-
"Standard output" Metrics Exporter MUST support both Cumulative and Delta
18-
[Temporality](../data-model.md#temporality).
17+
"Standard output" Metrics Exporter MUST provide configuration to set
18+
the [MetricReader](../sdk.md#metricreader) output `temporality` as a function of
19+
instrument kind. This option MAY be named `temporality`, and MUST set
20+
temporality to Cumulative for all instrument kinds by default.
21+
22+
"Standard output" Metrics Exporter MAY provide configuration to set
23+
the [MetricReader](../sdk.md#metricreader) default `aggregation` as a function
24+
of instrument kind. This option MAY be named `default_aggregation`, and MUST use
25+
the [default aggregation](../sdk.md#default-aggregation) by default.
1926

2027
If a language provides a mechanism to automatically configure a
2128
[MetricReader](../sdk.md#metricreader) to pair with the associated

0 commit comments

Comments
 (0)