This shows how to trace a Burr application to Langfuse using the LangfuseBridge hook.
What gets logged:
run/step/iterate/stream_result/...)__tracer)__tracer.log_attribute(s) as observation metadataapp_id maps to the Langfuse session and partition_key to the Langfuse user (both overridable)If you also install an OpenTelemetry LLM instrumentor (e.g. opentelemetry-instrumentation-openai), LLM calls show up as generations nested inside the corresponding Burr steps, with prompts/completions/token usage.
pip install "apache-burr[langfuse]" openai opentelemetry-instrumentation-openai export LANGFUSE_PUBLIC_KEY="pk-lf-..." export LANGFUSE_SECRET_KEY="sk-lf-..." export LANGFUSE_HOST="https://cloud.langfuse.com" # or your self-hosted URL export OPENAI_API_KEY="sk-..." python application.py
Then open your Langfuse project -- you will see one trace per .run() call, with the step spans, tracer spans, and (if instrumented) OpenAI generations nested inside.
See application.py for the full code, and the integration docs for configuration options (custom session/user IDs, disabling state capture, passing your own Langfuse client).
Langfuse SDK v4+ only exports LLM-relevant spans by default. LangfuseBridge handles this automatically when it constructs the client. If you construct the Langfuse client yourself, pass the provided filter:
from langfuse import Langfuse from burr.integrations.langfuse import LangfuseBridge, burr_span_export_filter client = Langfuse(should_export_span=burr_span_export_filter) bridge = LangfuseBridge(langfuse_client=client)