Skip to content

cli: fix memory, duplicate logs and dropped collector spans; fix two dagger check reports - #15100

Merged
sipsma merged 11 commits into
mainfrom
sipsma/cli-fixes-memory-logs-checks
Nov 9, 2026
Merged

sipsma merged 11 commits into
mainfrom
sipsma/cli-fixes-memory-logs-checks

Conversation

@sipsma

@sipsma sipsma commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

Five CLI fixes, each in its own commit or commits. Three make the CLI cheaper and more reliable on large runs and with telemetry. Two fix dagger check output.

CLI memory on heavy runs

The CLI kept every log twice: as raw output, and as a terminal screen built as it arrived, even for logs nothing ever shows. Now a log's screen is built only when something shows it.

On a heavy run (nine core/integration suites against a dev engine), peak CLI memory:

before after
output to a file 7.5 GB 2.9 GB
at a terminal 8.4 GB 3.2 GB

On the same run, CLI CPU time writing to a file went from 208 s to 147 s. Wall time was not slower: 693 s to 615 s to a file, 807 s to 620 s at a terminal. That is one run per mode, so the wall-time gain may be noise.

Cost: searching in the TUI builds every log's screen, so for the rest of that run memory returns to what it was before.

CLI CPU while many spans are running (now in #15080)

This PR first carried a fix for the CLI's CPU use while thousands of spans are running. #15080 merged the same change, so the commit left this PR at its rebase. Its changelog entry, which #15080 didn't add, is here and names #15080. With that fix alone, a heavy run's CLI kept up with the engine's telemetry but held so much of it that it was killed for memory on a 16 GB machine. The memory fix above cuts what the CLI holds.

Logs sent twice under a nested CLI

A dagger CLI run inside a container, or under dagger run, joins its parent's session. The engine already sends that nested CLI's telemetry to the parent, but the nested CLI also forwarded the engine's stream to the parent's collector. Every log record, such as a call result or an exec's output, reached the parent's display and Dagger Cloud twice. The nested CLI now forwards the engine's stream without that collector; its own telemetry still goes there.

On the TestCall suite, the CLI exported 15,747 duplicate log records before (34 MB, 29% of that suite's log text) and none after. Total log text went from 118 MB to 83 MB.

Tradeoff: if a user points a nested CLI at their own collector (with OTEL_EXPORTER_OTLP_* set inside the container, or under dagger run), that collector no longer receives the nested CLI's engine-side records, only the CLI's own telemetry. The top-level CLI's collector still receives everything.

Spans dropped on the way to your own OpenTelemetry collector

A collector configured with OTEL_EXPORTER_OTLP_* got the OpenTelemetry SDK's default span queue of 2,048, which silently drops a burst of the engine spans the CLI forwards. It now gets the same bounded queue of 16,384 spans as the Dagger Cloud exporter. In a reproduction forwarding a 5,000-span burst to a collector, 2,560 spans arrived before and all 5,000 after.

Bursts beyond 16,384 still drop, as they do for Dagger Cloud. When any do, the CLI now says so on stderr after its final output:

WARNING: <N> of <M> spans were not sent to the OpenTelemetry collector configured by OTEL_EXPORTER_OTLP_*: its queue was full, or exiting timed out

Cost, only while the collector falls behind a burst: up to about 8x more spans held in memory (17 MiB instead of 4 MiB in the test), and a longer flush at exit (6.8 s instead of 1.0 s with a collector taking 200 ms per request, still capped at 30 s). It never blocks the command. Log export to the collector is unchanged.

dagger check <name> on a check with no items

A check whose collection has no items failed with no checks matched pattern. It now passes with nothing run, and prints on stderr:

check "<name>" has no items to check

This matches what Dagger Cloud CI does for such checks. A name that matches no check still fails, and so do collection keys or --skip filters that leave out every item.

dagger check report after #15088

#15088 grouped a collection's checks under one check, which changed two parts of the report. This restores what came before it, while keeping the items nested under their collection. For a collection packages/tests/verify whose items Foo and Bar both fail:

top CHECKS line RUN LOCALLY hint
before #15088 ✘ 2 failed one dagger check line per failed item
main ✘ 1 failed dagger check "packages/tests/verify", which reruns the whole collection
this PR ✘ 2 failed one dagger check line per failed item

The "RE-RUN IN CI" line still names the collection, which Dagger Cloud reports as the group. Only the report text changes.

Notes for review

  • The nested-CLI commit comes after the collector commits. The collector change configures the collector's exporters in the CLI instead of having them detected at telemetry setup, so the nested-CLI change finds them where the CLI now puts them.
  • Each fix's tests fail without its change and pass with it. The new tests run in CI: the TUI and span tests in the package tests, the collector tests with the other internal/cmd/dagger unit tests, and the check and nested-CLI tests in core/integration.
  • The report fix fixes a regression that hasn't shipped yet, so it has no changelog entry of its own; the other four do, plus the CPU fix's entry for Fresh dagger check -l of dagger/dagger in under 5 s: per-package Go builds, a pre-warmed engine cache, and faster module loading and check planning #15080.

sipsma added a commit that referenced this pull request Nov 7, 2026
Five of the fixes change what users see. The dagger check report fix
restores behavior from before #15088, which hasn't been released, so it
has no entry of its own.

Signed-off-by: Erik Sipsma <[email protected]>
sipsma added a commit that referenced this pull request Nov 9, 2026
Four of the fixes change what users see. The CLI CPU fix reached main
with #15080, which added no entry, so its entry names #15080. The
dagger check report fix restores behavior from before #15088, which
hasn't been released, so it has no entry of its own.

Signed-off-by: Erik Sipsma <[email protected]>
@sipsma
sipsma force-pushed the sipsma/cli-fixes-memory-logs-checks branch from 3718dc0 to 773eb58 Compare November 9, 2026 20:48
@sipsma sipsma changed the title cli: fix memory, CPU, duplicate logs and dropped collector spans; fix two dagger check reports cli: fix memory, duplicate logs and dropped collector spans; fix two dagger check reports Nov 9, 2026
sipsma added 11 commits November 9, 2026 21:38
Since collection items are grouped under one check, the failing
report's RUN LOCALLY section named the group, which reruns the whole
collection. Suggest the address of each failed item instead, as before
the grouping. The native CI re-run still targets the group, the unit
Cloud reports.

Signed-off-by: Erik Sipsma <[email protected]>
A zoom to one collection item scopes the surfaced checks to that item,
so the CI re-run line named the item instead of its group. Find the
group through the item's span ancestors instead. Name the test's items
the way the engine does.

Signed-off-by: Erik Sipsma <[email protected]>
Since collection items are grouped under one check, the report's top
CHECKS header counted the whole collection as one check, so a run with
several failing items read "1 failed" while the nested header held the
real totals. Count a group as the items that ran, as the tally read
before the grouping.

Signed-off-by: Erik Sipsma <[email protected]>
'dagger check <name>' decided that nothing matched by counting the
results of the checks it ran. A check whose collection has no items,
such as a Go test check in a repository without tests, runs nothing, so
it failed with "no checks matched pattern" even though 'dagger check -l'
lists it.

When a run produces no results and the command names no collection
keys, in an address or a dimension flag, and skips no items by key,
every selected check was fully expanded and has no items. The run then
passes and says on stderr that each check has no items to check.
Patterns that select no check, and keys or keyed skips that leave out
every item, still fail with the existing error.

Signed-off-by: Erik Sipsma <[email protected]>
A span's log kept every byte twice for the whole run: the raw bytes, and
a midterm screen that stores each character as a rune plus its format.
That's about 7.5 bytes of heap per byte logged, and most logs are never
shown. A long test run streams hundreds of megabytes of logs, mostly the
results of calls that return strings, which the engine logs onto their
spans, so the CLI grew by gigabytes.

Now a log of plain writes keeps only its raw bytes until something reads
its screen (drawing it, a report, the pager, a search), which replays
them into a new screen. Resizes made before then are replayed where they
happened, since midterm doesn't reflow rows already written. What is
shown doesn't change.

Signed-off-by: Erik Sipsma <[email protected]>
The CLI forwards every engine span it receives to each of its span
processors, including the one for a collector configured with
OTEL_EXPORTER_OTLP_*. telemetry.Init's Detect gave that collector the
OpenTelemetry SDK's default batch processor, whose 2048-slot queue drops
spans without a word when full. A burst of forwarded engine spans then
arrives at the collector cut short: in a reproduction forwarding 5,000
finished spans to a local collector, 2,560 arrived.

Configure the collector's exporters in the CLI instead, as it already
does for Cloud, and give its spans the same 16Ki-slot bounded queue as
the Cloud exporter. Batches keep the SDK's default size, since a
collector may limit how large a request it accepts. Logs and metrics are
set up as Detect did.

Signed-off-by: Erik Sipsma <[email protected]>
The queue for a collector configured with OTEL_EXPORTER_OTLP_* is
bounded, and drops spans rather than stall the build when a burst
outgrows it. Count what it takes in and hands on, as the engine does for
its own span queues, and once telemetry has shut down tell the user on
stderr how many spans never reached the collector's exporter: those
dropped when the queue was full, and any still queued when exiting ran
out of time.

Signed-off-by: Erik Sipsma <[email protected]>
The warning was written while the pretty frontend could still own the
terminal. On a terminal without synchronized output it may be drawing
on the alternate screen, and stopping the TUI then restores the normal
screen, losing the warning. Report it once Frontend.Run has returned,
after the final render, from both places that set up engine telemetry.

Signed-off-by: Erik Sipsma <[email protected]>
A CLI run in an exec with privileged nesting, or under `dagger run`, joins
its parent's session as a nested client. The engine writes a nested
client's spans, logs and metrics to every ancestor client's store as well
as its own, so the parent already receives everything the engine streams
to the nested CLI. The nested CLI also forwarded that stream to the
collector exporters it configures from OTEL_EXPORTER_OTLP_*, which lead to
the same parent: the exec's telemetry proxy, or the parent CLI's. Spans
are stored by ID, so the second copy went unnoticed, but every log record
reached the parent, its frontend and Dagger Cloud twice: each call result
and each exec's output under a nested CLI showed up doubled.

A nested client now forwards the engine's telemetry without the collector
exporters. Its own telemetry still goes to them, and it still shows the
stream and publishes it to Cloud as before.

Signed-off-by: Erik Sipsma <[email protected]>
Four of the fixes change what users see. The CLI CPU fix reached main
with #15080, which added no entry, so its entry names #15080. The
dagger check report fix restores behavior from before #15088, which
hasn't been released, so it has no entry of its own.

Signed-off-by: Erik Sipsma <[email protected]>
golangci-lint flagged three spots in this PR's changes. The new
dagger check helpers deliberately answer "keyed" when a key doesn't
resolve, so the run reports its own error. The rerun section grew past
the complexity limit with the collection-item suggestions. The telemetry
config test needs only the config.

Signed-off-by: Erik Sipsma <[email protected]>
@sipsma
sipsma force-pushed the sipsma/cli-fixes-memory-logs-checks branch from 773eb58 to 4f27d6c Compare November 9, 2026 21:38
@sipsma
sipsma merged commit ce1dceb into main Nov 9, 2026
97 checks passed
@sipsma
sipsma deleted the sipsma/cli-fixes-memory-logs-checks branch November 9, 2026 22:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants