From 994734168bd9ccf70dedf14d618772821c3989d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Neum=C3=BCller?= Date: Fri, 7 Aug 2020 16:18:31 +0200 Subject: [PATCH] Introdue exception.left_scope, go back to allowing all kinds. --- specification/trace/api.md | 7 ++----- specification/trace/semantic_conventions/exceptions.md | 7 ++++++- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/specification/trace/api.md b/specification/trace/api.md index 7f4b27cb2ea..7243fc73dba 100644 --- a/specification/trace/api.md +++ b/specification/trace/api.md @@ -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 diff --git a/specification/trace/semantic_conventions/exceptions.md b/specification/trace/semantic_conventions/exceptions.md index 385740c46fb..7006a982534 100644 --- a/specification/trace/semantic_conventions/exceptions.md +++ b/specification/trace/semantic_conventions/exceptions.md @@ -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 @@ -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