Documentation
¶
Overview ¶
Package telemetry wires OpenTelemetry traces, metrics and logs for the process.
The SDK is built by otelconf from OpenTelemetry's declarative configuration: the self-hoster points OTEL_CONFIG_FILE at a YAML file and decides there which signals go to which destination (any exporter, several at once, sampling, views). Without the file the process exports nothing over OTLP, so there is zero overhead out of the box (and in the test suite).
Wiring model mirrors the logging package: Setup installs the global OTel providers (otel.SetTracerProvider / otel.SetMeterProvider / propagator) once at boot, so every already-instrumented subsystem picks them up without being threaded a provider. In particular the ogen-generated HTTP servers fall back to otel.GetTracerProvider()/GetMeterProvider() (see gen/*/oas_cfg_gen.go), so all three API surfaces (site/external/collect) get request spans + HTTP metrics from the globals alone.
Metrics are also exposed as a Prometheus /metrics endpoint (pull), served only by the opt-in listener on SPHERICON_METRICS_ADDR (see MetricsServer, ADR 0018), never on the public port. That reader is attached to the same MeterProvider whatever the file says, so a file without a meter_provider section still serves /metrics.
Index ¶
- func MetricsHandler() http.Handler
- func ObserveLicenseExpired(expired func() bool) error
- func ObserveReleaseAvailable(latest func(context.Context) (string, error)) error
- func Setup(ctx context.Context, cfg *config.Config, env string, build BuildInfo) (func(context.Context) error, error)
- type BuildInfo
- type MetricsServer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MetricsHandler ¶
MetricsHandler returns the Prometheus exposition handler for /metrics. Safe to call before Setup (returns a 503 stub until Setup runs).
func ObserveLicenseExpired ¶
ObserveLicenseExpired registers sphericon_license_expired: 1 while the license key has lapsed and the Instance runs the core (ADR 0035), 0 otherwise, so the SaaS deployment alerts on it. Call it after Setup.
func ObserveReleaseAvailable ¶
ObserveReleaseAvailable registers sphericon_release_available{latest} 1 next to sphericon_build_info: present while the Release check (ADR 0032) has cached a newer release, absent otherwise. latest reads that cached result (it asks nobody) and runs on every scrape; a read that fails reports nothing and goes to OpenTelemetry's error handler. Call it after Setup.
func Setup ¶
func Setup(ctx context.Context, cfg *config.Config, env string, build BuildInfo) (func(context.Context) error, error)
Setup installs the global OTel providers and returns a shutdown that flushes and stops them. Call it once at boot after logging.Setup; run the returned shutdown after the HTTP server has stopped so the final batched spans/metrics flush.
Types ¶
type BuildInfo ¶
BuildInfo carries the binary's version metadata into the OTel resource so traces/metrics are attributable to a specific build.
type MetricsServer ¶
type MetricsServer = sidelistener.Server
MetricsServer is the opt-in Prometheus listener (ADR 0018): the only place /metrics is served. A nil *MetricsServer means the listener is disabled: every method is a no-op on it.
func NewMetricsServer ¶
func NewMetricsServer(addr string) *MetricsServer
NewMetricsServer builds a server for addr (host:port) serving only /metrics.