From f4fbd6eab46d5fd328d5070490d5426d16f60ea9 Mon Sep 17 00:00:00 2001 From: p-blue-26 Date: Tue, 17 Nov 2026 17:42:32 -0500 Subject: [PATCH] test(debugger): enable Ruby coordinated snapshot sampling from 2.49.0 Task: enable the snapshot correlation tests for Ruby, per the blueprints correlation project. dd-trace-rb#6118 shares one sampling decision per trace and shipped in 2.49.0. Turn on Test_Debugger_Coordinated_Sampling and Test_Debugger_Probe_Budgets::test_per_trace_budget from that release on the weblogs that run the debugger scenario (rails72, rails80, uds-rails), and add the /debugger/correlation and /debugger/correlation/loop/ endpoints to the shared Ruby weblog controller they exercise, mirroring the Go and .NET endpoints: the probed methods return 400ms apart, and the loop sleeps one second per iteration. Map the two loop lines for the Ruby line probes. The three probe-budget tests keep xfail because the Ruby weblog has no /debugger/budgets endpoint; declare them incomplete_test_app with that reason instead of the previous class-wide missing_feature, which the class gate now carries as the v2.49.0 version gate. --- manifests/ruby.yml | 18 ++++++++----- tests/debugger/utils.py | 4 +-- .../docker/ruby/rails72/config/routes.rb | 2 ++ .../docker/ruby/rails80/config/routes.rb | 2 ++ .../app/controllers/debugger_controller.rb | 27 +++++++++++++++++++ 5 files changed, 45 insertions(+), 8 deletions(-) diff --git a/manifests/ruby.yml b/manifests/ruby.yml index c12558deb22..c6231a4c5ed 100644 --- a/manifests/ruby.yml +++ b/manifests/ruby.yml @@ -2019,11 +2019,12 @@ manifest: tests/debugger/test_debugger_probe_budgets.py::Test_Debugger_Probe_Budgets: - weblog_declaration: "*": irrelevant - rails72: missing_feature (feature not implemented) - rails80: missing_feature (feature not implemented) - uds-rails: missing_feature (feature not implemented) - tests/debugger/test_debugger_probe_budgets.py::Test_Debugger_Probe_Budgets::test_log_line_budgets: missing_feature (Not yet implemented) - tests/debugger/test_debugger_probe_budgets.py::Test_Debugger_Probe_Budgets::test_per_trace_budget: missing_feature (per-trace snapshot budget of 1 not implemented) + rails72: v2.49.0 + rails80: v2.49.0 + uds-rails: v2.49.0 + tests/debugger/test_debugger_probe_budgets.py::Test_Debugger_Probe_Budgets::test_log_line_budgets: incomplete_test_app (weblog has no /debugger/budgets endpoint) + tests/debugger/test_debugger_probe_budgets.py::Test_Debugger_Probe_Budgets::test_log_line_capture_expression_budgets: incomplete_test_app (weblog has no /debugger/budgets endpoint) + tests/debugger/test_debugger_probe_budgets.py::Test_Debugger_Probe_Budgets::test_span_probe_expression_budgets: incomplete_test_app (weblog has no /debugger/budgets endpoint) tests/debugger/test_debugger_probe_snapshot.py::Test_Debugger_Line_Probe_Snaphots: - weblog_declaration: "*": irrelevant @@ -2094,7 +2095,12 @@ manifest: rails72: v2.47.0-dev rails80: v2.47.0-dev uds-rails: v2.47.0-dev - tests/debugger/test_debugger_snapshot_correlation.py::Test_Debugger_Coordinated_Sampling: missing_feature (no per-trace coordinated sampling; probabilistic per-trace rate not implemented) + tests/debugger/test_debugger_snapshot_correlation.py::Test_Debugger_Coordinated_Sampling: + - weblog_declaration: + "*": irrelevant + rails72: v2.49.0 + rails80: v2.49.0 + uds-rails: v2.49.0 tests/debugger/test_debugger_snapshot_correlation.py::Test_Debugger_Coordinated_Sampling_Line_Probe: irrelevant (Line-probe variant is only used by Node.js) tests/debugger/test_debugger_symdb.py::Test_Debugger_SymDb: - weblog_declaration: diff --git a/tests/debugger/utils.py b/tests/debugger/utils.py index d5255eb96d8..a3fc2b22ba8 100644 --- a/tests/debugger/utils.py +++ b/tests/debugger/utils.py @@ -261,8 +261,8 @@ def method_and_language_to_line_number(self, method: str, language: str) -> list "Correlation": {"nodejs": [178]}, "CorrelationMiddle": {"nodejs": [184]}, "CorrelationLeaf": {"nodejs": [188]}, - "CorrelationLoopBody": {"golang": [144], "nodejs": [194]}, - "CorrelationLoopSibling": {"golang": [147], "nodejs": [197]}, + "CorrelationLoopBody": {"golang": [144], "nodejs": [194], "ruby": [256]}, + "CorrelationLoopSibling": {"golang": [147], "nodejs": [197], "ruby": [259]}, } return definitions.get(method, {}).get(language, []) diff --git a/utils/build/docker/ruby/rails72/config/routes.rb b/utils/build/docker/ruby/rails72/config/routes.rb index 004b2c34b59..828780db044 100644 --- a/utils/build/docker/ruby/rails72/config/routes.rb +++ b/utils/build/docker/ruby/rails72/config/routes.rb @@ -77,6 +77,8 @@ def call(_env) %w(operators strings collections null exception).each do |sub| get "/debugger/expression/#{sub}" => "debugger#expression_#{sub}" end + get '/debugger/correlation' => 'debugger#correlation' + get '/debugger/correlation/loop/:loops' => 'debugger#correlation_loop' scope '/rasp' do get 'sqli' => 'rasp#sqli' diff --git a/utils/build/docker/ruby/rails80/config/routes.rb b/utils/build/docker/ruby/rails80/config/routes.rb index 8627e5bae07..d20be5bbde6 100644 --- a/utils/build/docker/ruby/rails80/config/routes.rb +++ b/utils/build/docker/ruby/rails80/config/routes.rb @@ -69,6 +69,8 @@ def call(_env) %w(operators strings collections null exception).each do |sub| get "/debugger/expression/#{sub}" => "debugger#expression_#{sub}" end + get '/debugger/correlation' => 'debugger#correlation' + get '/debugger/correlation/loop/:loops' => 'debugger#correlation_loop' scope '/rasp' do get 'sqli' => 'rasp#sqli' diff --git a/utils/build/docker/ruby/shared/rails/app/controllers/debugger_controller.rb b/utils/build/docker/ruby/shared/rails/app/controllers/debugger_controller.rb index b098faa57b2..94d9afb1777 100644 --- a/utils/build/docker/ruby/shared/rails/app/controllers/debugger_controller.rb +++ b/utils/build/docker/ruby/shared/rails/app/controllers/debugger_controller.rb @@ -232,4 +232,31 @@ def snapshot_limits longString = data[:longString] render inline: 'Capture limits probe' # must be line 233 end + + def correlation + result = correlation_middle + sleep 0.4 # space the probed call sites in time + render inline: "Correlation #{result}" + end + + def correlation_middle + result = correlation_leaf + sleep 0.4 # space the probed call sites in time + result + end + + def correlation_leaf + 3 + end + + def correlation_loop + loops = params[:loops].to_i + total = 0 + loops.times do |i| + total += i # correlation loop body line probe + sleep 1 + end + after_loop = total # correlation loop sibling line probe + render inline: "Loop #{after_loop}" + end end