-
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
Upgrade profiler to use libdatadog v2.0.0 #2599
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
00b9546
Attach local root span id to profiling samples as a number not as a s…
ivoanjo 0a7f10a
Raise ArgumentError when ddog_prof_Profile_add returns a failure
ivoanjo 9a42eaf
Adopt to new error reporting API, as well as to new drop methods
ivoanjo 2a52553
Remove FIXME now that libdatadog has been fixed
ivoanjo f4abd1d
Bump dependency to pull in libdatadog 2.0
ivoanjo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -282,18 +282,15 @@ static VALUE _native_serialize(DDTRACE_UNUSED VALUE _self, VALUE recorder_instan | |
ddog_prof_Profile_SerializeResult serialized_profile = args.result; | ||
|
||
if (serialized_profile.tag == DDOG_PROF_PROFILE_SERIALIZE_RESULT_ERR) { | ||
VALUE err_details = ruby_string_from_prof_vec_u8(serialized_profile.err); | ||
ddog_prof_Profile_SerializeResult_drop(serialized_profile); | ||
return rb_ary_new_from_args(2, error_symbol, err_details); | ||
return rb_ary_new_from_args(2, error_symbol, get_error_details_and_drop(&serialized_profile.err)); | ||
} | ||
|
||
VALUE encoded_pprof = ruby_string_from_prof_vec_u8(serialized_profile.ok.buffer); | ||
VALUE encoded_pprof = ruby_string_from_vec_u8(serialized_profile.ok.buffer); | ||
Comment on lines
-290
to
+288
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This was a workaround for a header issue in 1.0.1, and it's been fixed. |
||
|
||
ddog_Timespec ddprof_start = serialized_profile.ok.start; | ||
ddog_Timespec ddprof_finish = serialized_profile.ok.end; | ||
|
||
// Clean up libdatadog object to avoid leaking in case ruby_time_from raises an exception | ||
ddog_prof_Profile_SerializeResult_drop(serialized_profile); | ||
ddog_prof_EncodedProfile_drop(&serialized_profile.ok); | ||
|
||
VALUE start = ruby_time_from(ddprof_start); | ||
VALUE finish = ruby_time_from(ddprof_finish); | ||
|
@@ -317,12 +314,16 @@ void record_sample(VALUE recorder_instance, ddog_prof_Sample sample) { | |
|
||
struct active_slot_pair active_slot = sampler_lock_active_profile(state); | ||
|
||
ddog_prof_Profile_add(active_slot.profile, sample); | ||
ddog_prof_Profile_AddResult result = ddog_prof_Profile_add(active_slot.profile, sample); | ||
|
||
sampler_unlock_active_profile(active_slot); | ||
|
||
if (result.tag == DDOG_PROF_PROFILE_ADD_RESULT_ERR) { | ||
rb_raise(rb_eArgError, "Failed to record sample: %"PRIsVALUE, get_error_details_and_drop(&result.err)); | ||
} | ||
} | ||
|
||
void record_endpoint(VALUE recorder_instance, ddog_CharSlice local_root_span_id, ddog_CharSlice endpoint) { | ||
void record_endpoint(VALUE recorder_instance, uint64_t local_root_span_id, ddog_CharSlice endpoint) { | ||
struct stack_recorder_state *state; | ||
TypedData_Get_Struct(recorder_instance, struct stack_recorder_state, &stack_recorder_typed_data, state); | ||
|
||
|
@@ -475,6 +476,7 @@ static void serializer_set_start_timestamp_for_next_profile(struct stack_recorde | |
} | ||
|
||
static VALUE _native_record_endpoint(DDTRACE_UNUSED VALUE _self, VALUE recorder_instance, VALUE local_root_span_id, VALUE endpoint) { | ||
record_endpoint(recorder_instance, char_slice_from_ruby_string(local_root_span_id), char_slice_from_ruby_string(endpoint)); | ||
ENFORCE_TYPE(local_root_span_id, T_FIXNUM); | ||
record_endpoint(recorder_instance, NUM2ULL(local_root_span_id), char_slice_from_ruby_string(endpoint)); | ||
return Qtrue; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
The else branch is not actually needed because there's nothing to drop when the
ddog_Vec_Tag_push
operation was successful.