observability

package
v0.22.171 Latest Latest
Warning

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

Go to latest
Published: May 26, 2026 License: MIT Imports: 14 Imported by: 0 modules, 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 — OpenTelemetry instrumentation seam for the dispatch surface (ADR-014 carry-over T1, design from the 2026-04-26 multi-CLI fan-out).

One Observer per `clawtool` process. Disabled = pointer-cheap no-op: StartSpan returns the input ctx and a no-op end func, RecordError is a void call. Enabled hooks an OTLP/HTTP exporter (Langfuse- compatible when the operator wires its public/secret key) into the global tracer provider; Supervisor.Send and Transport.startStreamingExec open spans on top.

Per ADR-007 we wrap go.opentelemetry.io/otel and friends; we do not invent trace context propagation, sampler logic, or exporter transport. Adding a new exporter (Datadog, Honeycomb) is a one-file extension; the Observer surface stays stable.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type EndFunc

type EndFunc func()

EndFunc closes a span. Returned by StartSpan; safe to call on a disabled Observer (no-op).

type Observer

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

Observer is the single seam every dispatch goes through. The zero value is a usable no-op; Init upgrades it to a live tracer when the operator's config opts in.

func New

func New() *Observer

New returns a zero-value Observer. Equivalent to a disabled observer; safe to use immediately.

func (*Observer) Enabled

func (o *Observer) Enabled() bool

Enabled reports whether the observer is wired to a live exporter. Useful for tests and for skipping expensive attribute construction behind a cheap check.

func (*Observer) Init

Init wires the OTLP/HTTP exporter and tracer provider when cfg.Enabled is true. When disabled, returns nil and leaves the observer in no-op mode.

Init is idempotent within a single process: a second call is a no-op. To re-configure call Shutdown first.

func (*Observer) RecordError

func (o *Observer) RecordError(ctx context.Context, err error)

RecordError attaches an error to the span carried in ctx and marks the span's status. No-op on a disabled observer or when ctx carries no active span.

func (*Observer) SetAttributes

func (o *Observer) SetAttributes(ctx context.Context, attrs ...attribute.KeyValue)

SetAttributes adds attributes to the active span in ctx. No-op when disabled or when ctx has no recording span.

func (*Observer) Shutdown

func (o *Observer) Shutdown(ctx context.Context) error

Shutdown flushes pending spans and tears down the tracer provider. Idempotent. Always safe to call (no-op when disabled).

func (*Observer) StartSpan

func (o *Observer) StartSpan(ctx context.Context, name string, attrs ...attribute.KeyValue) (context.Context, EndFunc)

StartSpan opens a span named `name`. Returns the derived context and an end func. On a disabled observer, returns the input ctx and a no-op end. Caller convention: `ctx, end := obs.StartSpan(ctx, "agents.Send"); defer end()`.

Jump to

Keyboard shortcuts

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