Skip to content

Handle control flow exceptions when assigning span status #6408

@alexander-alderman-webb

Description

We have a few cases of libraries using custom exception types as control flow signals, e.g.:

The should_be_treated_as_error() function is currently used to determine whether a transaction or span is assigned the internal_error or error status in Span.__exit__() and in StreamedSpan.__exit__(), respectively. As should_be_treated_as_error() currently holds an ever-expanding number of special cases, code is added that does not apply in the majority of cases (dead code if the relevant integrations did not create the span).

Proposal

Add a parameter to Span.__init__(), start_span(), start_transaction() and start_child() (and equivalent span streaming APIs) that accepts a set or tuple of control flow exceptions. Special case against the exceptions in the set on __exit__(). The parameter can be called control_flow_exceptions.

For example, in the AIOHTTP integration, the parameter would be set to control_flow_exceptions=(AIOHttpHttpException, ).

Metadata

Metadata

Labels

No labels
No labels
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions