Skip to content

Commit 060fc3f

Browse files
committed
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.
1 parent 3c5bf74 commit 060fc3f

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

pkg/preflight/collect.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,9 +150,15 @@ func CollectHostWithContext(
150150
// A `run` collector's captured environment in particular can carry
151151
// credentials verbatim (e.g. HTTPS_PROXY with embedded Basic Auth) into
152152
// the bundle. See https://github.com/replicatedhq/troubleshoot/issues/2100.
153+
_, span := otel.Tracer(constants.LIB_TRACER_NAME).Start(ctx, "Host collectors")
154+
span.SetAttributes(attribute.String("type", "Redactors"))
153155
if err := collect.RedactResult(opts.BundlePath, collect.CollectorResult(allCollectedData), nil); err != nil {
154-
return nil, errors.Wrap(err, "failed to redact host collector results")
156+
err = errors.Wrap(err, "failed to redact host collector results")
157+
span.SetStatus(codes.Error, err.Error())
158+
span.End()
159+
return collectResult, err
155160
}
161+
span.End()
156162

157163
// The values of map entries will contain the collected data in bytes if the data was not stored to disk
158164
collectResult.AllCollectedData = allCollectedData

0 commit comments

Comments
 (0)