Skip to content

Commit

Permalink
Introdue exception.left_scope, go back to allowing all kinds.
Browse files Browse the repository at this point in the history
  • Loading branch information
Oberon00 committed Aug 7, 2020
1 parent feeb86b commit 9947341
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
7 changes: 2 additions & 5 deletions specification/trace/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -510,11 +510,8 @@ MUST record an exception as an `Event` with the conventions outlined in the

Examples:

- `RecordException(exception: Exception)`
- `RecordException(type: String, message: String, stacktrace: String)`

Note that as per the semantic conventions, only exceptions leaving the scope of
a span unhandled must be recorded.
- `RecordException(exception: Exception, leftScope: boolean? = null)`
- `RecordException(type: String, message: String, stacktrace: String, leftScope: boolean?)`

### Span lifetime

Expand Down
7 changes: 6 additions & 1 deletion specification/trace/semantic_conventions/exceptions.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,17 @@ exceptions.

An unhandled exception that leaves the scope of a span
SHOULD be recorded as an `Event` on that span.
Other (handled, not leaving a span's scope) exceptions MUST NOT be recorded.
An exception is considered to leave the scope of a span if the span is ended
while the exception is still "in flight"
(special considerations may apply for Go, where exception semantic conventions are used for non-exceptions).

The name of the event MUST be `"exception"`.

Note that multiple events (on the same or different Spans)
might be logged for the same exception object instance.
E.g. one event might be logged in an instrumented exception constructor
and another event might be logged when an exception leaves the scope of a span.

## Attributes

The table below indicates which attributes should be added to the `Event` and
Expand All @@ -32,6 +36,7 @@ their types.
| 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. E.g. "java.net.ConnectException", "OSError" | One of `exception.type` or `exception.message` is required |
| exception.message | String | The exception message. E.g. `"Division by zero"`, `"Can't convert 'int' object to str implicitly"` | One of `exception.type` or `exception.message` is required |
| 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. E.g. `"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.left_scope | Bool | SHOULD be set to true if the exception event is recoded while observing the exception leaving the scope of the span. 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. | No |

### Stacktrace Representation

Expand Down

0 comments on commit 9947341

Please sign in to comment.