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) RecordError ¶
func (NoopSpan) SetAttribute ¶
type NoopTracer ¶
type NoopTracer struct{}
NoopTracer returns a tracer that creates NoopSpan instances.
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 ¶
StartSpanFunc is a function type that mirrors Tracer.Start. Some callers prefer passing a function instead of a full Tracer implementation.
type Tracer ¶
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.