Skip to content

fix(telemetry): a Job pod exports its metrics while it runs - #5926

Merged
dan-petty merged 3 commits into
mainfrom
fix/5916-job-pod-metrics-export
Nov 16, 2026
Merged

dan-petty merged 3 commits into
mainfrom
fix/5916-job-pod-metrics-export

Conversation

@dan-petty

Copy link
Copy Markdown
Owner

A long command, such as the command of a Job pod, exports its metrics every OTEL_METRIC_EXPORT_INTERVAL ms (default 60000) from a thread that calls flush(). The DELTA reader, the OTLP/JSON encoding and _send_payload stay. flush() holds collection and export under one lock, so a tick and the round flush of the Service do not pass each other. The SDK PeriodicExportingMetricReader collects outside its export lock, so it is not used.

devops_cli.entry sets a SIGTERM handler. It exports for at most 5 s, then does what the handler before did. The images run devops as PID 1, where the kernel dropped SIGTERM, so a runner ran on to SIGKILL and exported nothing.

Concurrent Job pods keep the shared service.instance.id. deltatocumulative drops out-of-order and older-start points (812 and 363 of about 702000 in 7 days). A drop now loses one interval, not a run.

Closes #5916

Change: openspec/changes/archive/2026-11-16-5916-job-pod-metrics-export/

@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 16, 2026
A long command exports its metrics every OTEL_METRIC_EXPORT_INTERVAL ms
(default 60000) through flush(), and SIGTERM exports once more before
the process stops as it did with no handler.
@dan-petty
dan-petty force-pushed the fix/5916-job-pod-metrics-export branch from 0145f5b to 57d914a Compare November 16, 2026 02:50
@dan-petty
dan-petty marked this pull request as ready for review November 16, 2026 02:57
@dan-petty

Copy link
Copy Markdown
Owner Author

Vet: SAFE. A thread exports the buffered metrics every OTEL_METRIC_EXPORT_INTERVAL (default 60 s) through the existing flush(), under the same lock as the round flush of the Service, so two exports cannot reach the collector out of order; a command shorter than the interval exports once at its end, as before. The SIGTERM handler exports first (in a thread, at most 5 s), then does what the handler before it did: a Python handler runs, an ignored signal stays ignored, and a default handler stops the process as before (a PID 1 runs on until SIGKILL, as today). Handlers that a block sets later (the stage Job, uvicorn) keep their behavior. The shared service.instance.id stays (#2039); the collector drop rate is small (about 1,200 of 702,000 points in 7 d) and now costs one interval, not one run.

@dan-petty
dan-petty merged commit 00bfc49 into main Nov 16, 2026
24 checks passed
@dan-petty
dan-petty deleted the fix/5916-job-pod-metrics-export branch November 16, 2026 03:01
dan-petty pushed a commit that referenced this pull request Nov 16, 2026
🤖 I have created a release *beep* *boop*
---


##
[0.160.1](v0.160.0...v0.160.1)
(2026-11-16)


### Bug Fixes

* **monitoring:** read AI spend from the gateway counter
([#5924](#5924))
([f391129](f391129))
* **telemetry:** a Job pod exports its metrics while it runs
([#5926](#5926))
([00bfc49](00bfc49))

---
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): a Job pod exports its metrics while it runs

1 participant