Skip to content

Commit d56b94b

Browse files
committed
Works?
1 parent 62ddd58 commit d56b94b

File tree

7 files changed

+262
-157
lines changed

7 files changed

+262
-157
lines changed

ddtrace/internal/core/crashtracking.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
from ddtrace.internal.native._native import crashtracker_init
2727
from ddtrace.internal.native._native import crashtracker_on_fork
2828
from ddtrace.internal.native._native import crashtracker_status
29+
from ddtrace.internal.native._native import crashtracker_register_native_runtime_callback
30+
from ddtrace.internal.native._native import CallbackResult
2931
except ImportError:
3032
is_available = False
3133

@@ -169,3 +171,26 @@ def crashtracker_fork_handler():
169171
print(f"Failed to start crashtracker: {e}", file=sys.stderr)
170172
return False
171173
return True
174+
175+
176+
def register_runtime_callback() -> bool:
177+
"""
178+
Register the native runtime callback for stack collection during crashes.
179+
180+
This should be called after crashtracker initialization to enable Python
181+
runtime stack trace collection in crash reports.
182+
183+
Returns:
184+
bool: True if callback was registered successfully, False otherwise
185+
"""
186+
if not is_available:
187+
return False
188+
if not is_started():
189+
return False
190+
191+
try:
192+
result = crashtracker_register_native_runtime_callback()
193+
return result == CallbackResult.Ok
194+
except Exception as e:
195+
print(f"Failed to register runtime callback: {e}", file=sys.stderr)
196+
return False

experimental_debug.json

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"runtime_stack": {
3+
"format": "Datadog Runtime Callback 1.0",
4+
"frames": [
5+
{
6+
"function": "<module>",
7+
"file": "<string>",
8+
"line": 1
9+
},
10+
{
11+
"function": "string_at",
12+
"file": "/home/bits/.pyenv/versions/3.13.5/lib/python3.13/ctypes/__init__.py",
13+
"line": 538
14+
},
15+
{
16+
"function": "<module>",
17+
"file": "tests/internal/crashtracker/test_crashtracker.py",
18+
"line": 653
19+
}
20+
],
21+
"runtime_type": "unknown"
22+
}
23+
}

src/native/Cargo.lock

Lines changed: 18 additions & 18 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/native/Cargo.toml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,19 @@ profiling = ["dep:datadog-profiling-ffi"]
1616

1717
[dependencies]
1818
anyhow = { version = "1.0", optional = true }
19-
datadog-crashtracker = { git = "https://github.com/DataDog/libdatadog", rev = "f15aff5b4d19ed1b78dbd202e2529a0c4a40f283", optional = true }
20-
datadog-ddsketch = { git = "https://github.com/DataDog/libdatadog", rev = "f15aff5b4d19ed1b78dbd202e2529a0c4a40f283" }
21-
datadog-library-config = { git = "https://github.com/DataDog/libdatadog", rev = "f15aff5b4d19ed1b78dbd202e2529a0c4a40f283" }
22-
data-pipeline = { git = "https://github.com/DataDog/libdatadog", rev = "f15aff5b4d19ed1b78dbd202e2529a0c4a40f283" }
23-
datadog-profiling-ffi = { git = "https://github.com/DataDog/libdatadog", rev = "f15aff5b4d19ed1b78dbd202e2529a0c4a40f283", optional = true, features = [
19+
datadog-crashtracker = { git = "https://github.com/DataDog/libdatadog", rev = "488d39573f008957784aa4ef726fadb4bee5a302", optional = true }
20+
datadog-ddsketch = { git = "https://github.com/DataDog/libdatadog", rev = "488d39573f008957784aa4ef726fadb4bee5a302" }
21+
datadog-library-config = { git = "https://github.com/DataDog/libdatadog", rev = "488d39573f008957784aa4ef726fadb4bee5a302" }
22+
data-pipeline = { git = "https://github.com/DataDog/libdatadog", rev = "488d39573f008957784aa4ef726fadb4bee5a302" }
23+
datadog-profiling-ffi = { git = "https://github.com/DataDog/libdatadog", rev = "488d39573f008957784aa4ef726fadb4bee5a302", optional = true, features = [
2424
"cbindgen",
2525
] }
26-
ddcommon = { git = "https://github.com/DataDog/libdatadog", rev = "f15aff5b4d19ed1b78dbd202e2529a0c4a40f283" }
26+
ddcommon = { git = "https://github.com/DataDog/libdatadog", rev = "488d39573f008957784aa4ef726fadb4bee5a302" }
2727
pyo3 = { version = "0.25", features = ["extension-module", "anyhow"] }
2828

2929
[build-dependencies]
3030
pyo3-build-config = "0.25"
31-
build_common = { git = "https://github.com/DataDog/libdatadog", rev = "f15aff5b4d19ed1b78dbd202e2529a0c4a40f283", features = [
31+
build_common = { git = "https://github.com/DataDog/libdatadog", rev = "488d39573f008957784aa4ef726fadb4bee5a302", features = [
3232
"cbindgen",
3333
] }
3434

0 commit comments

Comments
 (0)