Documentation
¶
Overview ¶
Package config parses the WAVEFRONT_* environment once at startup into an immutable Config. Required vars missing ⇒ MissingError; malformed values ⇒ InvalidError (both name the offending var). Load uses the functional-options pattern: production calls config.Load(); tests inject a fixed environment with config.Load(config.WithLookup(fake)).
Recognised environment variables:
WAVEFRONT_BUNDLE_PATH — path to the bundle directory (required) WAVEFRONT_UPSTREAM_BASE_URL — default backend base URL (required) WAVEFRONT_TARGETS — named backend targets, comma-separated name=url pairs WAVEFRONT_LISTEN_ADDR — data-plane listen address (default 0.0.0.0:8080) WAVEFRONT_METRICS_ADDR — ops/metrics listen address (default 0.0.0.0:9090) WAVEFRONT_CONTRACT_VERSION_HEADER — header carrying the contract version (default X-Api-Contract-Version) WAVEFRONT_REQUEST_TIMEOUT_MS — per-request upstream timeout in ms (default 15000) WAVEFRONT_READ_HEADER_TIMEOUT_MS — data-plane ReadHeaderTimeout in ms (default 10000) WAVEFRONT_READ_TIMEOUT_MS — data-plane ReadTimeout (headers+body) in ms (default 30000) WAVEFRONT_MAX_BODY_BYTES — maximum request body size in bytes (default 1048576) WAVEFRONT_LOG_LEVEL — log level: debug|info|warn|error (default info) WAVEFRONT_TRACES_OTLP_ENDPOINT — OTLP/HTTP collector base URL; unset disables tracing WAVEFRONT_TRACES_SERVICE_NAME — resource service.name on emitted spans (default wavefront) WAVEFRONT_TRACES_SAMPLE_RATIO — root-trace sample probability in (0,1] (default 1)
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func OpsAddr ¶ added in v0.7.3
OpsAddr resolves the ops/metrics listen address exactly as Load does — WAVEFRONT_METRICS_ADDR, or its default when unset/blank — without touching the rest of the configuration. The container self-probe uses it: a probe must reach the same configured ops port the server bound, and must not fail because serving-only required vars (bundle path, upstream URL) are absent. No validation: a malformed value simply fails the probe's dial, which is the correct healthcheck outcome.
Types ¶
type Config ¶
type Config struct {
BundlePath string
UpstreamBaseURL string
Targets map[string]string
ListenAddr string
MetricsAddr string
ContractVersionHeader string
RequestTimeout time.Duration
ReadHeaderTimeout time.Duration
ReadTimeout time.Duration
MaxBodyBytes int64
LogLevel slog.Level
TracesEndpoint string
TracesServiceName string
TracesSampleRatio float64
}
type InvalidError ¶
func (*InvalidError) Error ¶
func (e *InvalidError) Error() string
func (*InvalidError) Unwrap ¶
func (e *InvalidError) Unwrap() error
type Lookuper ¶
Lookuper resolves an environment variable: its value and whether it is set. It matches the signature of os.LookupEnv.
type MissingError ¶
type MissingError struct{ Var string }
func (*MissingError) Error ¶
func (e *MissingError) Error() string