Skip to content

adding crew ai instrumentation - #363

Open
venkata-pavani wants to merge 1 commit into
open-telemetry:mainfrom
venkata-pavani:crewai-inference
Open

adding crew ai instrumentation#363
venkata-pavani wants to merge 1 commit into
open-telemetry:mainfrom
venkata-pavani:crewai-inference

Conversation

@venkata-pavani

@venkata-pavani venkata-pavani commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Description

Description

What I changed What this means
Added CrewAI LLM call instrumentation CrewAI LLM calls now produce telemetry that follows the OpenTelemetry GenAI semantic conventions.
Added GenAI attributes The telemetry includes available model, provider, request settings, messages, tool definitions, response details, token usage, and error information.
Added spans and metrics The instrumentation emits inference spans, client duration metrics, and token usage metrics through opentelemetry-util-genai.
Added success and failure handling Successful calls complete their telemetry, while failed calls record and re-raise the original error without changing CrewAI's behavior.
Disabled CrewAI native telemetry by default This prevents two unrelated sets of telemetry from being emitted while this instrumentation is active.
Allowed users to retain CrewAI native telemetry Users can set CREWAI_DISABLE_TELEMETRY=false. Existing values are preserved and restored correctly. ref: #308 (comment)
Added completion-hook support Captured prompts and completions can be forwarded using the shared completion-hook mechanism.
Added tests Tests cover completed calls, failed calls, content capture, completion hooks, semantic-convention attributes, and native telemetry configuration.
Updated documentation and examples The README explains the new behavior and includes a custom completion-hook example.

Type of change

Please delete options that are not relevant.

  • New feature (non-breaking change which adds functionality)
  • This change requires a documentation update

How has this been tested?

Testing

Check Result
Pre-commit hooks ✅ Passed
Ruff lint and formatting ✅ Passed
Pyright typecheck ✅ Passed — 0 errors
CrewAI oldest supported version ✅ Passed — 10 tests
CrewAI latest supported version ✅ Passed — 10 tests
Conformance test ⚠️ Blocked locally because the installed Weaver CLI does not recognize --advice-data; the CrewAI scenario did not run

Future PR

In follow-up PRs, I plan to add CrewAI workflow, agent, and tool instrumentation using the invoke_workflow, invoke_agent, and execute_tool GenAI semantic conventions, along with proper context propagation and streaming support.

@venkata-pavani
venkata-pavani marked this pull request as ready for review August 7, 2026 03:22
@venkata-pavani
venkata-pavani requested a review from a team as a code owner August 7, 2026 03:22
Copilot AI lite review requested due to automatic review settings August 7, 2026 03:22
@opentelemetry-pr-dashboard

opentelemetry-pr-dashboard Bot commented Aug 7, 2026

Copy link
Copy Markdown

Pull request dashboard status

Waiting on the author · refreshed 2026-08-07 03:27 UTC

Two things need attention:

  • Required checks are failing — investigate the failures.
  • 1 review item — respond to each (e.g. link a commit, explain why not, ask a follow-up):
    • Inline threads: 1
Status above doesn't look right?
  • Just replied or pushed? Anything around or after the refresh time above may not be picked up yet — give it a few minutes.
  • Should this be with reviewers? Comment /dashboard route:reviewers to route it to them.
  • Anything wrong — including the routing? Report it with what you expected; it helps us improve the dashboard.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds first-pass OpenTelemetry GenAI instrumentation for CrewAI LLM inference by translating CrewAI LLM lifecycle events into opentelemetry-util-genai inference telemetry, along with unit + conformance scaffolding and docs/examples.

Changes:

  • Introduces a CrewAIInferenceEventListener that maps CrewAI LLM events to TelemetryHandler.inference() invocations.
  • Adds unit tests for inference event translation, completion hook wiring, and disabling CrewAI’s native telemetry while instrumented.
  • Adds a CrewAI conformance scenario + tox wiring and expands the package README with configuration and completion hook docs.

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
tox.ini Adds a CrewAI conformance tox env and updates CrewAI test commands to exclude conformance from non-conformance runs.
instrumentation/opentelemetry-instrumentation-genai-crewai/tests/test_instrumentor.py Adds tests ensuring CrewAI native telemetry is disabled only when instrumentation sets the default.
instrumentation/opentelemetry-instrumentation-genai-crewai/tests/test_inference.py Adds unit tests validating span attributes/status for completed/failed events and completion hook invocation.
instrumentation/opentelemetry-instrumentation-genai-crewai/tests/test_conformance.py Adds conformance test entrypoint wiring for CrewAI scenarios.
instrumentation/opentelemetry-instrumentation-genai-crewai/tests/conftest.py Ensures content_capture="SPAN_ONLY" for tests that assert content-related attributes exist.
instrumentation/opentelemetry-instrumentation-genai-crewai/tests/conformance/inference.py Adds a minimal inference conformance scenario emitting CrewAI LLM start/completion events.
instrumentation/opentelemetry-instrumentation-genai-crewai/tests/conformance/init.py Adds package marker for conformance scenarios.
instrumentation/opentelemetry-instrumentation-genai-crewai/src/opentelemetry/instrumentation/genai/crewai/event_listener.py Implements event listener translating CrewAI LLM events into GenAI inference invocations.
instrumentation/opentelemetry-instrumentation-genai-crewai/src/opentelemetry/instrumentation/genai/crewai/init.py Creates the listener during instrumentation and disables/restores CrewAI native telemetry via env var.
instrumentation/opentelemetry-instrumentation-genai-crewai/README.rst Updates README to reflect inference spans/metrics and documents native telemetry disabling + completion hooks.
instrumentation/opentelemetry-instrumentation-genai-crewai/examples/custom_hook.py Adds a minimal custom completion hook example.

Comment thread tox.ini
Comment on lines 56 to 60
; instrumentation-genai-crewai
py3{10,11,12,13,14}-test-instrumentation-genai-crewai-latest
py310-test-instrumentation-genai-crewai-oldest
py313-test-instrumentation-genai-crewai-conformance
lint-instrumentation-genai-crewai
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants