Skip to content

feat: track interception-hook dispatches in telemetry - #6805

Merged
lucasgomide merged 1 commit into
mainfrom
luzk/hooks-telemetry
Aug 4, 2026
Merged

feat: track interception-hook dispatches in telemetry#6805
lucasgomide merged 1 commit into
mainfrom
luzk/hooks-telemetry

Conversation

@lucasgomide

@lucasgomide lucasgomide commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

HookDispatchedEvent was already emitted from the dispatcher but never reached Feature Usage, so hook adoption and policy aborts were invisible in ClickHouse. This adds hook_dispatched_span and wires the event listener so each dispatch counts as hooks:, with hooks:aborted on abort outcomes.

`HookDispatchedEvent` was already emitted from the dispatcher but never
landed in Feature Usage. Wire it through `hook_dispatched_span` so hook
adoption and abort outcomes (e.g. policy checks) show up in the same
ClickHouse aggregation as other features.
@github-actions github-actions Bot added the size/S label Aug 4, 2026
@coderabbitai

coderabbitai Bot commented Aug 4, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

This PR adds telemetry tracking for hook dispatch events. A new Telemetry.hook_dispatched_span method records feature usage per interception point, plus an additional record for aborted outcomes. The event listener imports HookDispatchedEvent and wires it to this telemetry method. Tests cover both units.

Changes

Hook dispatch telemetry tracking

Layer / File(s) Summary
Telemetry hook_dispatched_span method
lib/crewai/src/crewai/telemetry/telemetry.py
Adds hook_dispatched_span(interception_point, outcome), which records a hooks:<interception_point> feature usage span and an additional hooks:aborted span when the outcome is "aborted". Updates documented feature identifiers accordingly.
Event listener registration for HookDispatchedEvent
lib/crewai/src/crewai/events/event_listener.py
Imports HookDispatchedEvent and registers a handler that calls the new telemetry method with the event's interception point and outcome.
Telemetry and event integration tests
lib/crewai/tests/telemetry/test_telemetry.py
Adds tests for proceeded and aborted hook dispatch spans, and an event-bus integration test that verifies HookDispatchedEvent reaches telemetry with the correct interception point and outcome.

Sequence Diagram(s)

sequenceDiagram
  participant HookSystem
  participant EventBus
  participant EventListener
  participant Telemetry

  HookSystem->>EventBus: emit HookDispatchedEvent(interception_point, outcome)
  EventBus->>EventListener: dispatch HookDispatchedEvent
  EventListener->>Telemetry: hook_dispatched_span(interception_point, outcome)
  Telemetry->>Telemetry: record hooks:<interception_point> usage
  alt outcome == "aborted"
    Telemetry->>Telemetry: record hooks:aborted usage
  end
Loading

Suggested reviewers: greysonlalonde

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly and concisely describes the telemetry change for interception-hook dispatches.
Description check ✅ Passed The description accurately explains the telemetry gap and the changes that track hook dispatch and abort outcomes.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch luzk/hooks-telemetry

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.

@lucasgomide
lucasgomide merged commit 9d659a6 into main Aug 4, 2026
56 checks passed
@lucasgomide
lucasgomide deleted the luzk/hooks-telemetry branch August 4, 2026 17:13
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