-
Notifications
You must be signed in to change notification settings - Fork 398
Telemetry-safe error reporting for native extensions #5076
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?
Telemetry-safe error reporting for native extensions #5076
Conversation
This gets us closer to allowing these errors to be sent to telemetry.
Add ruby_helpers.h include to 8 C files that use datadog_profiling_error_class and datadog_profiling_internal_error_class but were missing the header declaration. This fixes the compilation error: error: 'datadog_profiling_error_class' undeclared Files fixed: - clock_id_from_pthread.c - collectors_gc_profiling_helper.c - collectors_stack.c - collectors_thread_context.c - encoded_profile.c - libdatadog_helpers.c - private_vm_api_access.c - unsafe_api_calls_check.c
Move ruby_helpers.h include after private VM headers to avoid conflicts. This file requires private VM headers to be included first before any public Ruby headers, but ruby_helpers.h includes datadog_ruby_common.h which includes ruby.h, causing header ordering conflicts. Fixes compilation error: 'expected ')' before '==' token in RHASH_EMPTY_P'
Cannot include ruby_helpers.h in this file as it pulls in public Ruby headers (via datadog_ruby_common.h) that conflict with private VM headers. Instead, declare the exception class globals as extern, following the pattern already established in this file for other declarations. This fully resolves the header ordering compilation error.
Method was renamed from safe_exception_message to constant_exception_message but the RBS signature file was not updated, causing Steep type errors.
The error method must be public but was accidentally made private when constant_exception_message was added. Moving it before the private keyword restores its public visibility. Fixes test failure: NoMethodError: private method 'error' called
Serialization errors contain dynamic libdatadog content, so they should raise ProfilingInternalError (not ProfilingError or RuntimeError). Updated both the Ruby wrapper code and the test expectation to use ProfilingInternalError consistently. Fixes test failure expecting ProfilingError but getting RuntimeError.
Signed-off-by: Marco Costa <[email protected]>
Signed-off-by: Marco Costa <[email protected]>
Signed-off-by: Marco Costa <[email protected]>
Signed-off-by: Marco Costa <[email protected]>
BenchmarksBenchmark execution time: 2025-12-01 23:29:10 Comparing candidate commit f92ebb4 in PR branch Found 0 performance improvements and 0 performance regressions! Performance is the same for 44 metrics, 2 unstable metrics. |
…remediation-custom-profiler-code' into marcotc/error-logs-remediation-custom-profiler-code
b2d87f4 to
6a6bdfb
Compare
Signed-off-by: Marco Costa <[email protected]>
|
✅ Tests 🎉 All green!❄️ No new flaky tests detected 🎯 Code Coverage 🔗 Commit SHA: 976a297 | Docs | Datadog PR Page | Was this helpful? Give us feedback! |
(I'll squash the commits on reviews finish)
What does this PR do?
This PR ensure errors raised from native
ext/code have enough context to be valuable in telemetry.Motivation:
Because error information sent to telemetry cannot have arbitrary, dynamic data, we must ensure that we are only sending values that are known at gem build time.
Because our fallback is to only report the exception class, this PR adds a
telemetry_messageto native exceptions, so that their error information is not completely lost.Change log entry
Yes. Telemetry: Added static error reporting for native extensions.Additional Notes:
There's a follow up PR to reduce code duplication for the
datadog_ruby_common.c/hfiles: #5088How to test the change?
Easiest and fastest test it:
bundle exec rake clean compile && bundle exec rake spec:profilingThere are more products supported by
libdatadog, but at that point, just run CI :)