SDK + EventListener
For self-hosted CrewAI, or when you want Python SDK control over agent naming,
tags and flush timing, use the ants-platform SDK with its EventListener.
The listener subscribes to CrewAI's event bus and turns events into
observations.
Running CrewAI Enterprise? The Native OTel path needs no code.
Setup
Install the SDK
Requires Python 3.10 to 3.13 and CrewAI 0.80 or later.
Set environment variables
Create keys under Project Settings > API Keys in ANTS Platform.
Register the EventListener at module level in crew.py
Initialise in crew.py, not main.py. CrewAI's deployment runner imports
the @CrewBase class directly and never runs main.py.
Flush before exit
In main.py, or wherever you call kickoff():
Configuration
EventListener parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
public_key | str | none | Pass ants_platform._public_key. Required when deploying to CrewAI's cloud platform (see below). |
agent_name | str | the crew name, else crew | Stable agent name for the crew in the AI Agent Center. Also the root observation name. Stored in lower case. |
agent_display_name | str | none | Name shown in the UI. Can change later. |
tags | dict | none | Key-value pairs added to every trace as key:value tags, for example {"env": "production"}. They override the automatic tags with the same key. |
AntsPlatform client options
| Parameter | Default | Description |
|---|---|---|
public_key / secret_key / host | env vars | API credentials and host. |
timeout | 5 | HTTP timeout in seconds. Use 30 for slower networks. |
See the Python SDK for all options.
Deploying to CrewAI's cloud platform
CrewAI's deployment runner skips main.py and imports your @CrewBase class
directly. Two rules:
- Initialise in
crew.pyat module level, before the class. - Pass
public_keytoEventListener. CrewAI's own telemetry creates a second client in the process. Without an explicitpublic_key, the SDK sees several clients and returns a disabled one.
Set ANTS_PLATFORM_PUBLIC_KEY, ANTS_PLATFORM_SECRET_KEY and
ANTS_PLATFORM_HOST in your CrewAI deployment's environment variables. Push
your changes to your Git remote first. crewai deploy push builds from the
remote, not your local files.
How events map to observations
| CrewAI event | Observation |
|---|---|
CrewKickoffStartedEvent / Completed / Failed | Root span for the crew run |
AgentExecutionStartedEvent / Completed / Error | Span for the agent step, with role and task prompt |
LLMCallStartedEvent / Completed / Failed | Generation with model, messages and token usage |
ToolUsageStartedEvent / Finished / Error | Tool observation with arguments and output |
LLMGuardrailStartedEvent / Completed / Failed | Guardrail observation, if your CrewAI version emits it |
AgentReasoningStartedEvent / Completed / Failed | Span for agent reasoning, if your CrewAI version emits it |
Failed and error events set level ERROR on the observation. Automatic trace
tags: framework:crewai, agent:<name>, process_type, crewai_version,
num_agents and num_tasks. The listener blocks CrewAI's own telemetry spans
so they do not appear as separate traces.
Next
- Hit an issue? See Troubleshooting.
- Compare with the Native OTel approach.