Skip to main content
Demonstrates instrumenting an Agno agent with Langtrace.
This example initializes Langtrace after importing Agno model modules, so automatic instrumentation may not attach. Create a Langtrace project and generate an API key before running the example. See Langtrace Python SDK setup.
langtrace_op.py

Run the Example

1

Set up your virtual environment

2

Install dependencies

3

Export your Langtrace and OpenAI API keys

4

Save and fix the initialization order

Save the code above as langtrace_op.py, then move the langtrace_python_sdk import and langtrace.init() before every Agno and OpenAI import.
5

Run the example

Run the corrected file:
Full source: cookbook/observability/langtrace_op.py