Documentation
¶
Overview ¶
Package errcapture captures a runner job execution's error-level log output so it can be attached to the failed execution result as rich diagnostics.
Why this exists: tools like terraform emit their real error detail (e.g. an AWS "AccessDenied ... is not authorized to perform: s3:CreateBucket") into the log stream via structured @level:"error" records, while the Go error the runner wraps up is often just "exit status 1". ctl-api parses the failed result's error text into a structured composite error, so it needs the rich text, not the thin wrapper.
A Capture is a zapcore.Core teed into the per-execution job logger. It records error-level entries into a bounded in-memory buffer. The runner's API client decorator reads the buffer and attaches it to the result under MetadataKey when a job reports failure — one universal chokepoint, no per-handler wiring.
Index ¶
Constants ¶
const MetadataKey = "error_output"
MetadataKey is the error-metadata key the captured output is attached under. It must match the key ctl-api prefers when parsing a failed result (services/ctl-api/.../create_runner_job_execution_result.go: errMetaKeyOutput).
Variables ¶
This section is empty.
Functions ¶
func NewContext ¶
NewContext returns ctx carrying cap so downstream code (the API client decorator) can read the captured output.
Types ¶
type Capture ¶
type Capture struct {
// contains filtered or unexported fields
}
Capture accumulates error-level log lines for one job execution. It is safe for concurrent use: the job logger it feeds is shared across the execution's goroutines (steps, monitor).
func FromContext ¶
FromContext returns the Capture on ctx, or nil when none is set.