Skip to content

Conversation

@gyuheon0h
Copy link
Contributor

@gyuheon0h gyuheon0h commented Oct 16, 2025

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.

Motivation:

Change log entry

Additional Notes:

How to test the change?

"Ruby and C method runtime stack capture" RSpec test

Run a ruby program with the crashtracker initialized. Runtime stacks should be visible in the experimental section of the crash report. Stacktrace emitted from an example script I wrote to test

{
  "format": "Datadog Runtime Callback 1.0",
  "frames": [
    {
      "file": "<Fiddle (C extension)>",
      "function": "free"
    },
    {
      "file": "debug_runtime_callback.rb",
      "function": "final_crash_point",
      "line": 244
    },
    {
      "file": "<Integer (C extension)>",
      "function": "times"
    },
    {
      "file": "debug_runtime_callback.rb",
      "function": "final_crash_point",
      "line": 243
    },
   .....
    {
      "file": "debug_runtime_callback.rb",
      "function": "main_crash_test",
      "line": 251
    },
    {
      "file": "debug_runtime_callback.rb",
      "function": "<main>",
      "line": 276
    },
    {
      "file": "<Kernel (C extension)>",
      "function": "fork"
    }
  ]
}

@gyuheon0h gyuheon0h requested review from a team as code owners October 16, 2025 09:34
@gyuheon0h gyuheon0h marked this pull request as draft October 16, 2025 09:34
@github-actions
Copy link

github-actions bot commented Oct 16, 2025

👋 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-18 21:06:17 UTC

@github-actions github-actions bot added the core Involves Datadog core libraries label Oct 16, 2025
@github-actions
Copy link

github-actions bot commented Oct 16, 2025

Typing analysis

Ignored files

This PR introduces 1 ignored file. It decreases the percentage of typed files from 38.32% to 38.21% (-0.11%).

Ignored files (+1-0)Introduced:
lib/datadog/core/crashtracking/component.rb

Note: Ignored files are excluded from the next sections.

Untyped other declarations

This PR clears 1 untyped other declaration. It decreases the percentage of typed other declarations from 68.02% to 67.96% (-0.06%).

Untyped other declarations (+0-1)Cleared:
sig/datadog/core/crashtracking/component.rbs:33
└── attr_reader logger: untyped

@datadog-datadog-prod-us1
Copy link
Contributor

datadog-datadog-prod-us1 bot commented Oct 20, 2025

✅ Tests

🎉 All green!

❄️ No new flaky tests detected
🧪 All tests passed

🎯 Code Coverage
Patch Coverage: 85.14%
Total Coverage: 98.51% (+0.03%)

View detailed report

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: df60ca0 | Docs | Datadog PR Page | Was this helpful? Give us feedback!

@gyuheon0h gyuheon0h force-pushed the gyuheon0h/prof-12743-runtime-stack-callback branch from e628919 to 564c828 Compare October 24, 2025 15:37
Copy link
Contributor Author

gyuheon0h commented Oct 24, 2025

This stack of pull requests is managed by Graphite. Learn more about stacking.

@gyuheon0h gyuheon0h force-pushed the gyuheon0h/prof-12743-runtime-stack-callback branch 3 times, most recently from f102a46 to 53afc20 Compare October 31, 2025 15:19
@gyuheon0h
Copy link
Contributor Author

gyuheon0h commented Nov 8, 2025

Paper trail

[ ] Checking unreasonable string sizes
[ ] Checking that string pointers point to valid strings
[ ] Checking that control frames are valid
[ ] Checking that iseq is valid, and the instruction size is not unreasonable
[ ] Validating that pointers are readable using mincore
[ ] Checking for recursive frames
[ ] Strings can have different representations, take that into account
[ ] Ruby apps commonly have very deep stacks. We default in the profiler to collecting 400 and we've seen GitHub go close to 600, handle this
[ ] Pay attention to structure keeping the bytecode-to-line mapping

@gyuheon0h gyuheon0h force-pushed the gyuheon0h/prof-12743-runtime-stack-callback branch 6 times, most recently from 77d1391 to 1ebb325 Compare November 17, 2025 02:56
# * by msgpack, another datadog gem dependency
# (https://github.com/msgpack/msgpack-ruby/blob/18ce08f6d612fe973843c366ac9a0b74c4e50599/ext/msgpack/extconf.rb#L8)
append_cflags '-std=gnu99'

Copy link
Contributor Author

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

@gyuheon0h gyuheon0h force-pushed the gyuheon0h/prof-12743-runtime-stack-callback branch from 1ebb325 to 4e51bf3 Compare November 17, 2025 03:40

# Benchmark result files
/benchmarks/*.json

Copy link
Contributor Author

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"
Copy link
Contributor Author

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

@gyuheon0h gyuheon0h force-pushed the gyuheon0h/prof-12743-runtime-stack-callback branch 2 times, most recently from 3c782d0 to 8d957bf Compare November 17, 2025 03:48
@github-actions github-actions bot added the profiling Involves Datadog profiling label Nov 17, 2025
@gyuheon0h gyuheon0h marked this pull request as ready for review November 17, 2025 03:52
@gyuheon0h gyuheon0h changed the title [WIP][crashtracking] Runtime stack collection callback registration [crashtracking] Runtime stack collection callback registration Nov 17, 2025
@gyuheon0h gyuheon0h changed the title [crashtracking] Runtime stack collection callback registration [PROF-12743] Runtime stack collection callback registration Nov 17, 2025
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a 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".

@gyuheon0h gyuheon0h force-pushed the gyuheon0h/prof-12743-runtime-stack-callback branch from 831cda9 to 4b7af64 Compare November 18, 2025 23:26
@gyuheon0h gyuheon0h force-pushed the gyuheon0h/prof-12743-runtime-stack-callback branch from 4b7af64 to b8103ad Compare November 18, 2025 23:26
@gyuheon0h gyuheon0h force-pushed the gyuheon0h/prof-12743-runtime-stack-callback branch 17 times, most recently from ace0e43 to 185b3a2 Compare November 21, 2025 07:10
@gyuheon0h gyuheon0h force-pushed the gyuheon0h/prof-12743-runtime-stack-callback branch from 185b3a2 to df60ca0 Compare November 21, 2025 14:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core Involves Datadog core libraries profiling Involves Datadog profiling

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants