Replace constraints with requirement levels on exceptions (#862)

Co-authored-by: Joao Grassi <5938087+joaopgrassi@users.noreply.github.com>
This commit is contained in:
Liudmila Molkova 2024-04-05 10:29:01 -07:00 committed by GitHub
parent a00f5ae243
commit 34edf1b967
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 24 additions and 23 deletions

4
.chloggen/862.yaml Normal file
View File

@ -0,0 +1,4 @@
change_type: enhancement
component: exception
note: Replace constraints with requirement levels on exceptions.
issues: [ 862 ]

View File

@ -38,14 +38,13 @@ The table below indicates which attributes should be added to the
<!-- semconv log-exception --> <!-- semconv log-exception -->
| Attribute | Type | Description | Examples | [Requirement Level](https://opentelemetry.io/docs/specs/semconv/general/attribute-requirement-level/) | Stability | | Attribute | Type | Description | Examples | [Requirement Level](https://opentelemetry.io/docs/specs/semconv/general/attribute-requirement-level/) | Stability |
|---|---|---|---|---|---| |---|---|---|---|---|---|
| [`exception.message`](../attributes-registry/exception.md) | string | The exception message. | `Division by zero`; `Can't convert 'int' object to str implicitly` | See below | ![Stable](https://img.shields.io/badge/-stable-lightgreen) | | [`exception.message`](../attributes-registry/exception.md) | string | The exception message. | `Division by zero`; `Can't convert 'int' object to str implicitly` | `Conditionally Required` [1] | ![Stable](https://img.shields.io/badge/-stable-lightgreen) |
| [`exception.type`](../attributes-registry/exception.md) | 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` | `Conditionally Required` [2] | ![Stable](https://img.shields.io/badge/-stable-lightgreen) |
| [`exception.stacktrace`](../attributes-registry/exception.md) | 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)` | `Recommended` | ![Stable](https://img.shields.io/badge/-stable-lightgreen) | | [`exception.stacktrace`](../attributes-registry/exception.md) | 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)` | `Recommended` | ![Stable](https://img.shields.io/badge/-stable-lightgreen) |
| [`exception.type`](../attributes-registry/exception.md) | 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 | ![Stable](https://img.shields.io/badge/-stable-lightgreen) |
**Additional attribute requirements:** At least one of the following sets of attributes is required: **[1]:** Required if `exception.type` is not set, recommended otherwise.
* [`exception.type`](../attributes-registry/exception.md) **[2]:** Required if `exception.message` is not set, recommended otherwise.
* [`exception.message`](../attributes-registry/exception.md)
<!-- endsemconv --> <!-- endsemconv -->
### Stacktrace Representation ### Stacktrace Representation

View File

@ -48,12 +48,16 @@ The event name MUST be `exception`.
| Attribute | Type | Description | Examples | [Requirement Level](https://opentelemetry.io/docs/specs/semconv/general/attribute-requirement-level/) | Stability | | Attribute | Type | Description | Examples | [Requirement Level](https://opentelemetry.io/docs/specs/semconv/general/attribute-requirement-level/) | Stability |
|---|---|---|---|---|---| |---|---|---|---|---|---|
| [`exception.escaped`](../attributes-registry/exception.md) | 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. [1] | | `Recommended` | ![Stable](https://img.shields.io/badge/-stable-lightgreen) | | [`exception.message`](../attributes-registry/exception.md) | string | The exception message. | `Division by zero`; `Can't convert 'int' object to str implicitly` | `Conditionally Required` [1] | ![Stable](https://img.shields.io/badge/-stable-lightgreen) |
| [`exception.message`](../attributes-registry/exception.md) | string | The exception message. | `Division by zero`; `Can't convert 'int' object to str implicitly` | See below | ![Stable](https://img.shields.io/badge/-stable-lightgreen) | | [`exception.type`](../attributes-registry/exception.md) | 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` | `Conditionally Required` [2] | ![Stable](https://img.shields.io/badge/-stable-lightgreen) |
| [`exception.escaped`](../attributes-registry/exception.md) | 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. [3] | | `Recommended` | ![Stable](https://img.shields.io/badge/-stable-lightgreen) |
| [`exception.stacktrace`](../attributes-registry/exception.md) | 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)` | `Recommended` | ![Stable](https://img.shields.io/badge/-stable-lightgreen) | | [`exception.stacktrace`](../attributes-registry/exception.md) | 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)` | `Recommended` | ![Stable](https://img.shields.io/badge/-stable-lightgreen) |
| [`exception.type`](../attributes-registry/exception.md) | 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 | ![Stable](https://img.shields.io/badge/-stable-lightgreen) |
**[1]:** An exception is considered to have escaped (or left) the scope of a span, **[1]:** Required if `exception.type` is not set, recommended otherwise.
**[2]:** Required if `exception.message` is not set, recommended otherwise.
**[3]:** An exception is considered to have escaped (or left) the scope of a span,
if that span is ended while the exception is still logically "in flight". if that span is ended while the exception is still logically "in flight".
This may be actually "in flight" in some languages (e.g. if the exception This may be actually "in flight" in some languages (e.g. if the exception
is passed to a Context manager's `__exit__` method in Python) but will is passed to a Context manager's `__exit__` method in Python) but will
@ -69,11 +73,6 @@ It follows that an exception may still escape the scope of the span
even if the `exception.escaped` attribute was not set or set to false, even if the `exception.escaped` attribute was not set or set to false,
since the event might have been recorded at a time where it was not since the event might have been recorded at a time where it was not
clear whether the exception will escape. clear whether the exception will escape.
**Additional attribute requirements:** At least one of the following sets of attributes is required:
* [`exception.type`](../attributes-registry/exception.md)
* [`exception.message`](../attributes-registry/exception.md)
<!-- endsemconv --> <!-- endsemconv -->
### Stacktrace Representation ### Stacktrace Representation

View File

@ -7,10 +7,9 @@ groups:
Records. Records.
attributes: attributes:
- ref: exception.type - ref: exception.type
requirement_level:
conditionally_required: Required if `exception.message` is not set, recommended otherwise.
- ref: exception.message - ref: exception.message
requirement_level:
conditionally_required: Required if `exception.type` is not set, recommended otherwise.
- ref: exception.stacktrace - ref: exception.stacktrace
constraints:
- any_of:
- "exception.type"
- "exception.message"

View File

@ -7,10 +7,10 @@ groups:
report a single exception associated with a span. report a single exception associated with a span.
attributes: attributes:
- ref: exception.type - ref: exception.type
requirement_level:
conditionally_required: Required if `exception.message` is not set, recommended otherwise.
- ref: exception.message - ref: exception.message
requirement_level:
conditionally_required: Required if `exception.type` is not set, recommended otherwise.
- ref: exception.stacktrace - ref: exception.stacktrace
- ref: exception.escaped - ref: exception.escaped
constraints:
- any_of:
- "exception.type"
- "exception.message"