@@ -368,7 +368,6 @@ defmodule Sentry.LoggerBackendTest do
368368 Logger . configure_backend ( Sentry.LoggerBackend , level: :error , capture_log_messages: false )
369369 end
370370
371- # TODO: update for Elixir 1.10.4 to not manually set :callers and replace with Task
372371 test "sentry metadata is retrieved from callers" do
373372 Logger . configure_backend ( Sentry.LoggerBackend , capture_log_messages: true )
374373 bypass = Bypass . open ( )
@@ -379,18 +378,16 @@ defmodule Sentry.LoggerBackendTest do
379378 { :ok , body , conn } = Plug.Conn . read_body ( conn )
380379 json = Jason . decode! ( body )
381380 assert json [ "user" ] [ "user_id" ] == 3
382- assert json [ "message" ] == "error "
381+ assert json [ "message" ] == "(RuntimeError oops) "
383382 send ( pid , "API called" )
384383 Plug.Conn . resp ( conn , 200 , ~s< {"id": "340"}> )
385384 end )
386385
387386 capture_log ( fn ->
388387 Sentry.Context . set_user_context ( % { user_id: 3 } )
389- parent = self ( )
390388
391- Task . start ( fn ->
392- Logger . error ( "error" , callers: [ parent ] )
393- end )
389+ { :ok , task } = Task . start_link ( __MODULE__ , :task , [ pid ] )
390+ send ( task , :go )
394391
395392 assert_receive ( "API called" )
396393 end )
@@ -417,4 +414,17 @@ defmodule Sentry.LoggerBackendTest do
417414 assert_receive ( "API called" )
418415 end )
419416 end
417+
418+ def task ( parent , fun \\ fn -> raise "oops" end ) do
419+ mon = Process . monitor ( parent )
420+ Process . unlink ( parent )
421+
422+ receive do
423+ :go ->
424+ fun . ( )
425+
426+ { :DOWN , ^ mon , _ , _ , _ } ->
427+ exit ( :shutdown )
428+ end
429+ end
420430end
0 commit comments