Skip to content

Lorenze/feat/oss warf traces - #6980

Draft
lorenzejay wants to merge 4 commits into
mainfrom
lorenze/feat/oss-warf-traces
Draft

Lorenze/feat/oss warf traces#6980
lorenzejay wants to merge 4 commits into
mainfrom
lorenze/feat/oss-warf-traces

Conversation

@lorenzejay

Copy link
Copy Markdown
Collaborator

No description provided.

lucasgomide and others added 4 commits August 12, 2026 15:24
Open spans directly on the user's thread so that stdlib log records
emitted during hot paths like `Crew.kickoff`, `BaseTool.run`, and
`LLM.call` carry the active trace context and correlate with the
spans they belong to — a gap the previous metrics-only telemetry
could not close. Introduces a `crewai.telemetry.otel` module
exposing `operation` and `follows_from`, instruments the execution
hot paths, and propagates the active context across every
parallel-dispatch site. Depends only on `opentelemetry-api` so
provider and exporter choice stays with the host application per the
standard OTel library pattern; without an installed SDK the
`ProxyTracer` keeps everything as a NoOp.

Co-authored-by: Cursor <cursoragent@cursor.com>
Address review feedback on the native OpenTelemetry instrumentation
`test_otel.py`'s `span_exporter` fixture installed an SDK
`TracerProvider` once via module-level globals and never restored the
default `ProxyTracerProvider`, so `test_otel_noop.py`'s unconfigured-
default-state assertions failed whenever the two files ran on the same
worker. Install the SDK provider fresh per test and reset the global
slot back to `ProxyTracerProvider` in `finally`; `_tracer()` re-resolves
on every span so swapping providers between tests is safe.
`Telemetry.set_tracer()` installed crewAI's anonymous SDK
`TracerProvider` into OpenTelemetry's process-global slot, so the first
`Crew` constructed in a test or host application replaced the default
`ProxyTracerProvider` and exfiltrated every host span emitted via
`trace.get_tracer(...)` to crewAI's OTLP endpoint. Keep the provider
local to the `Telemetry` instance and route every anonymous span
through `self.provider.get_tracer("crewai.telemetry")` so the global
slot stays untouched. Mirrors the fix in `crewai_core.telemetry`,
drops the now-dead `set_tracer()` calls in `event_listener.py` and
`crewai_cli.command`, and adds regression coverage that asserts the
provider stays a `ProxyTracerProvider` after constructing a `Crew`.
@coderabbitai

coderabbitai Bot commented Aug 12, 2026

Copy link
Copy Markdown

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 37fab150-45ea-48a9-bcfd-32eaeb8c1338

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

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.

with operation("failing op"):
raise RuntimeError("boom")

finished = span_exporter.get_finished_spans()
with operation("doubly recorded"):
raise RuntimeError("once")

span = span_exporter.get_finished_spans()[0]
with operation("cancelled op"):
raise asyncio.CancelledError("cancel")

span = span_exporter.get_finished_spans()[0]
with operation("paused op", expected_exceptions=(_ExpectedPause,)):
raise _ExpectedPause("pause")

span = span_exporter.get_finished_spans()[0]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants