@@ -82,27 +82,23 @@ def log!(_event)
8282 end
8383 end
8484 end
85-
8685 context 'with NativeError' do
8786 before do
8887 skip unless defined? ( Datadog ::Profiling ::NativeError )
8988 end
90-
9189 it 'includes the telemetry-safe message in telemetry' do
9290 expect ( component ) . to receive ( :log! ) . with ( instance_of ( Datadog ::Core ::Telemetry ::Event ::Log ) ) do |event |
9391 expect ( event . payload ) . to include (
9492 logs : [ { message : 'Datadog::Profiling::NativeRuntimeError: (This is a safe profiler error)' , level : 'ERROR' , count : 1 ,
9593 stack_trace : a_string_including ( 'REDACTED' ) } ]
9694 )
9795 end
98-
9996 begin
10097 raise Datadog ::Profiling ::NativeRuntimeError . new ( 'This is a safe profiler error' , telemetry_message : 'This is a safe profiler error' )
10198 rescue => e
10299 component . report ( e , level : :error )
103100 end
104101 end
105-
106102 context 'with description' do
107103 it 'includes both description and telemetry message' do
108104 expect ( component ) . to receive ( :log! ) . with ( instance_of ( Datadog ::Core ::Telemetry ::Event ::Log ) ) do |event |
@@ -111,15 +107,13 @@ def log!(_event)
111107 stack_trace : a_string_including ( 'REDACTED' ) } ]
112108 )
113109 end
114-
115110 begin
116111 raise Datadog ::Profiling ::NativeRuntimeError . new ( 'Failed to initialize native extension' , telemetry_message : 'Failed to initialize native extension' )
117112 rescue => e
118113 component . report ( e , level : :error , description : 'Profiler failed to start' )
119114 end
120115 end
121116 end
122-
123117 context 'without telemetry message' do
124118 it 'omits the dynamic exception message from telemetry' do
125119 expect ( component ) . to receive ( :log! ) . with ( instance_of ( Datadog ::Core ::Telemetry ::Event ::Log ) ) do |event |
@@ -129,15 +123,13 @@ def log!(_event)
129123 )
130124 expect ( event . payload [ :logs ] . map { |log | log [ :message ] } ) . not_to include ( /Failed to initialize.*0x[0-9a-f]+/ )
131125 end
132-
133126 begin
134127 raise Datadog ::Profiling ::NativeRuntimeError , 'Failed to initialize string storage: Error at address 0xdeadbeef'
135128 rescue => e
136129 component . report ( e , level : :error )
137130 end
138131 end
139132 end
140-
141133 context 'with telemetry message and dynamic content' do
142134 it 'includes only the telemetry-safe message' do
143135 expect ( component ) . to receive ( :log! ) . with ( instance_of ( Datadog ::Core ::Telemetry ::Event ::Log ) ) do |event |
@@ -147,15 +139,13 @@ def log!(_event)
147139 )
148140 expect ( event . payload [ :logs ] . map { |log | log [ :message ] } ) . not_to include ( 'Dynamic info 0xabc123' )
149141 end
150-
151142 begin
152143 raise Datadog ::Profiling ::NativeRuntimeError . new ( 'Static format string' , 'Dynamic info 0xabc123' )
153144 rescue => e
154145 component . report ( e , level : :error )
155146 end
156147 end
157148 end
158-
159149 context 'with description and dynamic content' do
160150 it 'includes the description but not the dynamic exception message' do
161151 expect ( component ) . to receive ( :log! ) . with ( instance_of ( Datadog ::Core ::Telemetry ::Event ::Log ) ) do |event |
@@ -165,7 +155,6 @@ def log!(_event)
165155 )
166156 expect ( event . payload [ :logs ] . map { |log | log [ :message ] } ) . not_to include ( /memory address/ )
167157 end
168-
169158 begin
170159 raise Datadog ::Profiling ::NativeRuntimeError , 'Failed to serialize profile: Invalid memory address 0x12345678'
171160 rescue => e
0 commit comments