You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[connector/spanmetrics] Produce delta temporality span metrics with timestamps representing an uninterrupted series (#31780)
Closes#31671
**Description:**
Currently delta temporality span metrics are produced with
(StartTimestamp, Timestamp)'s of `(T1, T2), (T3, T4) ...`. However, the
[specification](https://opentelemetry.io/docs/specs/otel/metrics/data-model/#temporality)
says that the correct pattern for an uninterrupted delta series is `(T1,
T2), (T2, T3) ...`
This misalignment with the spec can confuse downstream components'
conversion from delta temporality to cumulative temporality, causing
each data point to be viewed as a cumulative counter "reset". An example
of this is in `prometheusexporter`
The conversion issue forces you to generate cumulative span metrics,
which use significantly more memory to cache the cumulative counts.
At work, I applied this patch to our collectors and switched to
producing delta temporality metrics for `prometheusexporter` to then
convert to cumulative. That caused a significant drop in-memory usage:

**Testing:**
- Unit tests asserting the timestamps
- Manual testing with `prometheusexporter` to make sure counter values
are cumulative and no longer being reset after receiving each delta data
point
# Use this changelog template to create an entry for release notes.
2
+
3
+
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
4
+
change_type: enhancement
5
+
6
+
# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver)
7
+
component: spanmetrics
8
+
9
+
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
10
+
note: Produce delta temporality span metrics with StartTimeUnixNano and TimeUnixNano values representing an uninterrupted series
11
+
12
+
# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists.
13
+
issues: [31671, 30688]
14
+
15
+
# (Optional) One or more lines of additional information to render under the primary note.
16
+
# These lines will be padded with 2 spaces and then inserted directly into the document.
17
+
# Use pipe (|) for multiline entries.
18
+
subtext: This allows producing delta span metrics instead of the more memory-intensive cumulative metrics, specifically when a downstream component can convert the delta metrics to cumulative.
19
+
20
+
# If your change doesn't affect end users or the exported elements of any package,
21
+
# you should instead start your pull request title with [chore] or use the "Skip Changelog" label.
22
+
# Optional: The change log or logs in which this entry should be included.
23
+
# e.g. '[user]' or '[user, api]'
24
+
# Include 'user' if the change is relevant to end users.
25
+
# Include 'api' if there is a change to a library API.
Copy file name to clipboardExpand all lines: connector/spanmetricsconnector/README.md
+2-1
Original file line number
Diff line number
Diff line change
@@ -114,8 +114,9 @@ The following settings can be optionally configured:
114
114
-`namespace`: Defines the namespace of the generated metrics. If `namespace` provided, generated metric name will be added `namespace.` prefix.
115
115
-`metrics_flush_interval` (default: `60s`): Defines the flush interval of the generated metrics.
116
116
-`metrics_expiration` (default: `0`): Defines the expiration time as `time.Duration`, after which, if no new spans are received, metrics will no longer be exported. Setting to `0` means the metrics will never expire (default behavior).
117
+
-`metric_timestamp_cache_size` (default `1000`): Only relevant for delta temporality span metrics. Controls the size of the cache used to keep track of a metric's TimestampUnixNano the last time it was flushed. When a metric is evicted from the cache, its next data point will indicate a "reset" in the series. Downstream components converting from delta to cumulative, like `prometheusexporter`, may handle these resets by setting cumulative counters back to 0.
117
118
-`exemplars`: Use to configure how to attach exemplars to metrics.
118
-
-`enabled` (default: `false`): enabling will add spans as Exemplars to all metrics. Exemplars are only kept for one flush interval.
119
+
-`enabled` (default: `false`): enabling will add spans as Exemplars to all metrics. Exemplars are only kept for one flush interval.rom the cache, its next data point will indicate a "reset" in the series. Downstream components converting from delta to cumulative, like `prometheusexporter`, may handle these resets by setting cumulative counters back to 0.
119
120
-`events`: Use to configure the events metric.
120
121
-`enabled`: (default: `false`): enabling will add the events metric.
121
122
-`dimensions`: (mandatory if `enabled`) the list of the span's event attributes to add as dimensions to the events metric, which will be included _on top of_ the common and configured `dimensions` for span and resource attributes.
0 commit comments