From 5f0ed879256bb2e72df8bca4e9d0dba735048505 Mon Sep 17 00:00:00 2001 From: Giovanni Liva Date: Tue, 15 Sep 2020 15:30:38 +0200 Subject: [PATCH] Add yaml semantic conventions for Exception (#927) --- semantic_conventions/trace/exception.yaml | 40 +++++++++++++++++++ .../trace/semantic_conventions/exceptions.md | 21 +++++++--- 2 files changed, 55 insertions(+), 6 deletions(-) create mode 100644 semantic_conventions/trace/exception.yaml diff --git a/semantic_conventions/trace/exception.yaml b/semantic_conventions/trace/exception.yaml new file mode 100644 index 000000000..612eaa040 --- /dev/null +++ b/semantic_conventions/trace/exception.yaml @@ -0,0 +1,40 @@ +groups: + - id: exception + prefix: exception + brief: > + This document defines the attributes used to + report a single exception associated with a span. + attributes: + - id: type + type: string + brief: > + 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. + examples: ["java.net.ConnectException","OSError"] + - id: message + type: string + brief: The exception message. + examples: ["Division by zero","Can't convert 'int' object to str implicitly"] + - id: stacktrace + type: string + brief: > + 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. + examples: '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)' + - id: escaped + type: boolean + brief: > + 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). + note: > + 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. + constraints: + - any_of: + - "exception.type" + - "exception.message" diff --git a/specification/trace/semantic_conventions/exceptions.md b/specification/trace/semantic_conventions/exceptions.md index 35cb1a808..7117b86bc 100644 --- a/specification/trace/semantic_conventions/exceptions.md +++ b/specification/trace/semantic_conventions/exceptions.md @@ -21,12 +21,21 @@ The name of the event MUST be `"exception"`. The table below indicates which attributes should be added to the `Event` and their types. -| Attribute name | Type | Notes and examples | 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. 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.escaped | Bool | 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). 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 | + +| 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