Tracing API
This page matches the Python SDK in sdk/boson-python. It is Langfuse-compatible and ships with two import paths:
- Recommended:
from getboson import ... - Compatibility:
from langfuse import ...(same implementation)
Minimal smoke example (real)
This is the same handshake pattern used in sdk/boson-python/examples/trace-smoke/smoke.py:
from langfuse import Langfuse, observe, propagate_attributes
@observe(
name="trace-smoke-handshake",
as_type="span",
capture_input=True,
capture_output=True,
)
def run_smoke():
return {"ok": True}
def main():
# Requires: LANGFUSE_BASE_URL, LANGFUSE_PUBLIC_KEY, LANGFUSE_SECRET_KEY
client = Langfuse()
with propagate_attributes(
trace_name="trace-smoke",
metadata={"app": "examples/trace-smoke"},
):
run_smoke()
client.flush()
client.shutdown()
Recommended pattern (production)
- one trace per request/job
- stable span names (
llm.completion,tool.execute,retrieval.query) - structured events for inputs/outputs (sanitized)