Skip to content

fix(telemetry): one metric stream across devops-cli builds - #5358

Merged
dan-petty merged 8 commits into
mainfrom
fix/5338-one-metric-stream-across-devops-cli
Nov 13, 2026
Merged

dan-petty merged 8 commits into
mainfrom
fix/5338-one-metric-stream-across-devops-cli

Conversation

@dan-petty

Copy link
Copy Markdown
Owner

Prometheus keeps one series for each job and instance, but the collector keys a metric stream by every resource attribute. A devops-cli build from before #4697 still sends host.name in its metric Resource, so an old and a new build of one workload wrote two running totals into one series, and its counts were wrong.

The collector now deletes host.name from the metric Resource of the devops-cli SDK before deltatocumulative, so every build sends one stream. Spans, logs and other SDKs keep host.name. The alert DevopsCliMetricStreamsShareSeries names the real causes and tells the reader to compare the labels of the two target_info series. Each row of the Alerting table renders its action, and a test parses the table. Tests guard the workstation instance, the metric Resource filter and the collector rule, and the promtool cases pin the wait, the job matcher and the lookback.

Closes #5338

Change: openspec/changes/archive/2026-11-13-5338-one-metric-stream-across-devops-cli/

…lector

A devops-cli build from before #4697 still sends host.name in its metric Resource. deltatocumulative keys a stream by every resource attribute, so an old and a new build of one workload wrote two running totals into one Prometheus series. The transform processor transform/metric_resource deletes host.name where telemetry.sdk.name is devops-cli-otel, before deltatocumulative.
…ce filter

A test without OTEL_RESOURCE_ATTRIBUTES pins the metric Resource of a workstation: the host name is the instance, and no host.name is in it. The two-pod test puts host.name and k8s.pod.name in OTEL_RESOURCE_ATTRIBUTES, so a removal of the allowlist filter fails a test.
The description of DevopsCliMetricStreamsShareSeries named a second service.instance.id, which gives a second instance label and cannot raise the alert. It now tells the reader to compare the labels of the two target_info series and names each cause. The promtool cases pin for: 30m, the job matcher and the 15 minute lookback.
Four rows of the Alerting table of k8s/README.md had a fifth cell, which GFM drops, so a reader did not see the action. The action is now in the Fires when cell. The test parses the table with markdown-it-py and fails on a row that does not render each cell.
docs/TELEMETRY.md says that the collector deletes host.name of devops-cli metrics before deltatocumulative, and that Job pods that run at the same time share one stream, whose dropped points otelcol_deltatocumulative_datapoints counts.
…rics pipeline

The metrics pipeline of the collector now has a resource statement and a datapoint statement. The scenario of the monitoring-collectors spec said that the pipeline has one transform statement, so it was wrong.
@dan-petty dan-petty added type/bug Type bug: the code does not do what it must scope/telemetry OpenTelemetry tracing spans, Prometheus metrics, and Jaeger labels Nov 13, 2026
@dan-petty

Copy link
Copy Markdown
Owner Author

Review, checks and render diff

Premise (origin/main, Prometheus through Grafana)

  • The metrics pipeline on main is [memory_limiter, deltatocumulative, transform/cluster, batch]. No processor changes host.name, and no dashboard or rule reads host_name.
  • max_over_time((count by (job, instance) (last_over_time(target_info{job=~"devops-cli.*|roadmap-service"}[15m])))[3h:5m]) > 1 at 04:23Z gave 2 for 4 pairs: the workstation instance of devops-cli, two runner pod instances of devops-cli-job, and roadmap-service. The two series of the workstation pair differ only in host_name (os_type, telemetry_sdk_language and telemetry_sdk_name="devops-cli-otel" are equal). At 04:23Z no pair was above 1, because the old writers had stopped.
  • Over 7 days, every OTLP target_info series has telemetry_sdk_name="devops-cli-otel". Pre-fix(telemetry): keep one metric stream per workload #4697 builds send the same SDK name, and the meter scope (devops-cli.telemetry) has no version, so the resource is the only part of the stream key that differs.

The collector rule on the real collector image

I ran otel/opentelemetry-collector-contrib:0.163.2 (the image that chart 0.178.3 renders) in a local container, with no change to the cluster.

  • validate --config of the rendered ConfigMap of the branch: exit 0. Control: the same config with the function name changed to delete_kee exits 1 with undefined function "delete_kee", so validate parses the OTTL statement.
  • A pipeline otlpjsonfile -> transform/metric_resource -> deltatocumulative -> debug, with the processor config of k8s/otel/values.yaml. Input: one delta of 1 from an old build (with host.name), one delta of 1 from a new build of the same instance, and one delta from another SDK with host.name.
    • Branch config: the old and new build give one cumulative stream (value 1, then 2, one start time) and no host.name. The other SDK keeps host.name.
    • Control without transform/metric_resource: two streams, each with value 1 and its own start time. This is the defect of fix(telemetry): one metric stream across devops-cli builds #5338.

Tests and checks (worktree at origin/main 2bbb9e2)

  • uv run devops ci test tests/telemetry/test_telemetry.py tests/telemetry/test_telemetry_instruments.py tests/prometheus/test_k8s_monitoring_alerting.py tests/commands/k8s/test_k8s_monitoring_integration.py tests/docs/test_docs.py tests/invariants/test_change_folders.py: 314 passed (promtool cases run live).
  • uv run devops ci --check --only lint,format,domain,docs,k8s,test-tree,openspec,constructs,startup-imports,swallowed-failures: all pass.
  • uv run mypy on the 5 changed Python files: 15 errors, all on lines that this branch does not change (the same 15 as on main).
  • Builder runs: devops ci fail-to-pass --base origin/main exit 0, with 4 tests that fail on the base (the promtool case of metric_streams, the README row test, the table render test and the collector test). Mutations that were not committed: a constant service.instance.id fails test_a_workstation_metric_resource_names_its_host_as_the_instance, and the Resource without the filter fails test_two_tracers_with_one_instance_send_equal_metric_resources. Rule mutations: for: 22m, no job matcher and a [14m] lookback each fail a promtool case.
  • Review fix: the scenario of the monitoring-collectors spec said that the metrics pipeline has one transform statement. It now has a resource statement and a datapoint statement, so the change adds a spec delta that names the one datapoint statement.

Render diff

k8s/otel/values.yaml, helm template otel-collector opentelemetry-collector --version 0.178.3 -n otel, origin/main against the branch:

@@ ConfigMap otel-collector-opentelemetry-collector, processors @@
+      transform/metric_resource:
+        error_mode: ignore
+        metric_statements:
+        - context: resource
+          statements:
+          - delete_key(resource.attributes, "host.name") where resource.attributes["telemetry.sdk.name"]
+            == "devops-cli-otel"
@@ ConfigMap, service.pipelines.metrics.processors @@
           - memory_limiter
+          - transform/metric_resource
           - deltatocumulative
           - transform/cluster
           - batch
@@ Deployment otel-collector-opentelemetry-collector, pod template @@
-        checksum/config: bf5fba252d726779d5d8aa47443aaea08d8db1978a0394eed4a710297f2373a0
+        checksum/config: 6bfeb808908bdea183b3905155bdadbb33b9f17a339680e522c38560aba3b492

The traces and logs pipelines do not change.

k8s/monitoring/prometheus-values.yaml with k8s/devops/monitoring/prometheus-rules-values.yaml, helm template prometheus prometheus --version 29.47.2 -n monitoring: only the ConfigMap prometheus-server changes, in alerting_rules.yml, and only the description of DevopsCliMetricStreamsShareSeries. The expression, for, labels and summary do not change, and no pod template annotation changes.

k8s/README.md is a document and renders nothing.

What restarts at the merge

  • OTel collector: one rollout. The checksum/config annotation changes, so Argo CD rolls out the collector Deployment once (1 replica, RollingUpdate: the new pod starts before the old pod stops). The new pod starts with an empty deltatocumulative state, so each devops-cli series gets one counter reset, the same as at any collector restart. rate() and increase() handle it.
  • Prometheus server: no restart. The config reloader loads the new rule text.
  • No image change. The collector rule needs no new devops-cli code, so it goes live at the merge.

Checks after the merge

  • Within 30 minutes of the collector rollout, count by (job, instance) (last_over_time(target_info{job=~"devops-cli.*|roadmap-service"}[15m])) is 1 for each pair, also while an old and a new build both send.
  • sum by (error) (increase(otelcol_deltatocumulative_datapoints{error!=""}[24h])) stays near the baseline of 2026-11-13: about 136,000 points, with 219 ErrOutOfOrder and 5 ErrOlderStart.

Known items that this change does not do

  • Two of the new tests pass on main by design (the workstation instance test and the two-pod test with host.name and k8s.pod.name). They guard behavior that main already has; the mutations above prove them.
  • The alert matcher does not cover roadmap-fix-plan-validation, roadmap-implement-check or devops-mcp-server. The issue keeps the matcher, and the collector rule now joins the old-build series of those jobs too.
  • The git row of devops ci fails on a transcript mismatch of tests/fixtures/git/review_window.json (fix(roadmap): the review_window git transcript does not match the code #4865). This branch does not touch it.
  • The collector logs "deltatocumulative" alias is deprecated; use "delta_to_cumulative" instead at start on 0.163.2. This is on main too, and fix(telemetry): use the delta_to_cumulative name of the collector processor #5359 tracks it.

@dan-petty

Copy link
Copy Markdown
Owner Author

Check results

Head commit: 8fcb49532bae4dedc525c438ebac03858c3b4ee9

Check Conclusion Link
Tests & Coverage success run
devops-cli success run
zizmor success run
trivy-config success run
CodeQL success run
Plan Check skipped run
Dependency Freshness skipped run
Tests on Main skipped run
Test Job Duration skipped run
Runner Image success run
Tests & Coverage (shard 1 of 4) success run
Service Image success run
Tests & Coverage (shard 3 of 4) success run
Design Tokens success run
Tests & Coverage (shard 4 of 4) success run
Static Analysis success run
Changed-Test Independence success run
Tests & Coverage (shard 2 of 4) success run
MCP Server Image success run
Analyze (actions) success run
Image Pins success run
Semantic PR title success run
Analyze (python) success run
Fail-to-Pass Check success run
Docs Site Build success run

Fail-to-pass run: https://github.com/dan-petty/devops-cli/actions/runs/43365696382/job/131689454896

Skipped check: Plan Check
Skipped check: Dependency Freshness
Skipped check: Tests on Main
Skipped check: Test Job Duration

@dan-petty
dan-petty marked this pull request as ready for review November 13, 2026 04:38
@dan-petty
dan-petty merged commit 19d13d7 into main Nov 13, 2026
25 checks passed
@dan-petty
dan-petty deleted the fix/5338-one-metric-stream-across-devops-cli branch November 13, 2026 04:41
dan-petty pushed a commit that referenced this pull request Nov 13, 2026
🤖 I have created a release *beep* *boop*
---


##
[0.126.1](v0.126.0...v0.126.1)
(2026-11-13)


### Bug Fixes

* **telemetry:** one metric stream across devops-cli builds
([#5358](#5358))
([19d13d7](19d13d7))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: dan-petty-release[bot] <346998822+dan-petty-release[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

scope/telemetry OpenTelemetry tracing spans, Prometheus metrics, and Jaeger type/bug Type bug: the code does not do what it must

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(telemetry): one metric stream across devops-cli builds

1 participant