tracing

package
v0.0.21 Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2025 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type LLMMiddleware

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

LLMMiddleware implements middleware for LLM calls with Langfuse tracing

func NewLLMMiddleware

func NewLLMMiddleware(llm interfaces.LLM, tracer *LangfuseTracer) *LLMMiddleware

NewLLMMiddleware creates a new LLM middleware with Langfuse tracing

func (*LLMMiddleware) Generate

func (m *LLMMiddleware) Generate(ctx context.Context, prompt string, options ...interfaces.GenerateOption) (string, error)

Generate generates text from a prompt with Langfuse tracing

func (*LLMMiddleware) GenerateWithTools

func (m *LLMMiddleware) GenerateWithTools(ctx context.Context, prompt string, tools []interfaces.Tool, options ...interfaces.GenerateOption) (string, error)

GenerateWithTools implements interfaces.LLM.GenerateWithTools for LLMMiddleware

func (*LLMMiddleware) Name

func (m *LLMMiddleware) Name() string

Name implements interfaces.LLM.Name

type LLMOTelMiddleware

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

LLMOTelMiddleware wraps an LLM with OpenTelemetry tracing

func NewLLMOTelMiddleware

func NewLLMOTelMiddleware(llm interfaces.LLM, tracer *OTelTracer) *LLMOTelMiddleware

NewLLMOTelMiddleware creates a new LLMOTelMiddleware

func (*LLMOTelMiddleware) Generate

func (m *LLMOTelMiddleware) Generate(ctx context.Context, prompt string, options ...interfaces.GenerateOption) (string, error)

Generate implements interfaces.LLM.Generate

func (*LLMOTelMiddleware) GenerateWithTools

func (m *LLMOTelMiddleware) GenerateWithTools(ctx context.Context, prompt string, tools []interfaces.Tool, options ...interfaces.GenerateOption) (string, error)

GenerateWithTools implements interfaces.LLM.GenerateWithTools

func (*LLMOTelMiddleware) Name

func (m *LLMOTelMiddleware) Name() string

Name implements interfaces.LLM.Name

type LangfuseConfig

type LangfuseConfig struct {
	// Enabled determines whether Langfuse tracing is enabled
	Enabled bool

	// SecretKey is the Langfuse secret key
	SecretKey string

	// PublicKey is the Langfuse public key
	PublicKey string

	// Host is the Langfuse host (optional)
	Host string

	// Environment is the environment name (e.g., "production", "staging")
	Environment string
}

LangfuseConfig contains configuration for Langfuse

type LangfuseTracer

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

LangfuseTracer implements tracing using Langfuse

func NewLangfuseTracer

func NewLangfuseTracer(customConfig ...LangfuseConfig) (*LangfuseTracer, error)

NewLangfuseTracer creates a new Langfuse tracer

func (*LangfuseTracer) Flush

func (t *LangfuseTracer) Flush() error

Flush flushes the Langfuse client

func (*LangfuseTracer) TraceEvent

func (t *LangfuseTracer) TraceEvent(ctx context.Context, name string, input interface{}, output interface{}, level string, metadata map[string]interface{}, parentID string) (string, error)

TraceEvent traces an event

func (*LangfuseTracer) TraceGeneration

func (t *LangfuseTracer) TraceGeneration(ctx context.Context, modelName string, prompt string, response string, startTime time.Time, endTime time.Time, metadata map[string]interface{}) (string, error)

TraceGeneration traces an LLM generation

func (*LangfuseTracer) TraceSpan

func (t *LangfuseTracer) TraceSpan(ctx context.Context, name string, startTime time.Time, endTime time.Time, metadata map[string]interface{}, parentID string) (string, error)

TraceSpan traces a span of execution

type MemoryOTelMiddleware

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

MemoryOTelMiddleware implements middleware for memory operations with OpenTelemetry tracing

func NewMemoryOTelMiddleware

func NewMemoryOTelMiddleware(memory interfaces.Memory, tracer *OTelTracer) *MemoryOTelMiddleware

NewMemoryOTelMiddleware creates a new memory middleware with OpenTelemetry tracing

func (*MemoryOTelMiddleware) AddMessage

func (m *MemoryOTelMiddleware) AddMessage(ctx context.Context, message interfaces.Message) error

AddMessage adds a message to memory with OpenTelemetry tracing

func (*MemoryOTelMiddleware) Clear

func (m *MemoryOTelMiddleware) Clear(ctx context.Context) error

Clear clears memory with OpenTelemetry tracing

func (*MemoryOTelMiddleware) GetMessages

GetMessages gets messages from memory with OpenTelemetry tracing

type OTelConfig

type OTelConfig struct {
	// Enabled determines whether OpenTelemetry tracing is enabled
	Enabled bool

	// ServiceName is the name of the service
	ServiceName string

	// CollectorEndpoint is the endpoint of the OpenTelemetry collector
	CollectorEndpoint string
}

OTelConfig contains configuration for OpenTelemetry

type OTelTracer

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

OTelTracer implements tracing using OpenTelemetry

func NewOTelTracer

func NewOTelTracer(config OTelConfig) (*OTelTracer, error)

NewOTelTracer creates a new OpenTelemetry tracer

func (*OTelTracer) EndSpan

func (t *OTelTracer) EndSpan(span trace.Span, err error)

EndSpan ends a span

func (*OTelTracer) StartSpan

func (t *OTelTracer) StartSpan(ctx context.Context, name string, attributes map[string]string) (context.Context, trace.Span)

StartSpan starts a new span

Jump to

Keyboard shortcuts

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