-
Notifications
You must be signed in to change notification settings - Fork 397
[WIP] Implement custom exceptions raised from profiler code #4990
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?
[WIP] Implement custom exceptions raised from profiler code #4990
Conversation
|
✅ Tests 🎉 All green!❄️ No new flaky tests detected 🎯 Code Coverage 🔗 Commit SHA: 9e8e039 | Docs | Datadog PR Page | Was this helpful? Give us feedback! |
f40e845 to
c8670d6
Compare
This gets us closer to allowing these errors to be sent to telemetry.
8550883 to
3d908d7
Compare
Typing analysisNote: Ignored files are excluded from the next sections. Untyped methodsThis PR introduces 1 partially typed method, and clears 1 partially typed method. It increases the percentage of typed methods from 53.12% to 53.15% (+0.03%). Partially typed methods (+1-1)❌ Introduced:If you believe a method or an attribute is rightfully untyped or partially typed, you can add |
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.
BenchmarksBenchmark execution time: 2025-11-07 21:32:47 Comparing candidate commit f04f01d in PR branch Found 0 performance improvements and 2 performance regressions! Performance is the same for 42 metrics, 2 unstable metrics. scenario:profiling - Allocations (baseline)
scenario:tracing - Propagation - Datadog
|
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.
What does this PR do?
THIS IS FROM CLAUDE CODE - REVIEW ACCORDINGLY
In #4985 we removed
pii_safeto get error logs back into compliance that the messages that we send to intake are a set of known strings.In this PR we implement a two-tier custom exception strategy for profiler C code errors to prevent PII in telemetry while preserving full local debugging information.
Exception Types:
ProfilingError: Constant error messages → included in telemetry (safe for fingerprinting)ProfilingInternalError: Dynamic content (libdatadog errors, system state) → excluded from telemetry (prevents fingerprinting issues)Changes:
RuntimeErrortoProfilingErrorProfilingInternalErrorProfilingErrormessagesMotivation:
Following PR #4985 which removed the
pii_safeparameter, we needed a way to safely include known-constant profiler error messages in telemetry without risking PII leaks from dynamic content.This approach:
This was the initial recommendation/suggestion that spawned this
pii_safeoption. Only invoke telemetry methods with PII safe arguments.rb_raise(rb_eRuntimeError, ...torb_raise(rb_eDatadogProfilingError, ...Change log entry
None.
Additional Notes:
Builds on PR #4985. All profiler errors now use typed exceptions instead of generic
RuntimeError, making error handling more explicit and safer for telemetry ingestion.How to test the change?
I tried to update the tests