File tree 1 file changed +9
-9
lines changed
opentelemetry-sdk/tests/logs
1 file changed +9
-9
lines changed Original file line number Diff line number Diff line change @@ -182,20 +182,20 @@ def test_log_record_exception(self):
182
182
183
183
def test_log_record_recursive_exception (self ):
184
184
"""Exception information will be included in attributes even though it is recursive"""
185
- processor , logger = set_up_test_logging (logging .ERROR )
185
+ with set_up_test_logging (logging .ERROR ) as ( processor , logger ):
186
186
187
- try :
188
- raise ZeroDivisionError (
189
- ZeroDivisionError (ZeroDivisionError ("division by zero" ))
190
- )
191
- except ZeroDivisionError :
192
- with self .assertLogs (level = logging .ERROR ):
193
- logger .exception ("Zero Division Error" )
187
+ try :
188
+ raise ZeroDivisionError (
189
+ ZeroDivisionError (ZeroDivisionError ("division by zero" ))
190
+ )
191
+ except ZeroDivisionError :
192
+ with self .assertLogs (level = logging .ERROR ):
193
+ logger .exception ("Zero Division Error" )
194
194
195
195
log_record = processor .get_log_record (0 )
196
196
197
197
self .assertIsNotNone (log_record )
198
- self .assertEqual ( log_record . body , "Zero Division Error" )
198
+ self .assertIn ( "Zero Division Error" , log_record . body )
199
199
self .assertEqual (
200
200
log_record .attributes [SpanAttributes .EXCEPTION_TYPE ],
201
201
ZeroDivisionError .__name__ ,
You can’t perform that action at this time.
0 commit comments