Documentation
¶
Overview ¶
Package telemetry wires codebot's LLM observability. It builds an OTLP/HTTP trace exporter for the configured backend (e.g. Langfuse) and returns a litellm hook that emits one generation span per LLM call — each tagged with the current session id so the backend groups a run's calls — plus a BindSession to supply that id once the session exists and a shutdown func that flushes pending spans. When disabled it is a no-op, so the rest of the app stays unaware of OpenTelemetry.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BindSession ¶
type BindSession func(provider func() string)
BindSession registers the provider that yields the current session id, used to tag every generation span so the backend (e.g. Langfuse) can group a session's calls. The hook is built at boot, before the session exists, so the binding happens later; the provider is read live on each call, so a mid-run session switch is reflected without re-binding.
func Setup ¶
func Setup(ctx context.Context, cfg config.TelemetryConfig) (litellm.Hook, BindSession, func(context.Context) error, error)
Setup builds the trace pipeline for cfg and returns: a litellm hook to register on every model, a BindSession to wire the session-id provider once the session is built, and a shutdown func that flushes pending spans. When telemetry is disabled it returns (nil, no-op bind, no-op shutdown, nil); callers register the hook only when it is non-nil.