feat: add record_exception option for in_span#1911
Conversation
| rescue Exception => e # rubocop:disable Lint/RescueException | ||
| span&.record_exception(e) | ||
| span&.record_exception(e) if record_exception | ||
| span&.status = Status.error("Unhandled exception of type: #{e.class}") |
There was a problem hiding this comment.
I find that Unhandled might be misleading here. Maybe just Exception of type:?
There was a problem hiding this comment.
Unhandled was included in the message to indicate that the exception was unhandled at the time the span was finished, based on the language in the spec:
An exception SHOULD be recorded as an
Eventon the span during which it occurred if and only if it remains unhandled when the span ends and causes the span status to be set to ERROR.
It may be handled later, but it was not handled within the lifetime of the span.
The spec recommends:
When the status is set to
Errorby Instrumentation Libraries, theDescriptionSHOULD be documented and predictable.
Sadly, we're violating this other recommendation, but I think changing the description would be more problematic at this point:
It's NOT RECOMMENDED to duplicate status code or
error.typein span status description.
Non breaking change, default behaviour is preserved. Allows for the
in_spanconvenience method to be configured to not capture exception events. Maintains recording of the span status as is.Related context: open-telemetry/opentelemetry-ruby-contrib#1653