Skip to main content
The Splunk Agent Observability CrewAI integration allows you to automatically log all CrewAI interactions with LLMs, including prompts, responses, and performance evaluators. The Splunk Agent Observability SDK has a custom event listener that listens to CrewAI events, and logs these to Splunk Agent Observability.

CrewAIEventListener

The Python Splunk Agent Observability CrewAI SDK reference.

Basic usage

The integration is based on the CrewAIEventListener class, which implements CrewAI’s event listener. To use it, create an instance of the listener before you kick off your crew, for example in your run function. When this listener is created, it automatically registers event handlers to capture the relevant events.
The CrewAIEventListener captures various CrewAI events, including:
  • Crew Kickoff events
  • Agent events
  • Task events
  • Tool usage
  • LLM calls
For each of these events, the callback logs relevant information to Splunk Agent Observability, such as:
  • Input prompts and messages
  • Output responses
  • Model information
  • Timing data
  • Token usage
  • Error information (if any)
The CrewAIEventListener automatically handles nested crews and agents, creating a hierarchical trace that reflects the structure of your CrewAI application.

Use a custom logger

When initializing the CrewAIEventListener, you can optionally specify a Splunk Agent Observability logger instance, either by creating a new logger, or by using the current logger from the Splunk Agent Observability context:
This is particularly useful if you want to call your CrewAI code from inside a function decorated with the log decorator, or from inside an experiment.

Session and trace support

Every time you kick off a crew, a new session and trace is created. If you want to manually manage sessions or traces, you can do this using by passing a Splunk Agent Observability logger instance to the listener. To add the crew kickoff as a new trace to an existing session, create the session first using the logger instance that was used to create the listener:
To add the crew kickoff to an existing trace, ensure the trace is started, and set the start_new_trace parameter to False.

Next steps

Basic logging components

Splunk Agent Observability logger

Log with full control over sessions, traces, and spans using the Splunk Agent Observability logger.

Log decorator

Quickly add logging to your code with the log decorator and wrapper.

Splunk Agent Observability context

Manage logging using the Splunk Agent Observability context manager.

How-to guides

Add Splunk Agent Observability to a CrewAI Application

Learn how to add Splunk Agent Observability to an existing CrewAI application