@@ -216,16 +216,16 @@ def _observe_exception(self, exc_info=None, ignore=None, expected=None, status_c
216216
217217 # If no exception details provided, use current exception.
218218
219- if exc_info and None not in exc_info :
220- exc , value , tb = exc_info
221- else :
222- exc , value , tb = sys .exc_info ()
223-
224- # Has to be an error to be logged.
219+ # Pull from sys.exc_info if no exception is passed
220+ if not exc_info or None in exc_info :
221+ exc_info = sys .exc_info ()
225222
226- if exc is None or value is None or tb is None :
223+ # If no exception to report, exit
224+ if not exc_info or None in exc_info :
227225 return
228226
227+ exc , value , tb = exc_info
228+
229229 module , name , fullnames , message = parse_exc_info ((exc , value , tb ))
230230 fullname = fullnames [0 ]
231231
@@ -246,7 +246,8 @@ def _observe_exception(self, exc_info=None, ignore=None, expected=None, status_c
246246 # 1. function parameter override as bool
247247 # 2. function parameter callable
248248 # 3. callable on transaction
249- # 4. default rule matching from settings
249+ # 4. function parameter iterable of class names
250+ # 5. default rule matching from settings
250251
251252 should_ignore = None
252253 is_expected = None
@@ -270,9 +271,17 @@ def _observe_exception(self, exc_info=None, ignore=None, expected=None, status_c
270271 if should_ignore :
271272 return
272273
274+ # List of class names
275+ if should_ignore is None and ignore is not None and not callable (ignore ):
276+ # Do not set should_ignore to False
277+ # This should cascade into default settings rule matching
278+ for name in fullnames :
279+ if name in ignore :
280+ return
281+
273282 # Default rule matching
274283 if should_ignore is None :
275- should_ignore = should_ignore_error (( exc , value , tb ) , status_code = status_code )
284+ should_ignore = should_ignore_error (exc_info , status_code = status_code )
276285 if should_ignore :
277286 return
278287
@@ -285,13 +294,18 @@ def _observe_exception(self, exc_info=None, ignore=None, expected=None, status_c
285294 if is_expected is None and callable (expected ):
286295 is_expected = expected (exc , value , tb )
287296
288- # Callable on transaction
289- if is_expected is None and hasattr (transaction , '_expected_errors' ):
290- is_expected = transaction ._expected_errors (exc , value , tb )
297+
298+ # List of class names
299+ if is_expected is None and expected is not None and not callable (expected ):
300+ # Do not set is_expected to False
301+ # This should cascade into default settings rule matching
302+ for name in fullnames :
303+ if name in expected :
304+ is_expected = True
291305
292306 # Default rule matching
293307 if is_expected is None :
294- is_expected = is_expected_error (( exc , value , tb ) , status_code = status_code )
308+ is_expected = is_expected_error (exc_info , status_code = status_code )
295309
296310 # Record a supportability metric if error attributes are being
297311 # overiden.
@@ -343,49 +357,14 @@ def notice_error(self, error=None, attributes={}, expected=None, ignore=None, st
343357 settings , fullname , message , is_expected , custom_params , self .guid , tb )
344358
345359
346- def record_exception (self , exc_info = None ,
347- params = {}, ignore_errors = []):
360+ def record_exception (self , exc_info = None , params = {}, ignore_errors = []):
348361 # Deprecation Warning
349362 warnings .warn ((
350363 'The record_exception function is deprecated. Please use the '
351364 'new api named notice_error instead.'
352365 ), DeprecationWarning )
353366
354- transaction = self .transaction
355-
356- # Pull from sys.exc_info if no exception is passed
357- if not exc_info or None in exc_info :
358- exc_info = sys .exc_info ()
359-
360- # If no exception to report, exit
361- if not exc_info or None in exc_info :
362- return
363-
364- exc , value , tb = exc_info
365-
366- # Check ignore_errors callables
367- # We check these here separatly from the notice_error implementation
368- # to preserve previous functionality in precedence
369- should_ignore = None
370-
371- if hasattr (transaction , '_ignore_errors' ):
372- should_ignore = transaction ._ignore_errors (exc , value , tb )
373- if should_ignore :
374- return
375-
376- if callable (ignore_errors ):
377- should_ignore = ignore_errors (exc , value , tb )
378- if should_ignore :
379- return
380-
381- # Check ignore_errors iterables
382- if should_ignore is None and not callable (ignore_errors ):
383- _ , _ , fullnames , _ = parse_exc_info (exc_info )
384- for fullname in fullnames :
385- if fullname in ignore_errors :
386- return
387-
388- self .notice_error (error = exc_info , attributes = params , ignore = should_ignore )
367+ self .notice_error (error = exc_info , attributes = params , ignore = ignore_errors )
389368
390369 def _add_agent_attribute (self , key , value ):
391370 self .agent_attributes [key ] = value
@@ -590,19 +569,16 @@ def get_linking_metadata():
590569
591570def record_exception (exc = None , value = None , tb = None , params = {},
592571 ignore_errors = [], application = None ):
593- # Deprecated, but deprecation warning are handled by underlying function calls
594- if application is None :
595- trace = current_trace ()
596- if trace :
597- trace .record_exception ((exc , value , tb ), params ,
598- ignore_errors )
599- else :
600- if application .enabled :
601- application .record_exception (exc , value , tb , params ,
602- ignore_errors )
572+ # Deprecation Warning
573+ warnings .warn ((
574+ 'The record_exception function is deprecated. Please use the '
575+ 'new api named notice_error instead.'
576+ ), DeprecationWarning )
577+
578+ notice_error (error = (exc , value , tb ), attributes = params , ignore = ignore_errors , application = application )
603579
604580
605- def notice_error (error = None , attributes = {}, expected = None , ignore = None , application = None , status_code = None ):
581+ def notice_error (error = None , attributes = {}, expected = None , ignore = None , status_code = None , application = None ):
606582 if application is None :
607583 trace = current_trace ()
608584 if trace :
0 commit comments