Documentation
¶
Overview ¶
Package httplog wraps an http.RoundTripper to emit gojira's structured, correlatable, credential-redacted view of every HTTP request the client makes. It is the response-stream half of the crawl observability instrument (the orchestration-stream half lives in internal/crawl).
Two log levels matter here:
INFO: one summary line per request — method, URL path, status, duration_ms, bytes — always emitted. This is the at-a-glance measurement record per call.
LevelTrace (from gojira's log package, below slog.LevelDebug): the full lifecycle — net/http/httptrace timings (DNS, connect, TLS, TTFB, conn-reuse) plus the raw response body and response headers. The httptrace machinery is only installed when the active logger is enabled at LevelTrace, keeping the hot path allocation-light on normal info-level runs.
Every record is tagged with trace_stream="response" so it can be filtered alongside the orchestration-stream events the crawl emits.
Credential redaction is ABSOLUTE: Authorization, Proxy-Authorization, Cookie, Set-Cookie, and X-Atlassian-Token are replaced with the literal "REDACTED" wherever they appear, including at trace level. The crawl observability PRD enforces this as a non-negotiable invariant; tests in this package grep the captured buffer for the raw token bytes and fail if they leak.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type RoundTripper ¶
type RoundTripper struct {
// Base is the underlying transport. When nil, [http.DefaultTransport]
// is used at RoundTrip time. Wrapping rather than embedding keeps the
// composition explicit at call sites.
Base http.RoundTripper
// Logger is the fallback sink when the per-request context does NOT
// carry a logger (see [trace.LoggerFrom]). When both are nil,
// [slog.Default] is used.
Logger *slog.Logger
}
RoundTripper wraps a base http.RoundTripper and logs every request's lifecycle through slog with redaction. It is intended to be installed on the gojira client via client.WithLogger / client.WithRoundTripper for crawl observability. The transport is concurrency-safe iff the base transport is.
func New ¶
func New(base http.RoundTripper, logger *slog.Logger) *RoundTripper
New constructs a RoundTripper. Either argument may be nil; sensible defaults are applied at RoundTrip time so the type is total — no configuration required to get a working instance.
func (*RoundTripper) RoundTrip ¶
RoundTrip executes req through the base transport, logging the request summary at INFO and (when the active logger is enabled at LevelTrace) the full httptrace lifecycle and raw response body. The returned *Response carries a body that has already been read into memory and re-wrapped in an io.NopCloser, so downstream consumers see exactly the same payload the wire delivered.