Skip to content

feat(crewAI): add instrumentation for async API (akickoff)#4342

Open
tsdaemon wants to merge 3 commits into
traceloop:mainfrom
datarobot-forks:anatolii/crewai-akickoff
Open

feat(crewAI): add instrumentation for async API (akickoff)#4342
tsdaemon wants to merge 3 commits into
traceloop:mainfrom
datarobot-forks:anatolii/crewai-akickoff

Conversation

@tsdaemon

@tsdaemon tsdaemon commented Jul 2, 2026

Copy link
Copy Markdown

CrewAI has released an async interface akickoff which is not covered in the current instrumentation. This adds instrumentation for the new execution path. This also removes deprecated GenAiSystemValues.

image
  • I have added tests that cover my changes.
  • If adding a new instrumentation or changing an existing one, I've added screenshots from some observability platform showing the change.
  • PR name follows conventional commits format: feat(instrumentation): ... or fix(instrumentation): ....
  • (If applicable) I have updated the documentation accordingly.

Summary by CodeRabbit

  • New Features

    • Added broader support for CrewAI’s native async execution paths, improving tracing coverage for async workflows, agent actions, task execution, and model calls.
    • Refined provider name labeling for some AI providers so trace attributes are more consistent with current naming conventions.
  • Bug Fixes

    • Improved compatibility with newer CrewAI versions while safely skipping unsupported async methods on older releases.
    • Enhanced span status and error reporting for async operations.

@coderabbitai

coderabbitai Bot commented Jul 2, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough
📝 Walkthrough
🚥 Pre-merge checks | ✅ 2
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly reflects the main change: adding CrewAI async API instrumentation, including akickoff.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@packages/opentelemetry-instrumentation-crewai/opentelemetry/instrumentation/crewai/instrumentation.py`:
- Around line 27-33: The LiteLLM prefix-to-OTel provider mapping in
instrumentation.py is incomplete for CrewAI model IDs. Update
_LITELLM_PREFIX_TO_OTEL_PROVIDER in the CrewAI instrumentation to normalize
bedrock/... to the AWS provider name and add the missing azure_ai/... mapping to
the Azure AI OpenAI provider name, so get_otel_provider_name (or the lookup path
used by CrewAI spans) returns the correct gen_ai.provider.name value.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 3d2f6bd3-05ca-4427-81f6-8fccfc354c8a

📥 Commits

Reviewing files that changed from the base of the PR and between 93429cf and 5508e76.

⛔ Files ignored due to path filters (1)
  • packages/opentelemetry-instrumentation-crewai/uv.lock is excluded by !**/*.lock
📒 Files selected for processing (3)
  • packages/opentelemetry-instrumentation-crewai/opentelemetry/instrumentation/crewai/instrumentation.py
  • packages/opentelemetry-instrumentation-crewai/pyproject.toml
  • packages/opentelemetry-instrumentation-crewai/tests/test_async_instrumentation.py

Comment on lines 27 to +33
_LITELLM_PREFIX_TO_OTEL_PROVIDER = {
"openai": GenAISystem.OPENAI.value,
"anthropic": GenAISystem.ANTHROPIC.value,
"gemini": GenAiSystemValues.GCP_GEMINI.value,
"vertex_ai": GenAiSystemValues.GCP_VERTEX_AI.value,
"gemini": GenAiProviderNameValues.GCP_GEMINI.value,
"vertex_ai": GenAiProviderNameValues.GCP_VERTEX_AI.value,
"bedrock": GenAISystem.AWS.value,
"azure": GenAiSystemValues.AZURE_AI_OPENAI.value,
"azure": GenAiProviderNameValues.AZURE_AI_OPENAI.value,

@coderabbitai coderabbitai Bot Jul 2, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Verify enum availability and cross-package provider expectations.
uv run python - <<'PY'
from opentelemetry.semconv._incubating.attributes.gen_ai_attributes import GenAiProviderNameValues

for name in ("AWS_BEDROCK", "AZURE_AI_INFERENCE"):
    print(name, getattr(GenAiProviderNameValues, name).value)
PY

rg -n -C2 '("bedrock"|"azure_ai"|AWS_BEDROCK|AZURE_AI_INFERENCE)' \
  packages/opentelemetry-instrumentation-litellm \
  packages/opentelemetry-instrumentation-crewai

Repository: traceloop/openllmetry

Length of output: 3426


🏁 Script executed:

sed -n '1,160p' packages/opentelemetry-instrumentation-crewai/opentelemetry/instrumentation/crewai/instrumentation.py
printf '\n---\n'
rg -n -C3 'AWS_BEDROCK|AZURE_AI_INFERENCE|bedrock|azure_ai' packages/opentelemetry-instrumentation-crewai

Repository: traceloop/openllmetry

Length of output: 8219


Normalize Bedrock and Azure AI provider names. bedrock/... maps to AWS, and azure_ai/... has no entry, so CrewAI spans will emit incorrect or missing gen_ai.provider.name values for LiteLLM-style model IDs.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@packages/opentelemetry-instrumentation-crewai/opentelemetry/instrumentation/crewai/instrumentation.py`
around lines 27 - 33, The LiteLLM prefix-to-OTel provider mapping in
instrumentation.py is incomplete for CrewAI model IDs. Update
_LITELLM_PREFIX_TO_OTEL_PROVIDER in the CrewAI instrumentation to normalize
bedrock/... to the AWS provider name and add the missing azure_ai/... mapping to
the Azure AI OpenAI provider name, so get_otel_provider_name (or the lookup path
used by CrewAI spans) returns the correct gen_ai.provider.name value.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks — split into the two parts:

  • azure_ai/: good catch, added "azure_ai": GenAiProviderNameValues.AZURE_AI_INFERENCE.value (→ azure.ai.inference). LiteLLM's azure_ai/ prefix targets Azure AI Foundry serverless deployments (Azure AI Inference API), which is distinct from azure/ → Azure OpenAI (azure.ai.openai). Previously azure_ai/... fell through to None.

  • bedrock/: this one is already correct and needs no change. It maps to GenAISystem.AWS.value, whose value is "aws.bedrock" — identical to GenAiProviderNameValues.AWS_BEDROCK.value. So bedrock spans already emit gen_ai.provider.name = aws.bedrock. (The verification script above only inspected GenAiProviderNameValues, not the actual GenAISystem.AWS value.)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, something went wrong! Please try again later. 🐰 💔

@CLAassistant

CLAassistant commented Jul 2, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants