Skip to content

cli/command: disable retries for the OTLP exporters - #7495

Open
azchohfi wants to merge 1 commit into
docker:masterfrom
azchohfi:otel-no-retry
Open

azchohfi wants to merge 1 commit into
docker:masterfrom
azchohfi:otel-no-retry

Conversation

@azchohfi

@azchohfi azchohfi commented Nov 6, 2026

Copy link
Copy Markdown

Summary

The CLI exports traces and metrics at exit with a 50ms budget (ExportTimeout). The OTLP gRPC exporters are created with the default retry policy, so when the endpoint refuses the connection the export backs off until the whole budget is used instead of failing right away. This happens on every command, docker --version included.

A common case is Docker Desktop's desktop-linux context while Desktop is not running: its metadata points OTEL_EXPORTER_OTLP_ENDPOINT at a unix socket that still exists as a file but has no listener. On Windows, Desktop leaves %LOCALAPPDATA%\Docker\run\userAnalyticsOtlpHttp.sock behind.

This passes WithRetry(RetryConfig{Enabled: false}) to both exporters. A retry cannot complete within 50ms anyway, so the only change is that a failed export gives up sooner.

To verify: with the Desktop context selected and Desktop stopped, time docker --version. Built from master (7c0f1b2) with and without this change (Go 1.27.3, CGO off), 30 interleaved runs, median of paired differences with 95% confidence interval:

difference
Windows 11 -45.3 ms (32.7 to 61.8)
Linux (WSL2, same kind of context with a stale socket file) -47.4 ms (41.8 to 51.5)

On v29.9.2 with 40 runs the same change gave -45.4 ms (44.0 to 46.1) on Windows and -50.0 ms (48.9 to 51.1) on Linux. With the default context it makes no difference. go test ./cli/command/... ./cli-plugins/... passes on Linux.

I used an AI assistant (GitHub Copilot) for the investigation and to help write this change; I reviewed and tested it.

Release notes (optional)

Don't wait for the telemetry export timeout when the OTLP endpoint refuses connections.

A picture of a cute animal (not mandatory but encouraged)

The CLI flushes traces and metrics at exit with a 50ms timeout
(ExportTimeout). The OTLP gRPC exporters were created with the default
retry policy, so when the endpoint refuses the connection the export
keeps backing off until the timeout expires instead of returning.

This happens on every command when the current context points at a
unix socket that has no listener, for example Docker Desktop's context
while Desktop is not running, which leaves its analytics socket file
behind. A retry cannot complete within 50ms anyway, so turn retries off.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Signed-off-by: Alexandre Zollinger Chohfi <alzollin@microsoft.com>
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.

1 participant