Skip to content

feat(observability): add component-probes feature for bpftrace component-level CPU attribution#24860

Open
connoryy wants to merge 19 commits intovectordotdev:masterfrom
connoryy:component-probes
Open

feat(observability): add component-probes feature for bpftrace component-level CPU attribution#24860
connoryy wants to merge 19 commits intovectordotdev:masterfrom
connoryy:component-probes

Conversation

@connoryy
Copy link

@connoryy connoryy commented Mar 6, 2026

Summary

Adds an opt-in component-probes Cargo feature that enables external bpftrace scripts to attribute CPU samples to individual Vector components by ID.

Vector configuration

How did you test this PR?

Unit tests for the component_probes module (label stability, uniqueness across threads, store/clear cycle). Tested end-to-end locally with a bpftrace script that attaches to the two uprobes (vector_register_thread, vector_register_component), builds the tid -> address and group_id -> name maps, and samples at 997 Hz. I can also provide a reference .bt script if requested.

Change Type

  • Bug fix
  • New feature
  • Dependencies
  • Non-functional (chore, refactoring, docs)
  • Performance

Is this a breaking change?

  • Yes
  • No

Does this PR include user facing changes?

  • Yes. Please add a changelog fragment based on our guidelines.
  • No. A maintainer will apply the no-changelog label to this PR.

References

Relevant issue: #24851

Notes

  • Please read our Vector contributor resources.
  • Do not hesitate to use @vectordotdev/vector to reach out to us regarding this PR.
  • Some CI checks run only after we manually approve them.
    • We recommend adding a pre-push hook, please see this template.
    • Alternatively, we recommend running the following locally before pushing to the remote branch:
      • make fmt
      • make check-clippy (if there are failures it's possible some of them can be fixed with make clippy-fix)
      • make test
  • After a review is requested, please avoid force pushes to help us review incrementally.
    • Feel free to push as many commits as you want. They will be squashed into one before merging.
    • For example, you can run git merge origin master and git push.
  • If this PR introduces changes Vector dependencies (modifies Cargo.lock), please
    run make build-licenses to regenerate the license inventory and commit the changes (if any). More details here.

connoryy added 7 commits March 3, 2026 16:17
…attribution

Adds an opt-in Cargo feature that lets external bpftrace scripts
attribute CPU time to individual Vector components.

A 4 KiB shared-memory array (VECTOR_COMPONENT_LABELS) is indexed by
tid % 4096. On span enter the component's group-id is written; on
span exit it is cleared. Both operations are single Relaxed atomic
byte stores (~2 ns, no syscall).

A separate uprobe symbol (vector_register_component) fires once per
component at startup so bpftrace can build the id → name mapping and
resolve the array's runtime address.

Disabled by default. Runtime code is gated to Linux.
…attribution

Adds an opt-in Cargo feature that lets external bpftrace scripts
attribute CPU time to individual Vector components.

A 4 KiB shared-memory array (VECTOR_COMPONENT_LABELS) is indexed by
tid % 4096. On span enter the component's group-id is written; on
span exit it is cleared. Both operations are single Relaxed atomic
byte stores (~2 ns, no syscall).

A separate uprobe symbol (vector_register_component) fires once per
component at startup so bpftrace can build the id → name mapping and
resolve the array's runtime address.

Disabled by default. Runtime code is gated to Linux.
@connoryy connoryy requested a review from a team as a code owner March 6, 2026 16:33
@github-actions
Copy link
Contributor

github-actions bot commented Mar 6, 2026

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@connoryy
Copy link
Author

connoryy commented Mar 6, 2026

I have read the CLA Document and I hereby sign the CLA

Copy link
Contributor

@thomasqueirozb thomasqueirozb left a comment

Choose a reason for hiding this comment

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

Thanks for this! This looks like a nice addition. Can you add a guide to website/content/en/guides/advanced/? This would make it possible for us to review and test this more easily and also have this documented to users that want to use this feature

@github-actions github-actions bot added the domain: ci Anything related to Vector's CI environment label Mar 6, 2026
@connoryy connoryy requested a review from a team as a code owner March 9, 2026 15:35

Replace `/path/to/vector` with your binary path:

```bpf

Check failure

Code scanning / check-spelling

Unrecognized Spelling

[bpf](#security-tab) is not a recognized word. \(unrecognized-spelling\)
if ($addr != 0) {
$group_id = *(uint32 *)$addr;
if ($group_id != 0) {
@stacks[@names[$group_id], ustack()] = count();

Check failure

Code scanning / check-spelling

Unrecognized Spelling

[ustack](#security-tab) is not a recognized word. \(unrecognized-spelling\)
```

This aggregates component-labeled stack traces directly in bpftrace. Start
bpftrace before Vector so it catches the registration uprobes during startup.

Check failure

Code scanning / check-spelling

Unrecognized Spelling

[uprobes](#security-tab) is not a recognized word. \(unrecognized-spelling\)
This aggregates component-labeled stack traces directly in bpftrace. Start
bpftrace before Vector so it catches the registration uprobes during startup.

If `ustack()` is not available in your environment, replace the `@stacks`

Check failure

Code scanning / check-spelling

Unrecognized Spelling

[ustack](#security-tab) is not a recognized word. \(unrecognized-spelling\)
line with a `printf` to emit raw labeled samples that can be joined with
stack traces from other tools like `perf`:

```bpf

Check failure

Code scanning / check-spelling

Unrecognized Spelling

[bpf](#security-tab) is not a recognized word. \(unrecognized-spelling\)
@connoryy connoryy requested a review from thomasqueirozb March 9, 2026 17:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

domain: ci Anything related to Vector's CI environment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants