|
| 1 | +# CrewAI |
| 2 | + |
| 3 | +## Overview |
| 4 | +Use the CrewAI integration to monitor, troubleshoot, and evaluate your applications based on [CrewAI][1]'s framework. |
| 5 | + |
| 6 | +**Note**: Requires Python. |
| 7 | + |
| 8 | +## Setup |
| 9 | + |
| 10 | +#### Installation |
| 11 | + |
| 12 | +##### If you do not have the Datadog Agent: |
| 13 | +1. Install the `ddtrace` package: |
| 14 | + |
| 15 | + ```shell |
| 16 | + pip install ddtrace |
| 17 | + ``` |
| 18 | + |
| 19 | +2. Start your application using the following command to enable Agentless mode: |
| 20 | + |
| 21 | + ```shell |
| 22 | + DD_SITE=<YOUR_DATADOG_SITE> DD_API_KEY=<YOUR_API_KEY> DD_LLMOBS_ENABLED=1 DD_LLMOBS_AGENTLESS_ENABLED=1 DD_LLMOBS_ML_APP=<YOUR_ML_APP_NAME> ddtrace-run python <YOUR_APP>.py |
| 23 | + ``` |
| 24 | + |
| 25 | +##### If you already have the Datadog Agent installed: |
| 26 | +1. Make sure the Agent is running and that APM and StatsD are enabled. For example, use the following command with Docker: |
| 27 | + |
| 28 | + ```shell |
| 29 | + docker run -d \ |
| 30 | + --cgroupns host \ |
| 31 | + --pid host \ |
| 32 | + -v /var/run/docker.sock:/var/run/docker.sock:ro \ |
| 33 | + -v /proc/:/host/proc/:ro \ |
| 34 | + -v /sys/fs/cgroup/:/host/sys/fs/cgroup:ro \ |
| 35 | + -e DD_API_KEY=<DATADOG_API_KEY> \ |
| 36 | + -p 127.0.0.1:8126:8126/tcp \ |
| 37 | + -p 127.0.0.1:8125:8125/udp \ |
| 38 | + -e DD_DOGSTATSD_NON_LOCAL_TRAFFIC=true \ |
| 39 | + -e DD_APM_ENABLED=true \ |
| 40 | + gcr.io/datadoghq/agent:latest |
| 41 | + ``` |
| 42 | + |
| 43 | +2. If you haven't already, install the `ddtrace` package: |
| 44 | + |
| 45 | + ```shell |
| 46 | + pip install ddtrace |
| 47 | + ``` |
| 48 | + |
| 49 | +3. To automatically enable tracing, start your application using the `ddtrace-run` command: |
| 50 | + |
| 51 | + ```shell |
| 52 | + DD_SITE=<YOUR_DATADOG_SITE> DD_API_KEY=<YOUR_API_KEY> DD_LLMOBS_ENABLED=1 DD_LLMOBS_ML_APP=<YOUR_ML_APP_NAME> ddtrace-run python <your_app>.py |
| 53 | + ``` |
| 54 | + |
| 55 | +**Note**: If the Agent is running on a custom host or port, set `DD_AGENT_HOST` and `DD_TRACE_AGENT_PORT` accordingly. |
| 56 | + |
| 57 | +##### If you are running LLM Observability in a serverless environment (AWS Lambda): |
| 58 | +1. Install the **Datadog-Python** and **Datadog-Extension** Lambda layers as part of your AWS Lambda setup. |
| 59 | +2. Enable LLM Observability by setting the following environment variables: |
| 60 | + |
| 61 | + ```shell |
| 62 | + DD_SITE=<YOUR_DATADOG_SITE> DD_API_KEY=<YOUR_API_KEY> DD_LLMOBS_ENABLED=1 DD_LLMOBS_ML_APP=<YOUR_ML_APP_NAME> |
| 63 | + ``` |
| 64 | + |
| 65 | +**Note**: In serverless environments, Datadog automatically flushes spans at the end of the Lambda function. |
| 66 | + |
| 67 | +##### Automatic CrewAI tracing |
| 68 | + |
| 69 | +The CrewAI integration allows for automatic tracing of Crew kickoffs, including task/agent/tool invocations, made through [CrewAI's Python SDK][1]. The CrewAI integration also captures latency, errors, input/output messages, and directional data flow linking during Crew executions. |
| 70 | + |
| 71 | +The following CrewAI methods are traced: |
| 72 | +- [Crew Kickoff][2]: |
| 73 | + - `crew.kickoff()` |
| 74 | + - `crew.kickoff_async()` |
| 75 | + - `crew.kickoff_for_each()` |
| 76 | + - `crew.kickoff_for_each_async()` |
| 77 | + |
| 78 | +- [Task Execution][3]: |
| 79 | + - `task.execute_sync()` |
| 80 | + - `task.execute_async()` |
| 81 | + |
| 82 | +- [Agent Execution][4]: |
| 83 | + - `agent.execute_task()` |
| 84 | + |
| 85 | +- [Tool Invocation][5]: |
| 86 | + - `tool.invoke()` |
| 87 | + |
| 88 | +No additional setup is required for these methods. |
| 89 | + |
| 90 | +##### Validation |
| 91 | + |
| 92 | +Validate that LLM Observability is properly capturing spans by checking your application logs for successful span creation. You can also run the following command to check the status of the `dd-trace` integration: |
| 93 | + |
| 94 | + ```shell |
| 95 | + ddtrace-run --info |
| 96 | + ``` |
| 97 | + |
| 98 | +Look for the following message to confirm the setup: |
| 99 | + |
| 100 | + ```shell |
| 101 | + Agent error: None |
| 102 | + ``` |
| 103 | + |
| 104 | +##### Debugging |
| 105 | + |
| 106 | +If you encounter issues during setup, enable debug logging by passing the `--debug` flag: |
| 107 | + |
| 108 | + ```shell |
| 109 | + ddtrace-run --debug |
| 110 | + ``` |
| 111 | + |
| 112 | +This displays any errors related to data transmission or instrumentation, including issues with CrewAI traces. |
| 113 | + |
| 114 | +## Data Collected |
| 115 | + |
| 116 | +### Metrics |
| 117 | + |
| 118 | +The CrewAI integration does not include any custom metrics. |
| 119 | + |
| 120 | +### Service Checks |
| 121 | + |
| 122 | +The CrewAI integration does not include any service checks. |
| 123 | + |
| 124 | +### Events |
| 125 | + |
| 126 | +The CrewAI integration does not include any events. |
| 127 | + |
| 128 | +## Troubleshooting |
| 129 | + |
| 130 | +Need help? Contact [Datadog support][6]. |
| 131 | + |
| 132 | +[1]: https://docs.crewai.com/introduction |
| 133 | +[2]: https://docs.crewai.com/concepts/crews#kicking-off-a-crew |
| 134 | +[3]: https://docs.crewai.com/concepts/tasks |
| 135 | +[4]: https://docs.crewai.com/concepts/agents |
| 136 | +[5]: https://docs.crewai.com/concepts/tools |
| 137 | +[6]: https://docs.datadoghq.com/help/ |
0 commit comments