File tree Expand file tree Collapse file tree 1 file changed +11
-0
lines changed 
src/Instrumentation/Laravel/tests/Integration Expand file tree Collapse file tree 1 file changed +11
-0
lines changed Original file line number Diff line number Diff line change 44
55namespace  OpenTelemetry \Tests \Contrib \Instrumentation \Laravel \Integration ;
66
7+ use  Exception ;
78use  Illuminate \Routing \Router ;
89use  Illuminate \Support \Facades \DB ;
910use  Illuminate \Support \Facades \Http ;
@@ -106,6 +107,16 @@ public function test_route_span_name_if_not_found(): void
106107        $ this  ->assertSame ('GET ' , $ span ->getName ());
107108    }
108109
110+     public  function  test_records_exception_in_logs (): void 
111+     {
112+         $ this  ->router ()->get ('/exception ' , fn  () => throw  new  Exception ('Test exception ' ));
113+         $ this  ->call ('GET ' , '/exception ' );
114+         $ logRecord  = $ this  ->storage [0 ];
115+         $ this  ->assertEquals (Exception::class, $ logRecord ->getAttributes ()->get (TraceAttributes::EXCEPTION_TYPE ));
116+         $ this  ->assertEquals ('Test exception ' , $ logRecord ->getAttributes ()->get (TraceAttributes::EXCEPTION_MESSAGE ));
117+         $ this  ->assertNotNull ($ logRecord ->getAttributes ()->get (TraceAttributes::EXCEPTION_STACKTRACE ));
118+     }
119+ 
109120    private  function  router (): Router 
110121    {
111122        /** @psalm-suppress PossiblyNullReference */ 
    
 
   
 
     
   
   
          
     
  
    
     
 
    
      
     
 
     
    You can’t perform that action at this time.
  
 
    
  
     
    
      
        
     
 
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments