Skip to content

Commit

Permalink
[NO-TICKET] Upgrade to libdatadog 7
Browse files Browse the repository at this point in the history
**What does this PR do?**

This PR upgrades dd-trace-rb to use libdatadog 7.

There was a small breaking API change -- the rename of `ddog_Endpoint`
APIs to `ddog_prof_Endpoint`.

**Motivation:**

Make sure Ruby is up-to-date on libdatadog.

**Additional Notes:**

As far as Ruby is impacted, the main changes in libdatadog 7 are
a number of fixes to the crash tracker (getting us closer to merging
 #3384) as well as some potential memory improvements from
(DataDog/libdatadog#303).

I'm opening this as a draft PR as libdatadog 7 is not yet available on
rubygems.org, and I'll come back to re-trigger CI and mark this as
non-draft once it is.

**How to test the change?**

Our existing test coverage includes libdatadog testing, so a green CI
is good here :)
  • Loading branch information
ivoanjo committed Mar 27, 2024
1 parent c097f90 commit 53cffdc
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion ddtrace.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ Gem::Specification.new do |spec|

# Used by profiling (and possibly others in the future)
# When updating the version here, please also update the version in `native_extension_helpers.rb` (and yes we have a test for it)
spec.add_dependency 'libdatadog', '~> 6.0.0.2.0'
spec.add_dependency 'libdatadog', '~> 7.0.0.1.0'

# used for CI visibility product until the next major version
spec.add_dependency 'datadog-ci', '~> 0.8.1'
Expand Down
10 changes: 5 additions & 5 deletions ext/datadog_profiling_native_extension/http_transport.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ inline static ddog_ByteSlice byte_slice_from_ruby_string(VALUE string);
static VALUE _native_validate_exporter(VALUE self, VALUE exporter_configuration);
static ddog_prof_Exporter_NewResult create_exporter(VALUE exporter_configuration, VALUE tags_as_array);
static VALUE handle_exporter_failure(ddog_prof_Exporter_NewResult exporter_result);
static ddog_Endpoint endpoint_from(VALUE exporter_configuration);
static ddog_prof_Endpoint endpoint_from(VALUE exporter_configuration);
static ddog_Vec_Tag convert_tags(VALUE tags_as_array);
static void safely_log_failure_to_process_tag(ddog_Vec_Tag tags, VALUE err_details);
static VALUE _native_do_export(
Expand Down Expand Up @@ -94,7 +94,7 @@ static ddog_prof_Exporter_NewResult create_exporter(VALUE exporter_configuration

// This needs to be called BEFORE convert_tags since it can raise an exception and thus cause the ddog_Vec_Tag
// to be leaked.
ddog_Endpoint endpoint = endpoint_from(exporter_configuration);
ddog_prof_Endpoint endpoint = endpoint_from(exporter_configuration);

ddog_Vec_Tag tags = convert_tags(tags_as_array);

Expand All @@ -116,7 +116,7 @@ static VALUE handle_exporter_failure(ddog_prof_Exporter_NewResult exporter_resul
rb_ary_new_from_args(2, error_symbol, get_error_details_and_drop(&exporter_result.err));
}

static ddog_Endpoint endpoint_from(VALUE exporter_configuration) {
static ddog_prof_Endpoint endpoint_from(VALUE exporter_configuration) {
ENFORCE_TYPE(exporter_configuration, T_ARRAY);

ID working_mode = SYM2ID(rb_ary_entry(exporter_configuration, 0)); // SYM2ID verifies its input so we can do this safely
Expand All @@ -131,12 +131,12 @@ static ddog_Endpoint endpoint_from(VALUE exporter_configuration) {
ENFORCE_TYPE(site, T_STRING);
ENFORCE_TYPE(api_key, T_STRING);

return ddog_Endpoint_agentless(char_slice_from_ruby_string(site), char_slice_from_ruby_string(api_key));
return ddog_prof_Endpoint_agentless(char_slice_from_ruby_string(site), char_slice_from_ruby_string(api_key));
} else { // agent_id
VALUE base_url = rb_ary_entry(exporter_configuration, 1);
ENFORCE_TYPE(base_url, T_STRING);

return ddog_Endpoint_agent(char_slice_from_ruby_string(base_url));
return ddog_prof_Endpoint_agent(char_slice_from_ruby_string(base_url));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ module NativeExtensionHelpers
# The MJIT header was introduced on 2.6 and removed on 3.3; for other Rubies we rely on debase-ruby_core_source
CAN_USE_MJIT_HEADER = RUBY_VERSION.start_with?('2.6', '2.7', '3.0.', '3.1.', '3.2.')

LIBDATADOG_VERSION = '~> 6.0.0.2.0'
LIBDATADOG_VERSION = '~> 7.0.0.1.0'

def self.fail_install_if_missing_extension?
ENV[ENV_FAIL_INSTALL_IF_MISSING_EXTENSION].to_s.strip.downcase == 'true'
Expand Down

0 comments on commit 53cffdc

Please sign in to comment.