-
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-8139] Upgrade to libdatadog 4 #3104
Conversation
**What does this PR do?** This PR includes the changes documented in the "Releasing a new version to rubygems.org" part of the README: <https://github.com/datadog/libdatadog/tree/main/ruby#releasing-a-new-version-to-rubygemsorg> **Motivation:** Enable Ruby to use libdatadog v4.0.0. **Additional Notes:** N/A **How to test the change?** I've tested this release locally against the changes in DataDog/dd-trace-rb#3104 . As a reminder, new libdatadog releases don't get automatically picked up by Ruby, so the PR that bumps the Ruby profiler will also test this release against all supported Ruby versions.
**What does this PR do?** This PR includes the changes documented in the "Releasing a new version to rubygems.org" part of the README: <https://github.com/datadog/libdatadog/tree/main/ruby#releasing-a-new-version-to-rubygemsorg> **Motivation:** Enable Ruby to use libdatadog v4.0.0. **Additional Notes:** N/A **How to test the change?** I've tested this release locally against the changes in DataDog/dd-trace-rb#3104 . As a reminder, new libdatadog releases don't get automatically picked up by Ruby, so the PR that bumps the Ruby profiler will also test this release against all supported Ruby versions.
Codecov Report
@@ Coverage Diff @@
## master #3104 +/- ##
=======================================
Coverage 98.16% 98.16%
=======================================
Files 1323 1323
Lines 75187 75232 +45
Branches 3430 3430
=======================================
+ Hits 73804 73850 +46
+ Misses 1383 1382 -1
... and 3 files with indirect coverage changes 📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My C is a bit rusty, but LGTM.
ddog_prof_Profile_Result reset_result = ddog_prof_Profile_reset(args.profile, NULL /* start_time is optional */ ); | ||
if (reset_result.tag == DDOG_PROF_PROFILE_RESULT_ERR) { | ||
return rb_ary_new_from_args(2, error_symbol, rb_sprintf("Failed to reset profile: %"PRIsVALUE, get_error_details_and_drop(&reset_result.err))); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we use reset_profile
here?
Maybe the function reset_profile
could return if the profiler successfully rest and if not the caller can choose what to do
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Simplified as 80d8cec
@@ -428,7 +430,7 @@ void record_sample(VALUE recorder_instance, ddog_prof_Slice_Location locations, | |||
|
|||
sampler_unlock_active_profile(active_slot); | |||
|
|||
if (result.tag == DDOG_PROF_PROFILE_ADD_RESULT_ERR) { | |||
if (result.tag == DDOG_PROF_PROFILE_RESULT_ERR) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was not mentioned in the breaking changes on the PR description. Is this expected?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes! This was slightly folded under
A bunch of APIs started returning ddog_prof_Profile_Result.
The API changed to no longer return an AddResult
and use a regular Result
(diff of profiling.h
header):
-struct ddog_prof_Profile_AddResult ddog_prof_Profile_add(struct ddog_prof_Profile *profile,
+struct ddog_prof_Profile_Result ddog_prof_Profile_add(struct ddog_prof_Profile *profile,
struct ddog_prof_Sample sample);
Error handling on result structure is similar, but the constant to indicate the error is different.
**What does this PR do?** This PR upgrades dd-trace-rb to use libdatadog 4. This release includes a number of memory footprint improvements, but there were also a few breaking API changes, which needed adjustments in our code. **Motivation:** Use the latest libdatadog release. **Additional Notes:** The backwards incompatible changes were mainly these 3: * Instead of having a `ddog_prof_Location` be able to include multiple `ddog_prof_Line`s, now a location can only include a single line. In our code we already always used 1-line-per-location only, so we only had to adjust to the `ddog_pprof_Line` getting removed. * The `ddog_prof_Profile_new` now returns a `ddog_prof_Profile`, instead of a pointer; conversely, a bunch of other APIs now want a pointer to a `ddog_prof_Profile` instead of the `ddog_prof_Profile` directly. * A bunch of APIs started returning `ddog_prof_Profile_Result`. **How to test the change?** Our existing test coverage already exercises all of these code paths.
b187f48
to
4d837ef
Compare
I've rebased this on top of current master without any other changes so as to incorporate the new CI job which is a requirement for merging. |
This is slightly inconsistent with the error result when profile serialization fails, but a reset failing is way less likely, and this allows us to simplify the code.
What does this PR do?
This PR upgrades dd-trace-rb to use libdatadog 4. This release includes a number of memory footprint improvements, but there were also a few breaking API changes, which needed adjustments in our code.
Motivation:
Use the latest libdatadog release.
Additional Notes:
✅ Done
I'm opening this PR as a draft until the libdatadog 4 release is up on rubygems.org, but I've already tested it locally.✅ Done
After libdatadog 4 gets released on rubygems.org, we should update the appraisals and then mark the PR as non-draft.The backwards incompatible changes were mainly these 3:
Instead of having a
ddog_prof_Location
be able to include multipleddog_prof_Line
s, now a location can only include a single line.In our code we already always used 1-line-per-location only, so we only had to adjust to the
ddog_pprof_Line
getting removed.The
ddog_prof_Profile_new
now returns addog_prof_Profile
, instead of a pointer; conversely, a bunch of other APIs now want a pointer to addog_prof_Profile
instead of theddog_prof_Profile
directly.A bunch of APIs started returning
ddog_prof_Profile_Result
.How to test the change?
Our existing test coverage already exercises all of these code paths.
For Datadog employees:
credentials of any kind, I've requested a review from
@DataDog/security-design-and-guidance
.