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, ).
We have a few cases of libraries using custom exception types as control flow signals, e.g.:
HueyControlFlowExceptionsGraphInterruptandGraphBubbleUp: LangchainIntegration reports GraphInterrupt / GraphBubbleUp as errors via on_tool_error #6384The
should_be_treated_as_error()function is currently used to determine whether a transaction or span is assigned theinternal_errororerrorstatus inSpan.__exit__()and inStreamedSpan.__exit__(), respectively. Asshould_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()andstart_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 calledcontrol_flow_exceptions.For example, in the AIOHTTP integration, the parameter would be set to
control_flow_exceptions=(AIOHttpHttpException, ).