telemetry

package
v1.11.1 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2026 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LogFieldTraceID = "trace_id"
	LogFieldSpanID  = "span_id"
)

Variables

View Source
var (
	AttrTraceID   = attribute.Key("trace.id")
	AttrTraceType = attribute.Key("trace.type")

	AttrTenantID = attribute.Key("tenant.id")
	AttrUserID   = attribute.Key("user.id")

	AttrLLMProvider      = attribute.Key("llm.provider")
	AttrLLMModel         = attribute.Key("llm.model")
	AttrLLMFeature       = attribute.Key("llm.feature")
	AttrLLMStatus        = attribute.Key("llm.status")
	AttrLLMTokenType     = attribute.Key("llm.token.type")
	AttrLLMCacheHit      = attribute.Key("llm.cache.hit")
	AttrLLMFallback      = attribute.Key("llm.fallback")
	AttrLLMFallbackLevel = attribute.Key("llm.fallback.level")
	AttrLLMDurationMS    = attribute.Key("llm.duration.ms")
	AttrLLMCost          = attribute.Key("llm.cost")

	AttrToolName       = attribute.Key("tool.name")
	AttrToolSuccess    = attribute.Key("tool.success")
	AttrToolDurationMS = attribute.Key("tool.duration.ms")

	AttrErrorCode    = attribute.Key("error.code")
	AttrErrorMessage = attribute.Key("error.message")
)

Functions

func LLMIdentityAttrs added in v1.11.0

func LLMIdentityAttrs(provider, model, tenantID, userID, feature string) []attribute.KeyValue

func LLMRequestAttrs added in v1.11.0

func LLMRequestAttrs(provider, model, tenantID, userID, feature, status string) []attribute.KeyValue

func LLMTokenAttrs added in v1.11.0

func LLMTokenAttrs(provider, model, tenantID, userID, feature, tokenType string) []attribute.KeyValue

func LLMTraceAttrs added in v1.11.0

func LLMTraceAttrs(provider, model, tenantID, userID, feature, traceID string) []attribute.KeyValue

func LoggerWithTrace

func LoggerWithTrace(ctx context.Context, logger *zap.Logger) *zap.Logger

LoggerWithTrace returns a logger with trace_id and span_id fields from the context. If the context has no valid span, the original logger is returned unchanged.

Types

type Providers

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

Providers holds the OTel SDK TracerProvider and MeterProvider. When telemetry is disabled, both fields are nil and Shutdown is a no-op.

func Init

func Init(cfg config.TelemetryConfig, logger *zap.Logger) (*Providers, error)

Init initializes the OTel SDK. When cfg.Enabled is false, it returns a noop Providers (nil tp/mp) without connecting to any external service.

func (*Providers) Shutdown

func (p *Providers) Shutdown(ctx context.Context) error

Shutdown flushes pending spans/metrics and closes exporters. Safe to call on noop Providers (nil tp/mp).

Jump to

Keyboard shortcuts

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