Skip to content

Commit 47cf97a

Browse files
committed
Gate behind flag
1 parent 05f9f4b commit 47cf97a

File tree

4 files changed

+22
-1
lines changed

4 files changed

+22
-1
lines changed

lib/datadog/core/configuration/supported_configurations.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ module Configuration
3232
"DD_APPSEC_TRACE_RATE_LIMIT" => {version: ["A"]},
3333
"DD_APPSEC_WAF_DEBUG" => {version: ["A"]},
3434
"DD_APPSEC_WAF_TIMEOUT" => {version: ["A"]},
35+
"DD_CRASHTRACKER_EMIT_RUNTIME_STACKS" => {version: ["A"]},
3536
"DD_CRASHTRACKING_ENABLED" => {version: ["A"]},
3637
"DD_DATA_STREAMS_ENABLED" => {version: ["A"]},
3738
"DD_DBM_PROPAGATION_MODE" => {version: ["A"]},

lib/datadog/core/crashtracking/component.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,9 @@ def start
5757
Utils::AtForkMonkeyPatch.apply!
5858

5959
start_or_update_on_fork(action: :start, tags: tags)
60-
register_runtime_stack_callback
60+
if DATADOG_ENV['DD_CRASHTRACKER_EMIT_RUNTIME_STACKS'] == 'true'
61+
register_runtime_stack_callback
62+
end
6163

6264
ONLY_ONCE.run do
6365
Utils::AtForkMonkeyPatch.at_fork(:child) do

spec/datadog/core/crashtracking/component_spec.rb

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,21 @@
11
require 'spec_helper'
22
require 'datadog/core/crashtracking/component'
3+
require 'datadog/runtime_stacks'
34

45
require 'webrick'
56
require 'fiddle'
67

78
RSpec.describe Datadog::Core::Crashtracking::Component, skip: !LibdatadogHelpers.supported? do
89
let(:logger) { Logger.new($stdout) }
910

11+
shared_context 'runtime stack emission enabled' do
12+
around do |example|
13+
ClimateControl.modify('DD_CRASHTRACKER_EMIT_RUNTIME_STACKS' => 'true') do
14+
example.run
15+
end
16+
end
17+
end
18+
1019
describe '.build' do
1120
let(:settings) { Datadog::Core::Configuration::Settings.new }
1221
let(:agent_settings) do
@@ -100,6 +109,7 @@
100109

101110
context 'instance methods' do
102111
describe '#start' do
112+
include_context 'runtime stack emission enabled'
103113
context 'when _native_start_or_update_on_fork raises an exception' do
104114
it 'logs the exception' do
105115
crashtracker = build_crashtracker(logger: logger)
@@ -343,6 +353,8 @@
343353
end
344354

345355
describe 'Ruby and C method runtime stack capture' do
356+
include_context 'runtime stack emission enabled'
357+
346358
let(:runtime_stack) { crash_report_experimental[:runtime_stack] }
347359

348360
it 'captures both Ruby and C method frames in mixed stacks' do
@@ -392,6 +404,7 @@ def ruby_method_with_c_calls
392404
)
393405
)
394406

407+
# Sanity check some frames
395408
expect(frames).to include(
396409
hash_including(
397410
function: 'ruby_method_with_c_calls'
@@ -410,6 +423,8 @@ def ruby_method_with_c_calls
410423
end
411424

412425
describe '#runtime_callback_registered?' do
426+
include_context 'runtime stack emission enabled'
427+
413428
it 'returns true when callback is registered' do
414429
crashtracker = build_crashtracker(logger: logger)
415430

supported-configurations.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,9 @@
7676
"DD_APPSEC_WAF_TIMEOUT": {
7777
"version": ["A"]
7878
},
79+
"DD_CRASHTRACKER_EMIT_RUNTIME_STACKS": {
80+
"version": ["A"]
81+
},
7982
"DD_CRASHTRACKING_ENABLED": {
8083
"version": ["A"]
8184
},

0 commit comments

Comments
 (0)