@@ -74,6 +74,11 @@ defmodule OpenTelemetryDecoratorTest do
74
74
exit ( exit_args )
75
75
end
76
76
77
+ @ decorate with_span ( "Example.with_throw" )
78
+ def with_throw ( throw_args ) do
79
+ throw ( throw_args )
80
+ end
81
+
77
82
@ decorate with_span ( "Example.with_error" )
78
83
def with_error , do: Attributes . set ( :error , "ruh roh!" )
79
84
@@ -230,15 +235,15 @@ defmodule OpenTelemetryDecoratorTest do
230
235
end
231
236
end
232
237
233
- test "catches exists , sets errors, and re-throws" do
238
+ test "catches exits , sets errors, and re-throws" do
234
239
try do
235
- Example . with_exit ( :bad_times )
240
+ Example . with_exit ( % { bad: :times } )
236
241
flunk ( "Should have re-raised the exception" )
237
242
catch
238
- :exit , :bad_times ->
243
+ :exit , % { bad: :times } ->
239
244
span = assert_span ( "Example.with_exit" )
240
245
assert span . status . code == :error
241
- assert span . status . message == "exited: bad_times "
246
+ assert span . status . message == "exited: %{bad: :times} "
242
247
end
243
248
end
244
249
@@ -276,9 +281,25 @@ defmodule OpenTelemetryDecoratorTest do
276
281
end
277
282
278
283
test "shutdowns with a reason add exit and shutdown_reason attributes" do
279
- Example . with_exit ( { :shutdown , : chillin} )
284
+ Example . with_exit ( { :shutdown , % { just: : chillin} } )
280
285
span = assert_span ( "Example.with_exit" )
281
- assert span . attributes == % { "app.exit" => :shutdown , "app.shutdown_reason" => :chillin }
286
+
287
+ assert span . attributes == % {
288
+ "app.exit" => :shutdown ,
289
+ "app.shutdown_reason" => "%{just: :chillin}"
290
+ }
291
+ end
292
+
293
+ test "catches throws, sets errors, and re-throws" do
294
+ try do
295
+ Example . with_throw ( % { catch: :this } )
296
+ flunk ( "Should have re-raised the exception" )
297
+ catch
298
+ :throw , % { catch: :this } ->
299
+ span = assert_span ( "Example.with_throw" )
300
+ assert span . status . code == :error
301
+ assert span . status . message == "uncaught: %{catch: :this}"
302
+ end
282
303
end
283
304
284
305
test "adds included input params on exception" do
0 commit comments