Documentation
¶
Overview ¶
Package config loads api-log's runtime configuration from YAML and environment overrides. Layout follows ARCHITECTURE.md § 11.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
Proxy ProxyConfig `yaml:"proxy"`
API APIConfig `yaml:"api"`
Storage StorageConfig `yaml:"storage"`
Timeouts TimeoutsConfig `yaml:"timeouts"`
Shutdown ShutdownConfig `yaml:"shutdown"`
Logging LoggingConfig `yaml:"logging"`
Diagnostics DiagnosticsConfig `yaml:"diagnostics"`
Plugins PluginsConfig `yaml:"plugins"`
Media MediaConfig `yaml:"media"`
Viewer ViewerConfig `yaml:"viewer"`
}
Config is the parsed runtime config.
All durations are stored as time.Duration. YAML uses *_seconds keys so the config file stays readable; we convert on load.
func Defaults ¶
func Defaults() Config
Defaults returns a Config with the documented v0 defaults from ARCHITECTURE.md § 11.
type DiagnosticsConfig ¶
type DiagnosticsConfig struct {
// Cadence for the counter-snapshot INFO line. 0 disables.
// Default 60s; tight enough for prod incident timelines, loose
// enough not to spam logs.
SnapshotIntervalSeconds int `yaml:"snapshot_interval_seconds"`
}
Diagnostics knobs — periodic background work that doesn't touch the trace path; safe to leave at defaults.
func (DiagnosticsConfig) SnapshotInterval ¶
func (c DiagnosticsConfig) SnapshotInterval() time.Duration
type LoggingConfig ¶
type LoggingConfig struct {
Level string `yaml:"level"`
}
type MediaConfig ¶
type MediaConfig struct {
SaveAttachments bool `yaml:"save_attachments"`
}
MediaConfig governs per-trace media extraction (see phase-k-media-contract.md).
SaveAttachments=true makes the writer-side extractor walk request/response bodies for named base64 fields (image_url.url, source.data, inlineData, b64_json) and persist each as a derived file under <data_dir>/<YYYY-MM-DD>/<keyhash>/media/<trace_id>/<idx>.<ext>. The JSONL remains the source of truth (Backend §6); these files are a fast-read cache + export-bundling target.
Default is true (operator decision 2026-05-30). The runtime-overrides layer (internal/runtime) can flip this without a restart via PUT /api/config/media, and that override takes precedence over both yaml and env per contract § 6.
type PluginsConfig ¶
type PluginsConfig struct {
PathFilter pathfilter.Config `yaml:"path_filter"`
}
PluginsConfig holds per-plugin config subtrees for the Phase A observe-class plugin pipeline. The zero value disables every plugin (no plugins are constructed in main) — matching the documented "empty plugins block = current behavior" contract in uiux-research/plugin.md § 5.
PHASE A SCAFFOLD ONLY: this struct is parsed but NOT yet read by main.go to construct a plugin.Registry. The wiring lands in Phase A.1 as its own commit. Until then, populating this block has no runtime effect — the JSONL output is identical with or without it.
type ProxyConfig ¶
type ShutdownConfig ¶
type ShutdownConfig struct {
GraceSeconds int `yaml:"grace_seconds"`
}
func (ShutdownConfig) Grace ¶
func (c ShutdownConfig) Grace() time.Duration
type StorageConfig ¶
type TimeoutsConfig ¶
type TimeoutsConfig struct {
ReadHeaderSeconds int `yaml:"read_header_seconds"`
IdleSeconds int `yaml:"idle_seconds"`
StreamIdleSeconds int `yaml:"stream_idle_seconds"`
ReqBodyCaptureSeconds int `yaml:"req_body_capture_seconds"`
// End-to-end traces this slow trigger a WARN log + slow_traces++.
// 0 disables (no WARN). Default 30s.
SlowTraceSeconds int `yaml:"slow_trace_seconds"`
}
func (TimeoutsConfig) Idle ¶
func (c TimeoutsConfig) Idle() time.Duration
func (TimeoutsConfig) ReadHeader ¶
func (c TimeoutsConfig) ReadHeader() time.Duration
func (TimeoutsConfig) ReqBodyCapture ¶
func (c TimeoutsConfig) ReqBodyCapture() time.Duration
func (TimeoutsConfig) SlowTrace ¶
func (c TimeoutsConfig) SlowTrace() time.Duration
func (TimeoutsConfig) StreamIdle ¶
func (c TimeoutsConfig) StreamIdle() time.Duration
type ViewerConfig ¶
type ViewerConfig struct {
Enabled bool `yaml:"enabled"`
Repo string `yaml:"repo"`
Version string `yaml:"version"`
Sha256 string `yaml:"sha256"`
LocalPath string `yaml:"local_path"`
CacheDir string `yaml:"cache_dir"`
PublicPath string `yaml:"public_path"`
}
ViewerConfig governs the optional hosted-viewer feature (`/viewer/*`). The backend fetches the viewer's release `dist.zip` once at startup, sha-verifies it against a backend-pinned constant (cmd/api-log/viewer_pins.go), extracts to a local cache, and serves it. Defaults are ON, pinned to the backend's source-baked version + SHA.
Empty Repo / Version / Sha256 fields are filled in from the backend-pinned constants in main.go. An empty CacheDir is resolved to `<DataDir>/viewer-cache`. An empty PublicPath defaults to `/viewer`. LocalPath overrides the fetch entirely (offline mode).
Operator-override safety: if the operator overrides Repo or Version without supplying a matching Sha256 (and not using LocalPath), the viewerhost rejects the override — the binary stays up, but `/viewer/` returns 503 with a logged error. We never serve an unverified asset.