Repository navigation
engine: send Cloud metrics with delta temporality - #14930
Merged
Merged
Conversation
The session's Cloud metric reader took the OTLP exporter's default, cumulative temporality. A cumulative gauge keeps every attribute set it ever saw and re-exports all of them at each collection, stamped with the collection time. Readings are keyed by span, so a long-lived client kept every exec's and helper command's series in memory and resent them every 5s. With a git-heavy agent session the Cloud uploads fell behind and the queued copies grew to tens of GB until the engine was OOM-killed. Cloud stores each gauge point as a sample at its time, and the legacy billing and check resource queries count each distinct time as a 5s sample, so the repeats were also wrong on the ingest side. Delta matches what the CLI forwarded before the engine published to Cloud: each reading is exported once, and the reader forgets the series afterwards. Signed-off-by: Alex Suraci <[email protected]>
Records the fix for the engine's memory growth in long sessions that publish telemetry to Dagger Cloud. Signed-off-by: Alex Suraci <[email protected]>
vito
added a commit
to vito/dagger
that referenced
this pull request
Oct 29, 2026
Include delta temporality for engine Cloud metrics so completed metric series are not retained and exported again on every collection. Signed-off-by: Alex Suraci <[email protected]>
vito
added a commit
to vito/dagger
that referenced
this pull request
Oct 29, 2026
Record the Cloud metric temporality merge and unchanged local dependency edits. Builds and tests remain skipped for dogfooding. Signed-off-by: Alex Suraci <[email protected]>
tiborvass
approved these changes
Oct 29, 2026
matipan
approved these changes
Oct 29, 2026
This was referenced Oct 30, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Long-lived sessions that publish telemetry to Dagger Cloud from the engine leak memory until the engine is OOM-killed. A git-heavy agent session reached 20–33 GB in under an hour. Heap profiles put about 80% of it under
cloudMetricQueue.Export→proto.Clone, and about 10% undercumulativeLastValue.collect→collectExemplars.The session's Cloud metric reader took the OTLP HTTP exporter's default cumulative temporality. That's because
cloudMetricQueue.Temporalitydelegated to the exporter. A cumulative gauge never forgets an attribute set, and it re-exports every series it has seen at each collection, stamped with the collection time.Resource readings are keyed by span (
dagger.io/metrics.trace/dagger.io/metrics.span). Since helper-command accounting, every git/rg/patch call adds its own series too. So a long-lived client kept every series in memory and re-sent all of them every 5s. Once one upload took longer than 5s, the queue's deep copies piled up.Ingest side
This also affected the data. Cloud's
/v1/metricswrites every gauge point as a row inotel_metrics_gauges, and that table's readers treat each distinctTimeUnixas a sample:godmode.BillingDaily) counts each distinctmemory.currenttime as 5s;With cumulative export, a finished exec's or helper's last reading repeated as a new sample every 5s until its client closed. Billing for new orgs uses the separate workload export (its own provider, raw points drained per collection), and this PR doesn't touch it.
Fix
cloudMetricQueue.Temporalitynow always returns delta. That matches the client's own metric stream, which is what the CLI forwarded to Cloud before the engine published it. Each reading is exported once, and the reader forgets the series afterwards.TestSessionPublishesEachGaugeReadingToCloudOncerecords one gauge reading, runs several collections, and checks that Cloud receives exactly one point. Without the fix it received 4.