Internal
Creates a new ScoreManager instance.
Configuration object containing the API client
Creates a score for the currently active observation.
This method automatically detects the active OpenTelemetry span and creates an observation-level score. If no active span is found, a warning is logged and the operation is skipped.
Score data (traceId and observationId will be auto-populated)
Creates a score for the currently active trace.
This method automatically detects the active OpenTelemetry span and creates a trace-level score. If no active span is found, a warning is logged and the operation is skipped.
Score data (traceId will be auto-populated)
Creates a new score event and adds it to the processing queue.
Scores are queued and sent in batches for efficiency. The score will be automatically sent when the queue reaches the flush threshold or after the flush interval expires.
The score data to create
Flushes all pending score events to the Langfuse API.
This method ensures all queued scores are sent immediately rather than waiting for the automatic flush interval or batch size threshold.
Promise that resolves when all pending scores have been sent
Creates a score for a specific observation using its OpenTelemetry span.
This method automatically extracts the trace ID and observation ID from the provided span context.
Object containing the OpenTelemetry span
Score data (traceId and observationId will be auto-populated)
Gracefully shuts down the score manager by flushing all pending scores.
This method should be called before your application exits to ensure all score data is sent to Langfuse.
Promise that resolves when shutdown is complete
Creates a score for a trace using an OpenTelemetry span.
This method automatically extracts the trace ID from the provided span context and creates a trace-level score.
Object containing the OpenTelemetry span
Score data (traceId will be auto-populated)
Manager for creating and batching score events in Langfuse.
The ScoreManager handles automatic batching and flushing of score events to optimize API usage. Scores are automatically sent when the queue reaches a certain size or after a time interval.