From b9faedfdb0e8012cea70a12981b8b256bda7af0b Mon Sep 17 00:00:00 2001 From: Xav Paice Date: Tue, 11 Aug 2026 03:17:10 +1200 Subject: [PATCH] fix(preflight): add tracing span and align error handling for host collector redaction (#2102) * fix(preflight): add tracing span and align error handling for host collector redaction Follow-up to #2101. Adds an OpenTelemetry span around host collector redaction and returns the unredacted collectResult on redaction failure, matching the behavior of remote host collectors and in-cluster support-bundle collectors. * fix(preflight): assign collected data before redaction so errors preserve output --- pkg/preflight/collect.go | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/pkg/preflight/collect.go b/pkg/preflight/collect.go index cc91a18e..73b17afa 100644 --- a/pkg/preflight/collect.go +++ b/pkg/preflight/collect.go @@ -145,17 +145,23 @@ func CollectHostWithContext( span.End() } + // The values of map entries will contain the collected data in bytes if the data was not stored to disk + collectResult.AllCollectedData = allCollectedData + // Local host preflight collectors are the only collection path (cluster, // remote host, in-cluster support bundle) that skipped redaction entirely. // A `run` collector's captured environment in particular can carry // credentials verbatim (e.g. HTTPS_PROXY with embedded Basic Auth) into // the bundle. See https://github.com/replicatedhq/troubleshoot/issues/2100. + _, span := otel.Tracer(constants.LIB_TRACER_NAME).Start(ctx, "Host collectors") + span.SetAttributes(attribute.String("type", "Redactors")) if err := collect.RedactResult(opts.BundlePath, collect.CollectorResult(allCollectedData), nil); err != nil { - return nil, errors.Wrap(err, "failed to redact host collector results") + err = errors.Wrap(err, "failed to redact host collector results") + span.SetStatus(codes.Error, err.Error()) + span.End() + return collectResult, err } - - // The values of map entries will contain the collected data in bytes if the data was not stored to disk - collectResult.AllCollectedData = allCollectedData + span.End() return collectResult, nil }