-
Notifications
You must be signed in to change notification settings - Fork 375
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
[PROF-11003] Fix unsafe initialization when using profiler with otel tracing #4195
[PROF-11003] Fix unsafe initialization when using profiler with otel tracing #4195
Conversation
The docs for `rb_protect` clearly say that we must call `rb_set_errinfo (Qnil)` if we want the exception to be cleanly ignored.
When called from inside an allocation (NEWOBJ tracepoint), it's not safe to allocate further new objects (including exceptions to be raised). One such example of an allocation is when calling `read_otel_current_span_key_const` to initialize the otel span key. Thus, this commit introduces the `is_safe_to_allocate_objects` flag (and plumbs it around a bunch of methods...) so that we can gate calls to `read_otel_current_span_key_const` and not perform them when they're not safe.
I was testing on 3.1 so I missed this one >_>
Thank you for updating Change log entry section 👏 Visited at: 2024-12-05 14:06:54 UTC |
Datadog ReportBranch report: ✅ 0 Failed, 22411 Passed, 1459 Skipped, 5m 51.73s Total Time |
BenchmarksBenchmark execution time: 2024-12-05 12:48:45 Comparing candidate commit 47b1706 in PR branch Found 0 performance improvements and 1 performance regressions! Performance is the same for 30 metrics, 2 unstable metrics. scenario:profiler - sample timeline=false
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #4195 +/- ##
==========================================
- Coverage 97.76% 97.75% -0.01%
==========================================
Files 1357 1357
Lines 81890 81914 +24
Branches 4164 4164
==========================================
+ Hits 80060 80076 +16
- Misses 1830 1838 +8 ☔ View full report in Codecov by Sentry. |
What does this PR do?
This PR fixes two issues in the profiler's support for reading from the opentelemetry ("otel") context:
If during the initialization of our otel reading code an exception was raised, we tried to rescue it but did not properly clean it up so it could still confuse the app/cause weird behaviors
Initialization of the otel reading code could happen during an allocation sample, where it's not safe to run random Ruby code (including throwing exceptions)
Motivation:
I suspect these issues may be linked to a customer crash:
...but I could not reproduce it myself. Nevertheless, the things being fixed were still definitely bugs ;)
Change log entry
Yes.
Fix unsafe initialization when using profiler with otel tracing
Additional Notes:
N/A
How to test the change?
This change includes test coverage (took longer than the fixes to code :P)