Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions lib/datadog/tracing/configuration/settings.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

require_relative "../../tracing/configuration/ext"
require_relative "../../core/environment/variable_helpers"
require_relative "../../ruby_version"
require_relative "../contrib/status_range_matcher"
require_relative "../contrib/status_range_env_parser"
require_relative "http"
Expand Down Expand Up @@ -496,11 +497,11 @@ def self.extended(base)
#
# This option is recommended for internal use only.
#
# @default `false`
# @default `true` on CRuby 4.0.0 and later, otherwise `false`
# @return [Boolean]
option :native_transport do |o|
o.env Configuration::Ext::ENV_EXPERIMENTAL_NATIVE_TRANSPORT_ENABLED
o.default false
o.default { RUBY_ENGINE == "ruby" && RubyVersion.is?(">= 4.0.0") }
o.type :bool
end

Expand Down
5 changes: 3 additions & 2 deletions spec/datadog/core/crashtracking/component_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -382,8 +382,9 @@ def method_that_raises
raise StandardError, "Test Ruby unhandled exception"
end

# Errors intake sends 2 messages, telemetry sends 2 messages
expect(messages.length).to eq(4)
paths = messages.select { |message| message.request_method == "POST" }.map(&:path)
expect(paths.count("/evp_proxy/v4/api/v2/errorsintake")).to eq(2)
expect(paths.count("/telemetry/proxy/api/v2/apmtelemetry")).to eq(2)
end
end

Expand Down
40 changes: 30 additions & 10 deletions spec/datadog/tracing/configuration/settings_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -654,17 +654,37 @@ def propagation_style_inject
describe "#native_transport" do
subject(:native_transport) { settings.tracing.native_transport }

it_behaves_like "a binary setting with",
env_variable: "DD_EXPERIMENTAL_NATIVE_TRANSPORT_ENABLED",
default: false
end
[
["ruby", "3.4.6", false],
["ruby", "4.0.0", true],
["ruby", "4.0.5", true],
["ruby", "4.0.10", true],
["ruby", "4.1.0", true],
["ruby", "5.0.0", true],
["jruby", "4.0.0", false],
["truffleruby", "4.1.0", false],
].each do |engine, version, default|
context "on #{engine} #{version}" do
before do
stub_const("RUBY_ENGINE", engine)
stub_const("Datadog::RubyVersion::CURRENT_RUBY_VERSION", Gem::Version.new(version))
end

describe "#native_transport=" do
it "changes the #native_transport setting" do
expect { settings.tracing.native_transport = true }
.to change { settings.tracing.native_transport }
.from(false)
.to(true)
it_behaves_like "a binary setting with",
env_variable: "DD_EXPERIMENTAL_NATIVE_TRANSPORT_ENABLED",
default: default

[true, false].each do |value|
context "when explicitly configured to #{value}" do
let(:envs) { {"DD_EXPERIMENTAL_NATIVE_TRANSPORT_ENABLED" => (!value).to_s} }

it "overrides the environment setting" do
settings.tracing.native_transport = value
is_expected.to be value
end
end
end
end
end
end

Expand Down
33 changes: 31 additions & 2 deletions spec/datadog/tracing/transport/native/configuration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,11 @@ def build_writer
end
end

context "when native_transport is not explicitly configured" do
context "outside the rollout version without an explicit setting" do
let(:settings) { Datadog::Core::Configuration::Settings.new }

before { stub_const("Datadog::RubyVersion::CURRENT_RUBY_VERSION", Gem::Version.new("3.4.6")) }

around do |example|
ClimateControl.modify("DD_EXPERIMENTAL_NATIVE_TRANSPORT_ENABLED" => nil) { example.run }
end
Expand Down Expand Up @@ -123,6 +125,32 @@ def build_writer
end
end

context "on CRuby 4.0.0 without an explicit setting" do
let(:settings) { Datadog::Core::Configuration::Settings.new }

around do |example|
ClimateControl.modify("DD_EXPERIMENTAL_NATIVE_TRANSPORT_ENABLED" => nil) { example.run }
end

before do
stub_const("RUBY_ENGINE", "ruby")
stub_const("Datadog::RubyVersion::CURRENT_RUBY_VERSION", Gem::Version.new("4.0.0"))
end

it "selects the native transport by default" do
expect(build_writer.transport).to be_a(Datadog::Tracing::Transport::Native::Transport)
end

context "when the native extension is unavailable" do
before { allow(Datadog::Tracing::Transport::Native).to receive(:supported?).and_return(false) }

it "falls back to the Ruby HTTP transport" do
expect(logger).to receive(:warn).with(/not available/)
expect(build_writer.transport).to be_a(Datadog::Tracing::Transport::Traces::Transport)
end
end
end

context "when native_transport is true but native extension is unavailable" do
let(:native_transport_enabled) { true }

Expand All @@ -141,7 +169,8 @@ def build_writer
end

describe "settings" do
it "has native_transport defaulting to false" do
it "defaults native_transport to false outside the rollout version" do
stub_const("Datadog::RubyVersion::CURRENT_RUBY_VERSION", Gem::Version.new("3.4.6"))
settings = Datadog::Core::Configuration::Settings.new
expect(settings.tracing.native_transport).to be false
end
Expand Down
1 change: 1 addition & 0 deletions supported-configurations.json
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,7 @@
],
"DD_EXPERIMENTAL_NATIVE_TRANSPORT_ENABLED": [
{
"__comment": "Default is true on CRuby 4.0.0 and later",
"version": "A",
"type": "boolean",
"default": "false"
Expand Down
6 changes: 6 additions & 0 deletions unreleased/20261005150145.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"type": "Changed",
"product": "Core",
"pull_request": "https://github.com/DataDog/dd-trace-rb/pull/6419",
"message": "Begin the progressive rollout of the native trace exporter, enabling it by default on CRuby 4.0.0 and later."
}
Loading