Skip to content

Commit 780c9bd

Browse files
Yun-Kimerikayasuda
authored andcommitted
feat(crewai): support tracing crewAI flows (#14082)
[MLOB-2806] This PR adds support for APM and LLMObs tracing of CrewAI flows, including the overall flow execution and individual start/listener method execution, as well as span linking of which methods triggered other methods in the flow (includes support for linking conditional AND/OR and router method triggers). (Due to some type hinting issues, I've removed `CrewAIIntegration` import from `llmobs/_integrations/__init__.py`. Python 3.8 has issues with subscripting WeakKeyDictionary, but CrewAI (and also LangGraph) only run on Python 3.9/3.10+ so we didn't know this was an issue until now) Note (assist for reading test assertions): span linking/event tests in `test_crewai_llmobs.py` are based on a complex flow that looks like this: <img width="974" height="627" alt="Screenshot 2025-07-30 at 4 23 59 PM" src="https://github.com/user-attachments/assets/c784fe1b-6574-4735-a632-ec63a245ffc9" /> Additional note: tested [manually](https://dd.datad0g.com/llm/traces?query=%40ml_app%3Aml-app%20%40event_type%3Aspan%20%40parent_id%3Aundefined&agg_m=count&agg_m_source=base&agg_t=count&fromUser=false&llmPanels=%5B%7B%22t%22%3A%22sampleDetailPanel%22%2C%22rEID%22%3A%22AwAAAZhc-Jpa5Z3YfgAAABhBWmhjLUpwYUFBRHBkZlpaLTBvekFBQUEAAAAkMDE5ODVjZjktYTNkYS00ZGEzLWE3NGYtOTQ1NmI4YWU2Mjg1AAAAfQ%22%7D%5D&spanId=14559885504901134809&start=1753820708729&end=1753907108729&paused=false) and verified that crews are compatible with being run inside flows (as is a documented use case in CrewAI): <img width="707" height="685" alt="Screenshot 2025-07-30 at 4 25 48 PM" src="https://github.com/user-attachments/assets/cc694c63-e043-4d36-a58d-5d65b31616cc" /> ## Checklist - [x] PR author has checked that all the criteria below are met - The PR description includes an overview of the change - The PR description articulates the motivation for the change - The change includes tests OR the PR description describes a testing strategy - The PR description notes risks associated with the change, if any - Newly-added code is easy to change - The change follows the [library release note guidelines](https://ddtrace.readthedocs.io/en/stable/releasenotes.html) - The change includes or references documentation updates if necessary - Backport labels are set (if [applicable](https://ddtrace.readthedocs.io/en/latest/contributing.html#backporting)) ## Reviewer Checklist - [x] Reviewer has checked that all the criteria below are met - Title is accurate - All changes are related to the pull request's stated goal - Avoids breaking [API](https://ddtrace.readthedocs.io/en/stable/versioning.html#interfaces) changes - Testing strategy adequately addresses listed risks - Newly-added code is easy to change - Release note makes sense to a user of the library - If necessary, author has acknowledged and discussed the performance implications of this PR as reported in the benchmarks PR comment - Backport labels are set in a manner that is consistent with the [release branch maintenance policy](https://ddtrace.readthedocs.io/en/latest/contributing.html#backporting) [MLOB-2806]: https://datadoghq.atlassian.net/browse/MLOB-2806?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ
1 parent f0083bf commit 780c9bd

File tree

18 files changed

+1124
-376
lines changed

18 files changed

+1124
-376
lines changed

.riot/requirements/181e571.txt

Lines changed: 0 additions & 166 deletions
This file was deleted.

.riot/requirements/1ce4995.txt

Lines changed: 160 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,160 @@
1+
#
2+
# This file is autogenerated by pip-compile with Python 3.11
3+
# by the following command:
4+
#
5+
# pip-compile --allow-unsafe --no-annotate --resolver=backtracking .riot/requirements/1ce4995.in
6+
#
7+
aiohappyeyeballs==2.6.1
8+
aiohttp==3.12.15
9+
aiosignal==1.4.0
10+
annotated-types==0.7.0
11+
anyio==4.10.0
12+
appdirs==1.4.4
13+
asttokens==3.0.0
14+
attrs==25.3.0
15+
backoff==2.2.1
16+
bcrypt==4.3.0
17+
blinker==1.9.0
18+
build==1.3.0
19+
cachetools==5.5.2
20+
certifi==2025.8.3
21+
cffi==1.17.1
22+
charset-normalizer==3.4.3
23+
chromadb==1.0.16
24+
click==8.2.1
25+
coloredlogs==15.0.1
26+
coverage[toml]==7.10.3
27+
crewai==0.157.0
28+
cryptography==45.0.6
29+
decorator==5.2.1
30+
diskcache==5.6.3
31+
distro==1.9.0
32+
docstring-parser==0.17.0
33+
durationpy==0.10
34+
et-xmlfile==2.0.0
35+
executing==2.2.0
36+
filelock==3.18.0
37+
flatbuffers==25.2.10
38+
frozenlist==1.7.0
39+
fsspec==2025.7.0
40+
google-auth==2.40.3
41+
googleapis-common-protos==1.70.0
42+
grpcio==1.74.0
43+
h11==0.16.0
44+
hf-xet==1.1.7
45+
httpcore==1.0.9
46+
httptools==0.6.4
47+
httpx==0.28.1
48+
huggingface-hub==0.34.4
49+
humanfriendly==10.0
50+
hypothesis==6.45.0
51+
idna==3.10
52+
importlib-metadata==8.7.0
53+
importlib-resources==6.5.2
54+
iniconfig==2.1.0
55+
instructor==1.10.0
56+
ipython==9.4.0
57+
ipython-pygments-lexers==1.1.1
58+
jedi==0.19.2
59+
jinja2==3.1.6
60+
jiter==0.10.0
61+
json-repair==0.25.2
62+
json5==0.12.0
63+
jsonpickle==4.1.1
64+
jsonref==1.1.0
65+
jsonschema==4.25.0
66+
jsonschema-specifications==2025.4.1
67+
kubernetes==33.1.0
68+
litellm==1.74.9
69+
markdown-it-py==4.0.0
70+
markupsafe==3.0.2
71+
matplotlib-inline==0.1.7
72+
mdurl==0.1.2
73+
mmh3==5.2.0
74+
mock==5.2.0
75+
mpmath==1.3.0
76+
multidict==6.6.4
77+
networkx==3.5
78+
numpy==2.3.2
79+
oauthlib==3.3.1
80+
onnxruntime==1.22.0
81+
openai==1.99.8
82+
openpyxl==3.1.5
83+
opentelemetry-api==1.36.0
84+
opentelemetry-exporter-otlp-proto-common==1.36.0
85+
opentelemetry-exporter-otlp-proto-grpc==1.36.0
86+
opentelemetry-exporter-otlp-proto-http==1.36.0
87+
opentelemetry-proto==1.36.0
88+
opentelemetry-sdk==1.36.0
89+
opentelemetry-semantic-conventions==0.57b0
90+
opentracing==2.4.0
91+
orjson==3.11.1
92+
overrides==7.7.0
93+
packaging==25.0
94+
parso==0.8.4
95+
pdfminer-six==20250506
96+
pdfplumber==0.11.7
97+
pexpect==4.9.0
98+
pillow==11.3.0
99+
pluggy==1.6.0
100+
portalocker==2.7.0
101+
posthog==5.4.0
102+
prompt-toolkit==3.0.51
103+
propcache==0.3.2
104+
protobuf==6.31.1
105+
ptyprocess==0.7.0
106+
pure-eval==0.2.3
107+
pyasn1==0.6.1
108+
pyasn1-modules==0.4.2
109+
pybase64==1.4.2
110+
pycparser==2.22
111+
pydantic==2.11.7
112+
pydantic-core==2.33.2
113+
pygments==2.19.2
114+
pyjwt==2.10.1
115+
pypdfium2==4.30.0
116+
pypika==0.48.9
117+
pyproject-hooks==1.2.0
118+
pytest==8.4.1
119+
pytest-asyncio==1.1.0
120+
pytest-cov==6.2.1
121+
pytest-mock==3.14.1
122+
python-dateutil==2.9.0.post0
123+
python-dotenv==1.1.1
124+
pyvis==0.3.2
125+
pyyaml==6.0.2
126+
referencing==0.36.2
127+
regex==2025.7.34
128+
requests==2.32.4
129+
requests-oauthlib==2.0.0
130+
rich==14.1.0
131+
rpds-py==0.27.0
132+
rsa==4.9.1
133+
shellingham==1.5.4
134+
six==1.17.0
135+
sniffio==1.3.1
136+
sortedcontainers==2.4.0
137+
stack-data==0.6.3
138+
sympy==1.14.0
139+
tenacity==9.1.2
140+
tiktoken==0.11.0
141+
tokenizers==0.21.4
142+
tomli==2.2.1
143+
tomli-w==1.2.0
144+
tqdm==4.67.1
145+
traitlets==5.14.3
146+
typer==0.16.0
147+
typing-extensions==4.14.1
148+
typing-inspection==0.4.1
149+
urllib3==2.5.0
150+
uv==0.8.8
151+
uvicorn[standard]==0.35.0
152+
uvloop==0.21.0
153+
vcrpy==7.0.0
154+
watchfiles==1.1.0
155+
wcwidth==0.2.13
156+
websocket-client==1.8.0
157+
websockets==15.0.1
158+
wrapt==1.17.2
159+
yarl==1.20.1
160+
zipp==3.23.0

0 commit comments

Comments
 (0)