11require 'spec_helper'
22require 'datadog/core/crashtracking/component'
3+ require 'datadog/runtime_stacks'
34
45require 'webrick'
56require 'fiddle'
67
78RSpec . 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
1322 instance_double ( Datadog ::Core ::Configuration ::AgentSettings )
1423 end
15- let ( :tags ) { { 'tag1' => 'value1' } }
24+ let ( :tags ) { { 'tag1' => 'value1' } }
1625 let ( :agent_base_url ) { 'agent_base_url' }
1726 let ( :ld_library_path ) { 'ld_library_path' }
1827 let ( :path_to_crashtracking_receiver_binary ) { 'path_to_crashtracking_receiver_binary' }
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 )
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
0 commit comments