tracing

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2026 License: BSD-2-Clause Imports: 7 Imported by: 0

Documentation

Overview

Package tracing wires OpenTelemetry tracing into a jargo voice agent.

The service processors emit spans through the global tracer, so instrumentation costs nothing until a TracerProvider is installed — without one, Tracer returns a no-op. Call Init at startup to export spans over OTLP, and wrap each session in StartConversation so the per-turn LLM and TTS spans nest under a single trace:

shutdown, err := tracing.Init(ctx, tracing.Config{ServiceName: "voicebot"})
defer shutdown(context.Background())
...
ctx, span := tracing.StartConversation(ctx, sessionID)
defer span.End()
task.Run(ctx) // LLM/TTS spans nest under the conversation span

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Init

func Init(ctx context.Context, cfg Config) (func(context.Context) error, error)

Init installs a global TracerProvider that batches spans to an OTLP HTTP collector, and returns a shutdown function that flushes and stops it. Call the returned function on exit. The service processors begin emitting spans as soon as the provider is installed.

func StartConversation

func StartConversation(ctx context.Context, id string) (context.Context, trace.Span)

StartConversation begins the root span for one session. The returned context carries the span, so service spans created while processing the session's frames nest under it; pass it to pipeline.Task.Run. Call End on the returned span when the session ends.

func Tracer

func Tracer() trace.Tracer

Tracer returns jargo's tracer from the global TracerProvider. Before Init (or any other provider) is installed, this is a no-op tracer.

Types

type Config

type Config struct {
	// ServiceName labels the traces; defaults to "jargo".
	ServiceName string
	// ServiceVersion is an optional version label.
	ServiceVersion string
	// Endpoint overrides the OTLP HTTP endpoint (host:port). Empty honors the
	// standard OTEL_EXPORTER_OTLP_ENDPOINT environment variable.
	Endpoint string
	// Insecure sends over plain HTTP instead of HTTPS.
	Insecure bool
	// SampleRatio is the head-sampling ratio in (0,1]. Zero (or less) always
	// samples — jargo traces are low-volume, one trace per session.
	SampleRatio float64
}

Config configures OTLP export.

Jump to

Keyboard shortcuts

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