Langfuse launches AI Gateway Learn more
FaqHow often do the Langfuse SDKs send data, and how do I change it?

How often do the Langfuse SDKs send data, and how do I change it?

The Python and JS/TS SDKs use the OpenTelemetry batch span processor. By default they export a batch every 5 seconds or as soon as 512 spans are queued, whichever comes first.

SettingPython (Langfuse)JS/TS (LangfuseSpanProcessor)Environment variable
Batch sizeflush_atflushAtLANGFUSE_FLUSH_AT
Interval (seconds)flush_intervalflushIntervalLANGFUSE_FLUSH_INTERVAL
from langfuse import Langfuse

langfuse = Langfuse(flush_at=100, flush_interval=1)
import { NodeSDK } from "@opentelemetry/sdk-node";
import { LangfuseSpanProcessor } from "@langfuse/otel";

export const langfuseSpanProcessor = new LangfuseSpanProcessor({
  flushAt: 100,
  flushInterval: 1,
});

const sdk = new NodeSDK({ spanProcessors: [langfuseSpanProcessor] });
sdk.start();

In short-lived processes such as scripts, serverless functions, or notebooks, flush queued spans before the process exits or the function returns. In Python, call langfuse.flush() (or langfuse.shutdown()). In JS/TS, call await langfuseSpanProcessor.forceFlush() (or await sdk.shutdown()); LangfuseClient.flush() sends only pending scores, not tracing spans. The JS/TS span processor can also export every span right away with exportMode: "immediate". See Queuing and batching and AWS Lambda and serverless functions.


Was this page helpful?

Last updated on