cli/command: disable retries for the OTLP exporters

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>
This commit is contained in:
Alexandre Zollinger Chohfi
2026-11-06 11:00:59 -08:00
co-authored by Copilot App
parent 7c0f1b261a
commit a5d7547c39
+5
View File
@@ -99,6 +99,10 @@ func dockerSpanExporter(ctx context.Context, cli Cli) []sdktrace.TracerProviderO
opts := []otlptracegrpc.Option{
otlptracegrpc.WithEndpoint(endpoint),
// The whole export is bounded by ExportTimeout, which is too short for a retry
// backoff to complete. With retries on, a refused connection (for example a stale
// Docker Desktop socket) waits out the full timeout instead of failing right away.
otlptracegrpc.WithRetry(otlptracegrpc.RetryConfig{Enabled: false}),
}
if !secure {
opts = append(opts, otlptracegrpc.WithInsecure())
@@ -120,6 +124,7 @@ func dockerMetricExporter(ctx context.Context, cli Cli) []sdkmetric.Option {
opts := []otlpmetricgrpc.Option{
otlpmetricgrpc.WithEndpoint(endpoint),
otlpmetricgrpc.WithRetry(otlpmetricgrpc.RetryConfig{Enabled: false}),
}
if !secure {
opts = append(opts, otlpmetricgrpc.WithInsecure())