Documentation
¶
Overview ¶
Package cliboot owns the cross-binary boot scaffolding shared by the all-in-one duckgres binary, cmd/duckgres-worker, and cmd/duckgres-controlplane. It centralizes build-info reporting, slog/redaction wiring, and OTLP log/trace exporters so production observability stays identical regardless of which entry point runs.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func InitLogging ¶
func InitLogging() func()
InitLogging configures slog to send logs to PostHog via OTLP when POSTHOG_API_KEY is set. Additional PostHog projects can be targeted by setting ADDITIONAL_POSTHOG_API_KEYS to a comma-separated list of API keys. Logs always go to stderr; PostHog is additive. The log level is controlled by DUCKGRES_LOG_LEVEL (debug, info, warn, error). Returns a shutdown function that flushes all OTLP batch processors.
func InitMetrics ¶
InitMetrics starts the Prometheus metrics HTTP server on :9090/metrics and returns the *http.Server so callers can shut it down during graceful shutdown / handover. The listener loops on transient errors with a 1s backoff — production duckgres processes have run into ephemeral port rebinds during handover and we don't want metrics scraping to silently die. Workers in --mode duckdb-service intentionally do NOT call this: in K8s all worker pods would fight over :9090 since the control plane owns the metrics endpoint there.
func InitTracing ¶
func InitTracing() func()
InitTracing configures an OTLP trace exporter when OTEL_EXPORTER_OTLP_TRACES_ENDPOINT (or DUCKGRES_TRACE_ENDPOINT) is set. When no endpoint is configured, the global TracerProvider remains the default no-op, adding zero overhead. Returns a shutdown function that flushes the batch span processor.
Types ¶
type BuildInfo ¶
BuildInfo carries the version/commit/date triple that each binary receives via -ldflags -X main.* at link time. Each package main owns its own var version/commit/date because ldflags can only target package-main symbols; cliboot just reads them via a value-typed struct.
func (*BuildInfo) Enrich ¶
func (b *BuildInfo) Enrich()
Enrich backfills Commit/Date from runtime/debug VCS settings when ldflags did not provide them — useful for local `go run` / `go build` where the linker flags aren't passed. ldflags-supplied values always win; the dirty marker only applies to VCS-backfilled commits because the release pipeline owns ldflags-injected values.
type RedactingHandler ¶
RedactingHandler wraps an slog.Handler and scrubs password values from log messages and string attributes before forwarding to the inner handler.
type StampedHandler ¶
type StampedHandler struct {
// contains filtered or unexported fields
}
StampedHandler emits records as: time, level, pod, node, msg, attrs. slog.TextHandler forces attrs after msg, which pushes pod/node to the end of long lines. Putting them up front makes kubectl-logs triage scannable.
func NewStampedHandler ¶
func NewStampedHandler(out io.Writer, level slog.Level) *StampedHandler
NewStampedHandler returns a handler with pod/node env vars pre-attached, writing to the provided writer. Tests pass a bytes.Buffer; production passes os.Stderr via newStderrStampedHandler.