Skip to content

Commit 44c975f

Browse files
authored
Spec out the metrics exporter and temporality handling (open-telemetry#2013)
* spec out the metrics exporter and temporality handling * OTLP defaults to cumulative * add envvar
1 parent 57c2f96 commit 44c975f

File tree

5 files changed

+95
-12
lines changed

5 files changed

+95
-12
lines changed

specification/metrics/sdk.md

+43
Original file line numberDiff line numberDiff line change
@@ -559,6 +559,26 @@ The SDK SHOULD provide a way to allow `MetricReader` to respond to
559559
idiomatic approach, for example, as `OnForceFlush` and `OnShutdown` callback
560560
functions.
561561

562+
The SDK SHOULD provide a way to allow [Aggregation
563+
Temporality](./datamodel.md#temporality) to be specified for a `MetricReader`
564+
instance during the creation time. [OpenTelemetry SDK](../overview.md#sdk)
565+
authors MAY choose the best idiomatic design for their language:
566+
567+
* Whether to treat the temporality settings as recommendation or enforcement.
568+
For example, if the temporality is set to Delta, would the SDK want to perform
569+
Cumulative->Delta conversion for an [Asynchronous
570+
Counter](./api.md#asynchronous-counter), or downgrade it to a
571+
[Gauge](./datamodel.md#gauge), or keep consuming it as Cumulative due to the
572+
consideration of [memory
573+
efficiency](./supplementary-guidelines.md#memory-management)?
574+
* If an invalid combination of settings occurred (e.g. if a `MetricReader`
575+
instance is set to use Cumulative, and it has an associated [Push Metric
576+
Exporter](#push-metric-exporter) instance which has the temporality set to
577+
Delta), would the SDK want to fail fast or use some fallback logic?
578+
* Refer to the [supplementary
579+
guidelines](./supplementary-guidelines.md#aggregation-temporality), which have
580+
more context and suggestions.
581+
562582
### MetricReader operations
563583

564584
#### Collect
@@ -629,6 +649,29 @@ example:
629649
* Exporter D is a pull exporter which reacts to another scraper over a named
630650
pipe.
631651

652+
The SDK SHOULD provide a way to allow [Aggregation
653+
Temporality](./datamodel.md#temporality) to be specified for a `MetricExporter`
654+
instance during the creation time, if the exporter supports both Cumulative and
655+
Delta [Temporality](./datamodel.md#temporality). [OpenTelemetry
656+
SDK](../overview.md#sdk) authors MAY choose the best idiomatic design for their
657+
language:
658+
659+
* Whether to treat the temporality settings as recommendation or enforcement.
660+
For example, if an [OTLP Exporter](./sdk_exporters/otlp.md) instance is being
661+
used, and the temporality is set to Delta, would the SDK want to perform
662+
Cumulative->Delta conversion for an [Asynchronous
663+
Counter](./api.md#asynchronous-counter), or downgrade it to a
664+
[Gauge](./datamodel.md#gauge), or keep exporting it as Cumulative due to the
665+
consideration of [memory
666+
efficiency](./supplementary-guidelines.md#memory-management)?
667+
* If an invalid combination of settings occurred (e.g. if a [Prometheus
668+
Exporter](./sdk_exporters/prometheus.md) instance is being used, and the
669+
temporality is set to Delta), would the SDK want to fail fast or use some
670+
fallback logic?
671+
* Refer to the [supplementary
672+
guidelines](./supplementary-guidelines.md#aggregation-temporality), which have
673+
more context and suggestions.
674+
632675
### Push Metric Exporter
633676

634677
Push Metric Exporter sends the data on its own schedule. Here are some examples:

specification/metrics/sdk_exporters/in-memory.md

+10-3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@
22

33
**Status**: [Experimental](../../document-status.md)
44

5-
Note: this specification is subject to major changes. To avoid thrusting
6-
language client maintainers, we don't recommend OpenTelemetry clients to start
7-
the implementation unless explicitly communicated.
5+
In-memory Metrics Exporter is a [Push Metric
6+
Exporter](../sdk.md#push-metric-exporter) which accumulates metrics data in the
7+
local memory and allows to inspect it (useful for e.g. unit tests).
8+
9+
In-memory Metrics Exporter MUST support both Cumulative and Delta
10+
[Temporality](../datamodel.md#temporality).
11+
12+
In-memory Metrics Exporter MUST allow [Aggregation
13+
Temporality](../datamodel.md#temporality) to be specified, as described in
14+
[MetricExporter](../sdk.md#metricexporter).

specification/metrics/sdk_exporters/otlp.md

+25-3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,28 @@
22

33
**Status**: [Experimental](../../document-status.md)
44

5-
Note: this specification is subject to major changes. To avoid thrusting
6-
language client maintainers, we don't recommend OpenTelemetry clients to start
7-
the implementation unless explicitly communicated.
5+
OTLP Metrics Exporter is a [Push Metric
6+
Exporter](../sdk.md#push-metric-exporter) which sends metrics via the
7+
[OpenTelemetry Protocol](../../protocol/README.md).
8+
9+
OTLP Metrics Exporter MUST support both Cumulative and Delta
10+
[Temporality](../datamodel.md#temporality).
11+
12+
OTLP Metrics Exporter MUST allow [Aggregation
13+
Temporality](../datamodel.md#temporality) to be specified, as described in
14+
[MetricExporter](../sdk.md#metricexporter).
15+
16+
If the temporality is not specified, OTLP Metrics Exporter SHOULD use Cumulative
17+
as the default temporality.
18+
19+
The exporter MUST provide configuration according to the [OpenTelemetry Protocol
20+
Exporter](../../protocol/exporter.md) specification.
21+
22+
In addition, the exporter MUST provide the following configuration (note: this
23+
section will be merged to the [OpenTelemetry Protocol
24+
Exporter](../../protocol/exporter.md) specification once it reaches
25+
[Stable](../../document-status.md)):
26+
27+
| Description | Default | Env variable |
28+
| ----------- | ------- | ------------ |
29+
| The output [Aggregation Temporality](../datamodel.md#temporality), either `CUMULATIVE` or `DELTA` (case insensitive) | `CUMULATIVE` | `OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY`

specification/metrics/sdk_exporters/prometheus.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22

33
**Status**: [Experimental](../../document-status.md)
44

5-
Note: this specification is subject to major changes. To avoid thrusting
6-
language client maintainers, we don't recommend OpenTelemetry clients to start
7-
the implementation unless explicitly communicated.
5+
Prometheus Exporter is a [Pull Metric Exporter](../sdk.md#pull-metric-exporter)
6+
which reacts to the Prometheus scraper and report the metrics passively to
7+
[Prometheus](https://prometheus.io/).

specification/metrics/sdk_exporters/stdout.md

+14-3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,17 @@
22

33
**Status**: [Experimental](../../document-status.md)
44

5-
Note: this specification is subject to major changes. To avoid thrusting
6-
language client maintainers, we don't recommend OpenTelemetry clients to start
7-
the implementation unless explicitly communicated.
5+
"Standard output" Metrics Exporter is a [Push Metric
6+
Exporter](../sdk.md#push-metric-exporter) which outputs the metrics to
7+
stdout/console.
8+
9+
[OpenTelemetry SDK](../../overview.md#sdk) authors MAY choose the best idiomatic
10+
name for their language. For example, ConsoleExporter, StdoutExporter,
11+
StreamExporter, etc.
12+
13+
"Standard output" Metrics Exporter MUST support both Cumulative and Delta
14+
[Temporality](../datamodel.md#temporality).
15+
16+
"Standard output" Metrics Exporter MUST allow [Aggregation
17+
Temporality](../datamodel.md#temporality) to be specified, as described in
18+
[MetricExporter](../sdk.md#metricexporter).

0 commit comments

Comments
 (0)