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 ConsoleOnlyLogger ¶
ConsoleOnlyLogger returns a logger that bypasses the OTLP leg. It is for diagnostic details that may contain raw upstream error text; all routine records must continue through slog.Default().
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.
func NewTraceContextHandler ¶
NewTraceContextHandler wraps next so records logged with a span-carrying context (the slog *Context variants) gain trace_id/span_id attributes. The OTLP log bridge extracts trace context natively; this wrapper gives the console output the same correlation, so an operator can jump from a stderr line to the trace in their backend. Records logged without a context pass through unchanged.
func RecordSpanError ¶
RecordSpanError records only a closed error class on a span. Error messages can contain upstream bodies, commands, URLs, or prompt fragments, so they stay in logs and never become exported span status text or exception events.
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. Whether a signal is exporting is decided by package otelenv, which is also what the HTTP transport asks before it emits provider spans — one answer, one place.
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.
func Init ¶
Init loads OTel config and, when an exporter endpoint is configured, builds the enabled providers, installs them as globals, and returns a Provider whose Shutdown flushes pending telemetry. When disabled it returns a no-op Provider and leaves the global providers as the SDK defaults.
func (*Provider) ForceFlushLogs ¶
ForceFlushLogs makes log-export tests and controlled shutdown paths wait for the current batch without exposing the provider implementation.
func (*Provider) MetricsEnabled ¶
MetricsEnabled reports whether Init installed a real meter provider.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package metrichook records bounded agent-loop metrics from the core hook payloads.
|
Package metrichook records bounded agent-loop metrics from the core hook payloads. |