moderation

package
v0.21.0 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2026 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Package moderation instruments Core moderation calls with OpenTelemetry.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidConfig = errors.New("otel/moderation: invalid config")
	ErrInvalidModel  = errors.New("otel/moderation: invalid model")
)

Functions

This section is empty.

Types

type Middleware

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

Middleware observes moderation metadata without recording classified text or provider category names.

func NewMiddleware

func NewMiddleware(config MiddlewareConfig) (Middleware, error)

NewMiddleware snapshots provider identity and resolves nil OTel providers to the official process globals.

func (Middleware) Wrap

Wrap decorates one moderation Model without changing its call semantics.

type MiddlewareConfig

type MiddlewareConfig struct {
	Provider       string
	TracerProvider trace.TracerProvider
	MeterProvider  metric.MeterProvider
	// LoggerProvider receives GenAI exception events. Nil uses the global provider.
	LoggerProvider log.LoggerProvider
}

MiddlewareConfig identifies the provider and optional OTel providers used by moderation instrumentation.

func (MiddlewareConfig) Validate

func (m MiddlewareConfig) Validate() error

Validate checks construction inputs without resolving global providers.

Jump to

Keyboard shortcuts

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