observability

package
v0.43.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 8, 2026 License: AGPL-3.0 Imports: 13 Imported by: 0

Documentation

Overview

Package observability owns the process-global OpenTelemetry tracer provider. It is initialized once during server startup and shut down once at exit, so tracing is server-level infrastructure rather than a toggleable plugin.

When OTEL_EXPORTER_OTLP_ENDPOINT is unset (or OTEL_SDK_DISABLED=true), Init is a no-op: the global provider stays the SDK default (no-op), and Shutdown does nothing. Exporter transport details (protocol, headers, TLS) are resolved by the OTel exporter from its standard environment variables.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Handler

func Handler(h http.Handler) http.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 an endpoint is set and the SDK is not disabled
	ServiceName string // OTel service name, defaults to "stella"
}

Config holds tracer settings derived from standard OTel environment variables. Exporter-level vars (endpoint, protocol, headers, TLS) are consumed by the auto exporter and are not duplicated here.

func LoadConfig

func LoadConfig() Config

LoadConfig reads OTel settings from the environment. Tracing is enabled when the auto 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 all trace export even when an endpoint is present.

type Provider

type Provider struct {
	// contains filtered or unexported fields
}

Provider is the lifecycle handle for the global tracer provider. The zero value (and any Provider returned when OTel is disabled) is a valid no-op: Shutdown returns nil without touching anything.

func Init

func Init(ctx context.Context) (*Provider, error)

Init loads OTel config and, when an exporter endpoint is configured, builds the tracer provider, installs it as the global provider, and returns a Provider whose Shutdown flushes pending spans. When disabled it returns a no-op Provider and leaves the global provider as the SDK default.

func (*Provider) Shutdown

func (p *Provider) Shutdown(ctx context.Context) error

Shutdown flushes pending spans and stops the provider. It is a no-op when OTel is disabled. The caller controls the deadline via ctx.

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL