Skip to content

Commit a022623

Browse files
authored
Merge branch 'main' into prometheus_empty_scopeinfo
2 parents 522b74e + bc76c97 commit a022623

File tree

3 files changed

+149
-11
lines changed

3 files changed

+149
-11
lines changed

CHANGELOG.md

+7
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ release.
1919
([#3636](https://github.com/open-telemetry/opentelemetry-specification/pull/3636))
2020
- Attribute sets not observed during async callbacks are not exported.
2121
([#3242](https://github.com/open-telemetry/opentelemetry-specification/pull/3242))
22+
- Promote MetricProducer specification to feature-freeze.
23+
([#3600](https://github.com/open-telemetry/opentelemetry-specification/pull/3600))
24+
- Clarify that advice is non-identifying.
25+
([#3661](https://github.com/open-telemetry/opentelemetry-specification/pull/3661))
2226

2327
### Logs
2428

@@ -66,6 +70,9 @@ release.
6670
([#3613](https://github.com/open-telemetry/opentelemetry-specification/pull/3613))
6771
- Refine `MetricProvider.ForceFlush` and define `ForceFlush` for periodic exporting MetricReader.
6872
([#3563](https://github.com/open-telemetry/opentelemetry-specification/pull/3563))
73+
- Add synchronous gauge instrument, clarify temporality selection influence on
74+
metric point persistence.
75+
([#3540](https://github.com/open-telemetry/opentelemetry-specification/pull/3540))
6976

7077
### Logs
7178

specification/metrics/api.md

+96-1
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ linkTitle: API
3737
+ [Histogram creation](#histogram-creation)
3838
+ [Histogram operations](#histogram-operations)
3939
- [Record](#record)
40+
* [Gauge](#gauge)
41+
+ [Gauge creation](#gauge-creation)
42+
+ [Gauge operations](#gauge-operations)
43+
- [Record](#record-1)
4044
* [Asynchronous Gauge](#asynchronous-gauge)
4145
+ [Asynchronous Gauge creation](#asynchronous-gauge-creation)
4246
+ [Asynchronous Gauge operations](#asynchronous-gauge-operations)
@@ -186,7 +190,7 @@ will have the following fields:
186190
* Optional `advice` (**experimental**)
187191

188192
Instruments are associated with the Meter during creation. Instruments
189-
are identified by all of these fields.
193+
are identified by the `name`, `kind`, `unit`, and `description`.
190194

191195
Language-level features such as the distinction between integer and
192196
floating point numbers SHOULD be considered as identifying.
@@ -774,6 +778,97 @@ httpServerDuration.Record(50, ("http.request.method", "POST"), ("url.scheme", "h
774778
httpServerDuration.Record(100, new HttpRequestAttributes { method = "GET", scheme = "http" });
775779
```
776780

781+
### Gauge
782+
783+
**Status**: [Experimental](../document-status.md)
784+
785+
`Gauge` is a [synchronous Instrument](#synchronous-instrument-api) which can be
786+
used to record non-additive value(s) (e.g. the background noise level - it makes
787+
no sense to record the background noise level value from multiple rooms and sum
788+
them up) when changes occur.
789+
790+
Note: If the values are additive (e.g. the process heap size - it makes sense to
791+
report the heap size from multiple processes and sum them up, so we get the
792+
total heap usage), use [UpDownCounter](#asynchronous-updowncounter).
793+
794+
Note: Synchronous Gauge is normally used when the measurements are exposed via a
795+
subscription to change events (
796+
i.e. `backgroundNoiseLevel.onChange(value -> gauge.record(value))`). If the
797+
measurement is exposed via an accessor,
798+
use [Asynchronous Gauge](#asynchronous-gauge) to invoke the accessor in a
799+
callback function (
800+
i.e. `createObservableGauge(observable -> observable.record(backgroundNoiseLevel.getCurrentValue()))`.
801+
802+
Example uses for Gauge:
803+
804+
* subscribe to change events for the background noise level
805+
* subscribe to change events for the CPU fan speed
806+
807+
#### Gauge creation
808+
809+
There MUST NOT be any API for creating a `Gauge` other than with a
810+
[`Meter`](#meter). This MAY be called `CreateGauge`. If strong type is
811+
desired, [OpenTelemetry API](../overview.md#api) authors MAY decide the language
812+
idiomatic name(s), for example `CreateUInt64Gauge`, `CreateDoubleGauge`,
813+
`CreateGauge<UInt64>`, `CreateGauge<double>`.
814+
815+
See the [general requirements for synchronous instruments](#synchronous-instrument-api).
816+
817+
Here are some examples that [OpenTelemetry API](../overview.md#api) authors
818+
might consider:
819+
820+
```java
821+
// Java
822+
823+
DoubleGauge backgroundNoiseLevel = meter.gaugeBuilder("facility.noise.level")
824+
.setDescription("Background noise level of rooms")
825+
.setUnit("B")
826+
.build();
827+
```
828+
829+
#### Gauge operations
830+
831+
##### Record
832+
833+
Record the Gauge current value.
834+
835+
This API SHOULD NOT return a value (it MAY return a dummy value if required by
836+
certain programming languages or systems, for example `null`, `undefined`).
837+
838+
This API MUST accept the following parameter:
839+
840+
* A numeric value. The current absolute value.
841+
842+
The value needs to be provided by a user. If possible, this API
843+
SHOULD be structured so a user is obligated to provide this parameter. If it
844+
is not possible to structurally enforce this obligation, this API MUST be
845+
documented in a way to communicate to users that this parameter is needed.
846+
* [Attributes](../common/README.md#attribute) to associate with the value.
847+
848+
Users can provide attributes to associate with the value, but it is
849+
up to their discretion. Therefore, this API MUST be structured to accept a
850+
variable number of attributes, including none.
851+
852+
The [OpenTelemetry API](../overview.md#api) authors MAY decide to allow flexible
853+
[attributes](../common/README.md#attribute) to be passed in as arguments. If
854+
the attribute names and types are provided during the [gauge
855+
creation](#gauge-creation), the [OpenTelemetry API](../overview.md#api)
856+
authors MAY allow attribute values to be passed in using a more efficient way
857+
(e.g. strong typed struct allocated on the callstack, tuple). The API MUST allow
858+
callers to provide flexible attributes at invocation time rather than having to
859+
register all the possible attribute names during the instrument creation. Here
860+
are some examples that [OpenTelemetry API](../overview.md#api) authors might
861+
consider:
862+
863+
```java
864+
// Java
865+
Attributes roomA = Attributes.builder().put("room.id", "Rack A");
866+
Attributes roomB = Attributes.builder().put("room.id", "Rack B");
867+
868+
backgroundNoiseLevel.record(4.3, roomA);
869+
backgroundNoiseLevel.record(2.5, roomB);
870+
```
871+
777872
### Asynchronous Gauge
778873

779874
Asynchronous Gauge is an [asynchronous Instrument](#asynchronous-instrument-api)

specification/metrics/sdk.md

+46-10
Original file line numberDiff line numberDiff line change
@@ -527,6 +527,7 @@ an aggregation and `advice` to influence aggregation configuration parameters
527527
| [Asynchronous Counter](./api.md#asynchronous-counter) | [Sum Aggregation](./sdk.md#sum-aggregation) |
528528
| [UpDownCounter](./api.md#updowncounter) | [Sum Aggregation](./sdk.md#sum-aggregation) |
529529
| [Asynchronous UpDownCounter](./api.md#asynchronous-updowncounter) | [Sum Aggregation](./sdk.md#sum-aggregation) |
530+
| [Gauge](./api.md#gauge) | [Last Value Aggregation](./sdk.md#last-value-aggregation) |
530531
| [Asynchronous Gauge](./api.md#asynchronous-gauge) | [Last Value Aggregation](./sdk.md#last-value-aggregation) |
531532
| [Histogram](./api.md#histogram) | [Explicit Bucket Histogram Aggregation](./sdk.md#explicit-bucket-histogram-aggregation), with `ExplicitBucketBoundaries` from [advice](./api.md#instrument-advice) if provided |
532533

@@ -703,7 +704,8 @@ given instrument before starting a subsequent round of collection.
703704

704705
The implementation SHOULD NOT produce aggregated metric data for a
705706
previously-observed attribute set which is not observed during a successful
706-
callback.
707+
callback. See [MetricReader](#metricreader) for more details on the persistence
708+
of metrics across successive collections.
707709

708710
### Cardinality limits
709711

@@ -854,6 +856,11 @@ When a Meter creates an instrument, it SHOULD validate the instrument advice
854856
parameters. If an advice parameter is not valid, the Meter SHOULD emit an error
855857
notifying the user and proceed as if the parameter was not provided.
856858

859+
If multiple [identical Instruments](api.md#instrument) are created with
860+
different advice parameters, the Meter MUST return an instrument using the
861+
first-seen advice parameters and log an appropriate error as described in
862+
[duplicate instrument registrations](#duplicate-instrument-registration).
863+
857864
## Attribute limits
858865

859866
**Status**: [Stable](../document-status.md)
@@ -1058,7 +1065,6 @@ measurements using the equivalent of the following naive algorithm:
10581065
common configurable aspects of the OpenTelemetry Metrics SDK and
10591066
determines the following capabilities:
10601067

1061-
* Registering [MetricProducer](#metricproducer)(s)
10621068
* Collecting metrics from the SDK and any registered
10631069
[MetricProducers](#metricproducer) on demand.
10641070
* Handling the [ForceFlush](#forceflush) and [Shutdown](#shutdown) signals from
@@ -1071,7 +1077,7 @@ SHOULD provide at least the following:
10711077
* The default output `aggregation` (optional), a function of instrument kind. If not configured, the [default aggregation](#default-aggregation) SHOULD be used.
10721078
* The default output `temporality` (optional), a function of instrument kind. If not configured, the Cumulative temporality SHOULD be used.
10731079
* **Status**: [Experimental](../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.
1074-
* **Status**: [Experimental](../document-status.md) - Zero of more [MetricProducer](#metricproducer)s (optional) to collect metrics from in addition to metrics from the SDK.
1080+
* **Status**: [Feature-freeze](../document-status.md) - Zero of more [MetricProducer](#metricproducer)s (optional) to collect metrics from in addition to metrics from the SDK.
10751081

10761082
The [MetricReader.Collect](#collect) method allows general-purpose
10771083
`MetricExporter` instances to explicitly initiate collection, commonly
@@ -1082,18 +1088,48 @@ typically with push-based metrics collection.
10821088

10831089
The `MetricReader` MUST ensure that data points from OpenTelemetry
10841090
[instruments](./api.md#instrument) are output in the configured aggregation
1085-
temporality for each instrument kind. For synchronous instruments being output
1086-
with Cumulative temporality, this means converting [Delta to Cumulative](supplementary-guidelines.md#synchronous-example-cumulative-aggregation-temporality)
1087-
aggregation temporality. For asynchronous instruments being output
1088-
with Delta temporality, this means converting [Cumulative to
1089-
Delta](supplementary-guidelines.md#asynchronous-example-delta-temporality) aggregation
1090-
temporality.
1091+
temporality for each instrument kind. For synchronous instruments with
1092+
Cumulative aggregation temporality, this means
1093+
converting [Delta to Cumulative](supplementary-guidelines.md#synchronous-example-cumulative-aggregation-temporality)
1094+
aggregation temporality. For asynchronous instruments with Delta temporality,
1095+
this means
1096+
converting [Cumulative to Delta](supplementary-guidelines.md#asynchronous-example-delta-temporality)
1097+
aggregation temporality.
10911098

10921099
The `MetricReader` is not required to ensure data points from a non-SDK
10931100
[MetricProducer](#metricproducer) are output in the configured aggregation
10941101
temporality, as these data points are not collected using OpenTelemetry
10951102
instruments.
10961103

1104+
The `MetricReader` selection of `temporality` as a function of instrument kind
1105+
influences the persistence of metric data points across collections. For
1106+
synchronous instruments with Cumulative aggregation
1107+
temporality, [MetricReader.Collect](#collect) MUST receive data points exposed
1108+
in previous collections regardless of whether new measurements have been
1109+
recorded. For synchronous instruments with Delta aggregation
1110+
temporality, [MetricReader.Collect](#collect) MUST only receive data points with
1111+
measurements recorded since the previous collection. For asynchronous
1112+
instruments with Delta or Cumulative aggregation
1113+
temporality, [MetricReader.Collect](#collect) MUST only receive data points with
1114+
measurements recorded since the previous collection. These rules apply to all
1115+
metrics, not just those whose [point kinds](./data-model.md#point-kinds)
1116+
includes an aggregation temporality field.
1117+
1118+
The `MetricReader` selection of `temporality` as a function of instrument kind
1119+
influences the starting timestamp (i.e. `StartTimeUnixNano`) of metrics data
1120+
points received by [MetricReader.Collect](#collect). For instruments with
1121+
Cumulative aggregation temporality, successive data points received by
1122+
successive calls to [MetricReader.Collect](#collect) MUST repeat the same
1123+
starting timestamps (e.g. `(T0, T1], (T0, T2], (T0, T3]`). For instruments with
1124+
Delta aggregation temporality, successive data points received by successive
1125+
calls to [MetricReader.Collect](#collect) MUST advance the starting timestamp (
1126+
e.g. `(T0, T1], (T1, T2], (T2, T3]`). The ending timestamp (i.e. `TimeUnixNano`)
1127+
MUST always be equal to time the metric data point took effect, which is equal
1128+
to when [MetricReader.Collect](#collect) was invoked. These rules apply to all
1129+
metrics, not just those whose [point kinds](./data-model.md#point-kinds) includes
1130+
an aggregation temporality field.
1131+
See [data model temporality](./data-model.md#temporality) for more details.
1132+
10971133
The SDK MUST support multiple `MetricReader` instances to be registered on the
10981134
same `MeterProvider`, and the [MetricReader.Collect](#collect) invocation on one
10991135
`MetricReader` instance SHOULD NOT introduce side-effects to other `MetricReader`
@@ -1430,7 +1466,7 @@ modeled to interact with other components in the SDK:
14301466

14311467
## MetricProducer
14321468

1433-
**Status**: [Experimental](../document-status.md)
1469+
**Status**: [Feature-freeze](../document-status.md)
14341470

14351471
`MetricProducer` defines the interface which bridges to third-party metric
14361472
sources MUST implement so they can be plugged into an OpenTelemetry

0 commit comments

Comments
 (0)