Skip to content

Latest commit

 

History

History
68 lines (51 loc) · 4.01 KB

File metadata and controls

68 lines (51 loc) · 4.01 KB

Semantic Conventions for Exceptions

This document defines semantic conventions for recording application exceptions.

Recording an Exception

An exception SHOULD be recorded as an Event on the span during which it occurred. The name of the event MUST be "exception".

Attributes

The table below indicates which attributes should be added to the Event and their types.

Attribute Type Description Example Required
exception.type 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. java.net.ConnectException
OSError
See below
exception.message string The exception message. Division by zero
Can't convert 'int' object to str implicitly
See below
exception.stacktrace 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. Exception in thread "main" java.lang.RuntimeException: Test exception\n at com.example.GenerateTrace.methodB(GenerateTrace.java:13)\n at com.example.GenerateTrace.methodA(GenerateTrace.java:9)\n at com.example.GenerateTrace.main(GenerateTrace.java:5) No
exception.escaped boolean SHOULD be set to true if the exception event is recorded at a point where it is known that the exception is escaping the scope of the span (e.g. if there is an exception active just before ending the span). [1] No

[1]: Note that an exception may still leave the scope of the span even if this was not set or set to false, if the event was recorded at an earlier time.

Additional attribute requirements: At least one of the following sets of attributes is required:

  • exception.type
  • exception.message

Stacktrace Representation

The table below, adapted from Google Cloud, includes possible representations of stacktraces in various languages. The table is not meant to be a recommendation for any particular language, although SIGs are free to adopt them if they see fit.

Language Format
C# the return value of Exception.ToString()
Go the return value of runtime.Stack
Java the contents of Throwable.printStackTrace()
Javascript the return value of error.stack as returned by V8
Python the return value of traceback.format_exc()
Ruby the return value of Exception.full_message

Backends can use the language specified methodology for generating a stacktrace combined with platform information from the telemetry sdk resource in order to extract more fine grained information from a stacktrace, if necessary.