Skip to content

Commit

Permalink
fix: add comments of langfuse callback config (#51)
Browse files Browse the repository at this point in the history
  • Loading branch information
meguminnnnnnnnn authored Jan 14, 2025
1 parent 6dc8db1 commit c668ac7
Show file tree
Hide file tree
Showing 2 changed files with 81 additions and 86 deletions.
97 changes: 81 additions & 16 deletions callbacks/langfuse/langfuse.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,30 +32,95 @@ import (
)

type Config struct {
Host string
// Host is the Langfuse server URL (Required)
// Example: "https://cloud.langfuse.com"
Host string

// PublicKey is the public key for authentication (Required)
// Example: "pk-lf-..."
PublicKey string

// SecretKey is the secret key for authentication (Required)
// Example: "sk-lf-..."
SecretKey string

Threads int
Timeout time.Duration
// Threads is the number of concurrent workers for processing events (Optional)
// Default: 1
// Example: 5
Threads int

// Timeout is the HTTP request timeout (Optional)
// Default: no timeout
// Example: 30 * time.Second
Timeout time.Duration

// MaxTaskQueueSize is the maximum number of events to buffer (Optional)
// Default: 100
// Example: 1000
MaxTaskQueueSize int
FlushAt int
FlushInterval time.Duration
SampleRate float64
LogMessage string
MaskFunc func(string) string
MaxRetry uint64

Name string
UserID string

// FlushAt is the number of events to batch before sending (Optional)
// Default: 15
// Example: 50
FlushAt int

// FlushInterval is how often to flush events automatically (Optional)
// Default: 500 * time.MilliSecond
// Example: 10 * time.Second
FlushInterval time.Duration

// SampleRate is the percentage of events to send (Optional)
// Default: 1.0 (100%)
// Example: 0.5 (50%)
SampleRate float64

// LogMessage is the message to log when events exceed the limit length(1 000 000) (Optional)
// Default: ""
// Example: "langfuse event:"
LogMessage string

// MaskFunc is a function to mask sensitive data before sending (Optional)
// Default: nil
// Example: func(s string) string { return strings.ReplaceAll(s, "secret", "***") }
MaskFunc func(string) string

// MaxRetry is the maximum number of retry attempts for failed requests (Optional)
// Default: 3
// Example: 5
MaxRetry uint64

// Name is the trace name (Optional)
// Default: ""
// Example: "my-app-trace"
Name string

// UserID is the user identifier for the trace (Optional)
// Default: ""
// Example: "user-123"
UserID string

// SessionID is the session identifier for the trace (Optional)
// Default: ""
// Example: "session-456"
SessionID string
Release string
Tags []string
Public bool

// Release is the version or release identifier (Optional)
// Default: ""
// Example: "v1.2.3"
Release string

// Tags are labels attached to the trace (Optional)
// Default: nil
// Example: []string{"production", "feature-x"}
Tags []string

// Public determines if the trace is publicly accessible (Optional)
// Default: false
// Example: true
Public bool
}

func NewLangfuseHandler(cfg *Config) (handler callbacks.Handler, flusher func()) {

var langfuseOpts []langfuse.Option
if cfg.Threads > 0 {
langfuseOpts = append(langfuseOpts, langfuse.WithThreads(cfg.Threads))
Expand Down
70 changes: 0 additions & 70 deletions callbacks/langfuse/option.go

This file was deleted.

0 comments on commit c668ac7

Please sign in to comment.