Creates a new LangfuseSpanProcessor instance.
Optional
params: LangfuseSpanProcessorParamsConfiguration parameters for the processor
const processor = new LangfuseSpanProcessor({
publicKey: 'pk_...',
secretKey: 'sk_...',
environment: 'staging',
flushAt: 10,
flushInterval: 2,
mask: ({ data }) => {
// Custom masking logic
return typeof data === 'string'
? data.replace(/secret_\w+/g, 'secret_***')
: data;
},
shouldExportSpan: ({ otelSpan }) => {
// Only export spans from specific services
return otelSpan.name.startsWith('my-service');
}
});
Forces an immediate flush of all pending spans and media uploads.
Promise that resolves when all pending operations are complete
Called when a span ends. Processes the span for export to Langfuse.
This method:
The span that ended
Called when a span is started. Adds environment and release attributes to the span.
The span that was started
The parent context
Gracefully shuts down the processor, ensuring all pending operations are completed.
Promise that resolves when shutdown is complete
OpenTelemetry span processor for sending spans to Langfuse.
This processor extends the standard BatchSpanProcessor to provide:
Example