Semantic Conventions for Exceptions
This document defines semantic conventions for recording exceptions on logs and events emitted through the Logger API.
Recording an Exception
Exceptions SHOULD be recorded as attributes on the LogRecord passed to the Logger emit operations. Exceptions MAY be recorded on “logs” or “events” depending on the context.
To encapsulate proper handling of exceptions API authors MAY provide a
RecordException method/extension, or similar helper mechanism on
LogRecord class/structure or wherever it makes the most sense depending on
the language runtime.
The table below indicates which attributes should be added to the LogRecord and their types.
|string||The exception message.||See below|
|string||A stacktrace as a string in the natural representation for the language runtime. The representation is to be determined and documented by each language SIG.||Recommended|
|string||The type of the exception (its fully-qualified class name, if applicable). The dynamic type of the exception should be preferred over the static type in languages that support it.||See below|
Additional attribute requirements: At least one of the following sets of attributes is required:
Same as Trace Semantic Conventions for Exceptions - Stacktrace Representation.