Documentation
¶
Overview ¶
Package telemetry initializes OpenTelemetry for the agent loop.
Telemetry is off by default — no exporter is configured — so a fresh invocation makes zero outbound network calls. Consumers opt in by setting one of:
- "console" — writes spans to stderr; useful for local debug
- "otlp" — honors standard OTEL env vars (OTEL_EXPORTER_OTLP_ENDPOINT, etc.) to ship to a collector
- "none" — the default; no spans leave
The mode is normally set via cfg.OTEL.Exporter in .agents/config.json, but the standard OpenTelemetry SDK env var `OTEL_TRACES_EXPORTER` overrides when set (matches the OTel spec's env-var-wins convention). This is the load-bearing knob for multi-daemon k8s deployments where the base ConfigMap is shared across Pods but each Pod's exporter target differs — operators wire it via a per-Deployment env-var patch instead of duplicating config.json per daemon.
ADK's telemetry.New constructs providers but does NOT install them as OTEL globals; you must call SetGlobalOtelProviders explicitly or ADK's instrumentation will run against the noop tracer. This package handles that.
Index ¶
Constants ¶
const ( ModeNone = "none" // default; no spans exported ModeConsole = "console" // stdout exporter; for local dev ModeOTLP = "otlp" // honors OTEL_EXPORTER_OTLP_ENDPOINT etc. )
Mode names recognized by Setup.
const TracesExporterEnvVar = "OTEL_TRACES_EXPORTER"
TracesExporterEnvVar names the OTel-standard env var that overrides the config-file exporter mode. Same shape as the mode arg: "none", "console", or "otlp". Unknown values fall through to the mode switch below and return the same error the config-file path does.
Variables ¶
This section is empty.
Functions ¶
func Setup ¶
Setup configures OpenTelemetry. Returns a shutdown function the caller MUST call (typically deferred) so buffered spans get flushed.
When mode is "" or "none", no providers are constructed and the shutdown returns nil — call sites stay clean either way.
The OTel-standard env var `OTEL_TRACES_EXPORTER` overrides the passed mode when set. This is the load-bearing knob for k8s deployments with shared ConfigMaps but per-Pod exporter targets: operators patch the Deployment env instead of forking config.json. The override runs before the mode-validation switch, so an invalid env-var value produces the same clear error as an invalid config value.
Types ¶
This section is empty.