Skip to main content
This cookbook shows how to add Maxim observability and tracing to your CrewAI agent applications in just one line of code. You’ll learn how to instrument CrewAI, log agent interactions, and view traces in the Maxim dashboard.

Prerequisites

1. Installation

Install the Maxim SDK via pip:
Or add to your requirements.txt:

2. Set Up Environment Variables

Create a .env file in your project root:

3. Import Required Packages

4. Instrument CrewAI with Maxim

Instrument CrewAI with just one line:
You can enable debug logging for troubleshooting:

5. Create and Run Your CrewAI Application

That’s it! All your CrewAI agent interactions will now be logged and available in your Maxim dashboard.

6. Viewing Your Traces

After running your CrewAI application:
  • Log in to your Maxim Dashboard
  • Navigate to your repository
  • View detailed agent traces, including:
    • Agent conversations
    • Tool usage patterns
    • Performance metrics
    • Cost analytics

7. Troubleshooting

Common Issues

  • No traces appearing:
    • Ensure your API key and repository ID are correct
    • Ensure you’ve called instrument_crewai() before running your crew
    • Set debug=True in your instrument_crewai() call to surface any internal errors
  • Verbose logging:
    • Configure your agents with verbose=True to capture detailed logs
  • Order of operations:
    • Double-check that instrument_crewai() is called before creating or executing agents
crewai_traces.gif
For more details, see the CrewAI documentation and the Maxim Python SDK documentation.

Resources

Cookbook Code

Python Notebook for CrewAI & Maxim