Documentation
¶
Overview ¶
Package observability owns the process-global OpenTelemetry providers (tracer and logger). They are initialized once during server startup and shut down once at exit, so telemetry is server-level infrastructure rather than a toggleable plugin.
When no OTLP endpoint or signal-specific exporter is configured (or OTEL_SDK_DISABLED=true), Init is a no-op: the global providers stay the SDK defaults (no-op), and Shutdown does nothing. Exporter transport details (protocol, headers, TLS) are resolved by the OTel exporters from their standard environment variables.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Handler ¶
Handler wraps h with OpenTelemetry HTTP server instrumentation so every inbound request produces a server span. It is always applied: when tracing is disabled the global provider is a no-op, so wrapping adds negligible overhead and keeps the server's handler composition unconditional.
The span name formatter gives each span a "<METHOD> <templated-path>" name. Path segments that look like resource instance IDs are collapsed to a placeholder (see templatePath) so /api/projects/123 and /api/projects/456 share one span name — span names are an aggregation key, and raw instance paths would explode cardinality in the tracing backend.
Types ¶
type Config ¶
type Config struct {
Enabled bool // true when trace export is configured and the SDK is not disabled
ServiceName string // OTel service name, defaults to "stella"
}
Config holds OTel settings derived from standard environment variables. Exporter-level vars (endpoint, protocol, headers, TLS) are consumed by the auto exporters and are not duplicated here.
func LoadConfig ¶
func LoadConfig() Config
LoadConfig reads OTel settings from the environment. Tracing is enabled when the span exporter has something to export to — either an OTLP endpoint (the generic or traces-specific variable) or an explicit OTEL_TRACES_EXPORTER such as "console" — and the operator has not opted out. OTEL_SDK_DISABLED=true and OTEL_TRACES_EXPORTER=none are the standard kill switches; either silences trace export even when an endpoint is present.
type Provider ¶
type Provider struct {
// contains filtered or unexported fields
}
Provider is the lifecycle handle for global OTel providers. The zero value (and any Provider returned when OTel is disabled) is a valid no-op: Shutdown returns nil without touching anything.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package tracehook is the core agent trace hook: it logs LLM, tool, and memory activity via slog and, when OTel tracing is enabled, records the session/turn/LLM/tool/memory span hierarchy.
|
Package tracehook is the core agent trace hook: it logs LLM, tool, and memory activity via slog and, when OTel tracing is enabled, records the session/turn/LLM/tool/memory span hierarchy. |