observability

package
v0.1.0-rc.1 Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2026 License: Apache-2.0 Imports: 27 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package observability provides the diagnostic log and OpenTelemetry export. Both are fed from the goroutines doing the work and written by dedicated background goroutines, so logging and tracing never wait on disk or network I/O.

Index

Constants

View Source
const ConversationID = attribute.Key("gen_ai.conversation.id")

ConversationID is the OpenTelemetry GenAI key for the session a span belongs to. The ADK sets it on its spans; ours use the same key so one query finds every turn of a session.

View Source
const DefaultEndpoint = "http://localhost:4318"

DefaultEndpoint is the OTLP/HTTP collector address from the OpenTelemetry spec. The Go exporters would otherwise default to https, which local collectors don't serve.

View Source
const ServiceName = "blitz"

ServiceName identifies Blitz in exported telemetry.

Variables

This section is empty.

Functions

func End

func End(span trace.Span, err error)

End records err (cancellation is not an error) and ends the span.

func OpenLog

func OpenLog(cfg config.LogConfig, r *redact.Redactor, extra ...slog.Handler) (*slog.Logger, io.Closer, error)

OpenLog returns a logger writing JSON lines to cfg.Dir (secrets masked) and to each extra handler (e.g. Telemetry.LogHandler), plus a func that flushes and closes the file. With level "off" only the extra handlers receive records, at info level.

func ParseLevel

func ParseLevel(s string) (level slog.Level, ok bool, err error)

ParseLevel maps a config level to slog; ok is false for "off".

func ParseTraceparent

func ParseTraceparent(tp string) (trace.SpanContext, bool)

ParseTraceparent decodes a W3C traceparent into a remote span context.

func Start

func Start(ctx context.Context, name string, attrs ...attribute.KeyValue) (context.Context, trace.Span)

Start begins a span on the current global provider (a no-op with telemetry off). Attributes must not carry content (prompts, file text, arguments): use sizes, names and outcomes.

func StartWith

func StartWith(ctx context.Context, name string, opts ...trace.SpanStartOption) (context.Context, trace.Span)

StartWith is Start with arbitrary span options, e.g. trace.WithLinks.

func Traceparent

func Traceparent(span trace.Span) string

Traceparent encodes a span's context in W3C Trace Context form, or "" when the span is not recording a real trace (telemetry off).

Types

type Telemetry

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

Telemetry owns the OpenTelemetry providers. A nil *Telemetry is valid and does nothing.

func NewTelemetry

func NewTelemetry(cfg config.TelemetryConfig, version string, r *redact.Redactor, spanExp sdktrace.SpanExporter, logExp sdklog.Exporter) *Telemetry

NewTelemetry installs global providers exporting through the given exporters (content filtering and masking still apply). StartTelemetry uses it with OTLP/HTTP exporters; embedders and tests can pass their own. Install telemetry once per process: the ADK binds its tracer to the first global provider, so spans from later providers would miss the ADK's.

func StartTelemetry

func StartTelemetry(ctx context.Context, cfg config.TelemetryConfig, version string, r *redact.Redactor) (*Telemetry, error)

StartTelemetry installs global trace and log providers exporting over OTLP/HTTP when cfg.Enabled; otherwise it returns nil. Export happens on the SDK's batch goroutines, so instrumented code only enqueues.

func (*Telemetry) Flush

func (t *Telemetry) Flush(ctx context.Context) error

Flush exports everything recorded so far.

func (*Telemetry) LogHandler

func (t *Telemetry) LogHandler() slog.Handler

LogHandler returns an slog handler that sends records to the collector, or nil when telemetry is off.

func (*Telemetry) Shutdown

func (t *Telemetry) Shutdown(ctx context.Context) error

Shutdown flushes pending spans and logs, waiting at most a few seconds.

Jump to

Keyboard shortcuts

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