telemetry

package
v0.1.20 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2026 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Overview

Package telemetry defines minimal tracing interfaces used across the ai-sdk codebase. The package is intentionally small and dependency-free — concrete bridging implementations (for example OpenTelemetry) live in the middleware/ or provider-specific packages.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type NoopSpan

type NoopSpan struct{}

NoopSpan is a span that performs no operations. Use when telemetry is disabled to avoid nil checks in call sites.

func (NoopSpan) End

func (NoopSpan) End()

func (NoopSpan) RecordError

func (NoopSpan) RecordError(err error)

func (NoopSpan) SetAttribute

func (NoopSpan) SetAttribute(key, value string)

type NoopTracer

type NoopTracer struct{}

NoopTracer returns a tracer that creates NoopSpan instances.

func (NoopTracer) Start

func (NoopTracer) Start(ctx context.Context, _ string) (context.Context, Span)

type Span

type Span interface {
	// End finishes the span and flushes any pending data.
	End()

	// SetAttribute sets a string attribute on the span.
	SetAttribute(key, value string)

	// RecordError records an error on the span.
	RecordError(err error)
}

Span represents a unit of work for tracing. Implementations may attach additional metadata and export the span to an external system. Keep the surface area intentionally small so middleware can adapt OTel or other tracers to this interface.

type SpanContext

type SpanContext interface{ any }

SpanContext is an opaque carrier for span context propagation. Concrete tracer implementations may provide a richer implementation but consumers should treat it as opaque. SpanContext is an opaque carrier for span context propagation. Concrete tracer implementations may provide a richer implementation but consumers should treat it as opaque.

type StartSpanFunc

type StartSpanFunc func(ctx context.Context, name string) (context.Context, Span)

StartSpanFunc is a function type that mirrors Tracer.Start. Some callers prefer passing a function instead of a full Tracer implementation.

type Tracer

type Tracer interface {
	Start(ctx context.Context, name string) (context.Context, Span)
}

Tracer is a minimal trace provider. Start creates a new span with the provided name and returns a context containing the span plus the Span itself. Implementations should ensure the returned context contains any required propagation information.

var DefaultTracer Tracer = NoopTracer{}

DefaultTracer is the zero-value tracer used when no tracer is configured.

Jump to

Keyboard shortcuts

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