Documentation
¶
Overview ¶
Package chat instruments Core chat capabilities with OpenTelemetry.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( ErrInvalidConfig = errors.New("otel/chat: invalid config") ErrNilStream = errors.New("otel/chat: nil stream sequence") )
Functions ¶
This section is empty.
Types ¶
type Middleware ¶
type Middleware struct {
// contains filtered or unexported fields
}
Middleware adds GenAI spans and metrics to synchronous and streaming chat capabilities. It is immutable after construction and safe for concurrent use.
func NewMiddleware ¶
func NewMiddleware(config MiddlewareConfig) (Middleware, error)
func (Middleware) Call ¶
func (m Middleware) Call(next corechat.Model) corechat.Model
Call is a corechat.CallMiddleware. It preserves the wrapped model's response and error exactly; observation is a read-only side effect.
func (Middleware) Stream ¶
func (m Middleware) Stream(next corechat.Streamer) corechat.Streamer
Stream is a corechat.StreamMiddleware. Instrumentation starts lazily when the caller iterates and ends synchronously on completion, provider failure, or early consumer stop. Invalid deltas are still forwarded unchanged; an accumulation problem is recorded as an event and never becomes a business error.
type MiddlewareConfig ¶
type MiddlewareConfig struct {
Provider string
TracerProvider trace.TracerProvider
MeterProvider metric.MeterProvider
}
MiddlewareConfig identifies the remote GenAI provider and optionally supplies providers scoped to this middleware. Provider is normalized to lowercase so span and metric dimensions remain stable. The global OpenTelemetry providers are used when TracerProvider or MeterProvider is nil.
func (MiddlewareConfig) Validate ¶
func (m MiddlewareConfig) Validate() error