1
Set up auto-instrumentation
Register your tracer provider and auto-instrument your LLM provider:
2
Get a tracer for manual spans
Use the same TracerProvider to get a tracer — this ensures manual and auto spans end up in the same trace:
3
Add manual CHAIN and TOOL spans around your logic
Manual spans automatically nest as children of each other and alongside auto-instrumented spans:The result is a complete trace tree: CHAIN (manual) → LLM (auto) → TOOL (manual). Without the manual spans, you’d only see the LLM call — the tool execution and agent orchestration would be invisible.
End every manual span with an explicit outcome. The context managers above end the spans, but
set_status(Status(StatusCode.OK)) records successful completion. If you catch an exception in manual span code, call record_exception(...) and set_status(Status(StatusCode.ERROR)) before re-raising or returning.