-
Notifications
You must be signed in to change notification settings - Fork 398
[PROF-12743] Runtime stack collection callback registration #4984
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
|
👋 Hey @DataDog/ruby-guild, please fill "Change log entry" section in the pull request description. If changes need to be present in CHANGELOG.md you can state it this way **Change log entry**
Yes. A brief summary to be placed into the CHANGELOG.md(possible answers Yes/Yep/Yeah) Or you can opt out like that **Change log entry**
None.(possible answers No/Nope/None) Visited at: 2025-11-17 03:53:49 UTC |
Typing analysisThis PR does not change typing compared to the base branch. |
This comment has been minimized.
This comment has been minimized.
e628919 to
564c828
Compare
f102a46 to
53afc20
Compare
|
Paper trail [ ] Checking unreasonable string sizes |
77d1391 to
1ebb325
Compare
| # * by msgpack, another datadog gem dependency | ||
| # (https://github.com/msgpack/msgpack-ruby/blob/18ce08f6d612fe973843c366ac9a0b74c4e50599/ext/msgpack/extconf.rb#L8) | ||
| append_cflags '-std=gnu99' | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Taken from ext/datadog_profiling_native_extension/extconf.rb, so that we can access private Ruby headers
1ebb325 to
4e51bf3
Compare
|
|
||
| # Benchmark result files | ||
| /benchmarks/*.json | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will be removed when this repo is updated to use libdatadog v24; just for lower friction when local dev rn
| @@ -1,7 +1,49 @@ | |||
| #include <ruby.h> | |||
| #include <datadog/crashtracker.h> | |||
| #include "extconf.h" | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Taken from ext/datadog_profiling_native_extension/private_vm_api_access.c so that we can access internal Ruby structures
3c782d0 to
8d957bf
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Codex Review
Here are some automated review suggestions for this pull request.
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
8d957bf to
98cb61e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Codex Review
Here are some automated review suggestions for this pull request.
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
98cb61e to
77de730
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Codex Review
Here are some automated review suggestions for this pull request.
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
77de730 to
16fede1
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Codex Review
Here are some automated review suggestions for this pull request.
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| Utils::AtForkMonkeyPatch.apply! | ||
|
|
||
| start_or_update_on_fork(action: :start, tags: tags) | ||
| register_runtime_stack_callback |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Guard runtime callback registration on repeated starts
The new start path always invokes register_runtime_stack_callback, and register_runtime_stack_callback raises whenever the native call returns false (e.g. callback already registered). Because the crash tracker component is process‑wide and Datadog.configure can instantiate and start a new component multiple times, the second start now raises Failed to register runtime stack callback and prevents reconfiguration or restarts from succeeding. Consider checking _native_is_runtime_callback_registered or otherwise making the registration idempotent so that later start calls do not blow up.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not true, if a callback is already registered, it should replace it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Codex Review
Here are some automated review suggestions for this pull request.
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
989188a to
5309fef
Compare
5309fef to
50da69c
Compare
3ff1774 to
af340dd
Compare
af340dd to
bc7eb46
Compare

What does this PR do?
We want to collect runtime frames for the crashtracker. This approach follows how we access the call stack for profiling.
CI fails currently because we are not on libdatadog v24 yet. Once this PR is merged and this PR is rebased, we should be green
Motivation:
Change log entry
Additional Notes:
How to test the change?
"Ruby and C method runtime stack capture"RSpec testRun a ruby program with the crashtracker initialized. Runtime stacks should be visible in the
experimentalsection of the crash report. Stacktrace emitted from an example script I wrote to test