Skip to main content

Example Tool Instrumentation

The following example illustrates how to manually trace a tool function alongside a chat completion response. You’ll learn how to establish spans for both the tool and LLM to capture their inputs, outputs, and key events. Before diving into the code, ensure your tracer is properly configured:
Now we can create tool spans by starting spans and defining our name and other attributes: