feat(tracing): surface otel shutdown errors via --debug

OTel SDK/exporter errors already go through docker/cli's own
otel.SetErrorHandler(debug.OTELErrorHandler), installed by the plugin
framework at startup. Our own handler, installed at package init time,
was always clobbered before any command ran (plugin.Run() sets its handler
after all inits execute), so it never had any effect - verified by tracing
the exact call order and reproducing the flag behavior against a built
binary.

Drop that dead handler along with the COMPOSE_OTEL_DEBUG env var it
introduced. The one genuinely-discarded error (the tracer shutdown/flush
error in wrapRunE) now goes through logrus like everything else in the
codebase: it's already gated by --debug/-D via logrus's own level, so no
explicit check is needed.

Signed-off-by: hiroto.toyoda <[email protected]>
This commit is contained in:
hiroto.toyoda
2026-09-02 17:12:12 +02:00
committed by Guillaume Lours
parent d0c384aeae
commit 1ebdc06c18
3 changed files with 4 additions and 34 deletions
+4 -3
View File
@@ -26,6 +26,7 @@ import (
dockercli "github.com/docker/cli/cli"
"github.com/docker/cli/cli/command"
"github.com/sirupsen/logrus"
"github.com/spf13/cobra"
flag "github.com/spf13/pflag"
"go.opentelemetry.io/otel"
@@ -110,9 +111,9 @@ func wrapRunE(c *cobra.Command, cmdSpan trace.Span, tracingShutdown tracing.Shut
// been canceled already
ctx, cancel := context.WithTimeout(context.Background(), 100*time.Millisecond)
defer cancel()
// TODO(milas): add an env var to enable logging from the
// OTel components for debugging purposes
_ = tracingShutdown(ctx)
if err := tracingShutdown(ctx); err != nil {
logrus.WithError(err).Debug("otel: shutdown error")
}
}
return cmdErr
}