Skip to content

Commit b9faedf

Browse files
authored
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
1 parent 3db6a99 commit b9faedf

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

pkg/preflight/collect.go

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -145,17 +145,23 @@ func CollectHostWithContext(
145145
span.End()
146146
}
147147

148+
// The values of map entries will contain the collected data in bytes if the data was not stored to disk
149+
collectResult.AllCollectedData = allCollectedData
150+
148151
// Local host preflight collectors are the only collection path (cluster,
149152
// remote host, in-cluster support bundle) that skipped redaction entirely.
150153
// A `run` collector's captured environment in particular can carry
151154
// credentials verbatim (e.g. HTTPS_PROXY with embedded Basic Auth) into
152155
// the bundle. See https://github.com/replicatedhq/troubleshoot/issues/2100.
156+
_, span := otel.Tracer(constants.LIB_TRACER_NAME).Start(ctx, "Host collectors")
157+
span.SetAttributes(attribute.String("type", "Redactors"))
153158
if err := collect.RedactResult(opts.BundlePath, collect.CollectorResult(allCollectedData), nil); err != nil {
154-
return nil, errors.Wrap(err, "failed to redact host collector results")
159+
err = errors.Wrap(err, "failed to redact host collector results")
160+
span.SetStatus(codes.Error, err.Error())
161+
span.End()
162+
return collectResult, err
155163
}
156-
157-
// The values of map entries will contain the collected data in bytes if the data was not stored to disk
158-
collectResult.AllCollectedData = allCollectedData
164+
span.End()
159165

160166
return collectResult, nil
161167
}

0 commit comments

Comments
 (0)