Skip to content

Commit 1fd9c35

Browse files
committed
Add in code attributes to exception event #1981
1 parent 062cd65 commit 1fd9c35

File tree

3 files changed

+50
-0
lines changed

3 files changed

+50
-0
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Use this changelog template to create an entry for release notes.
2+
#
3+
# If your change doesn't affect end users you should instead start
4+
# your pull request title with [chore] or use the "Skip Changelog" label.
5+
6+
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
7+
change_type: enhancement
8+
9+
# The name of the area of concern in the attributes-registry, (e.g. http, cloud, db)
10+
component: exception
11+
12+
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
13+
note: "Add code attributes (`code.function.name`, `code.file.path`, `code.line.number`, `code.column.number`) as opt-in attributes for the `event.exception` event."
14+
15+
# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists.
16+
# The values here must be integers.
17+
issues: [1981]
18+
19+
# (Optional) One or more lines of additional information to render under the primary note.
20+
# These lines will be padded with 2 spaces and then inserted directly into the document.
21+
# Use pipe (|) for multiline entries.
22+
subtext:

docs/exceptions/exceptions-spans.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,31 @@ This event describes a single exception.
3737
| [`exception.type`](/docs/registry/attributes/exception.md) | ![Stable](https://img.shields.io/badge/-stable-lightgreen) | `Conditionally Required` [2] | 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` |
3838
| [`exception.escaped`](/docs/registry/attributes/exception.md) | ![Deprecated](https://img.shields.io/badge/-deprecated-red)<br>It's no longer recommended to record exceptions that are handled and do not escape the scope of a span. | `Recommended` | boolean | Indicates that the exception is escaping the scope of the span. | |
3939
| [`exception.stacktrace`](/docs/registry/attributes/exception.md) | ![Stable](https://img.shields.io/badge/-stable-lightgreen) | `Recommended` | 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)` |
40+
| [`code.column.number`](/docs/registry/attributes/code.md) | ![Stable](https://img.shields.io/badge/-stable-lightgreen) | `Opt-In` | int | The column number in `code.file.path` best representing the operation. It SHOULD point within the code unit named in `code.function.name`. This attribute MUST NOT be used on the Profile signal since the data is already captured in 'message Line'. This constraint is imposed to prevent redundancy and maintain data integrity. | `16` |
41+
| [`code.file.path`](/docs/registry/attributes/code.md) | ![Stable](https://img.shields.io/badge/-stable-lightgreen) | `Opt-In` | string | The source code file name that identifies the code unit as uniquely as possible (preferably an absolute file path). This attribute MUST NOT be used on the Profile signal since the data is already captured in 'message Function'. This constraint is imposed to prevent redundancy and maintain data integrity. | `/usr/local/MyApplication/content_root/app/index.php` |
42+
| [`code.function.name`](/docs/registry/attributes/code.md) | ![Stable](https://img.shields.io/badge/-stable-lightgreen) | `Opt-In` | string | The method or function fully-qualified name without arguments. The value should fit the natural representation of the language runtime, which is also likely the same used within `code.stacktrace` attribute value. This attribute MUST NOT be used on the Profile signal since the data is already captured in 'message Function'. This constraint is imposed to prevent redundancy and maintain data integrity. [3] | `com.example.MyHttpService.serveRequest`; `GuzzleHttp\Client::transfer`; `fopen` |
43+
| [`code.line.number`](/docs/registry/attributes/code.md) | ![Stable](https://img.shields.io/badge/-stable-lightgreen) | `Opt-In` | int | The line number in `code.file.path` best representing the operation. It SHOULD point within the code unit named in `code.function.name`. This attribute MUST NOT be used on the Profile signal since the data is already captured in 'message Line'. This constraint is imposed to prevent redundancy and maintain data integrity. | `42` |
4044

4145
**[1] `exception.message`:** Required if `exception.type` is not set, recommended otherwise.
4246

4347
**[2] `exception.type`:** Required if `exception.message` is not set, recommended otherwise.
4448

49+
**[3] `code.function.name`:** Values and format depends on each language runtime, thus it is impossible to provide an exhaustive list of examples.
50+
The values are usually the same (or prefixes of) the ones found in native stack trace representation stored in
51+
`code.stacktrace` without information on arguments.
52+
53+
Examples:
54+
55+
* Java method: `com.example.MyHttpService.serveRequest`
56+
* Java anonymous class method: `com.mycompany.Main$1.myMethod`
57+
* Java lambda method: `com.mycompany.Main$$Lambda/0x0000748ae4149c00.myMethod`
58+
* PHP function: `GuzzleHttp\Client::transfer`
59+
* Go function: `github.com/my/repo/pkg.foo.func5`
60+
* Elixir: `OpenTelemetry.Ctx.new`
61+
* Erlang: `opentelemetry_ctx:new`
62+
* Rust: `playground::my_module::my_cool_func`
63+
* C function: `fopen`
64+
4565
<!-- prettier-ignore-end -->
4666
<!-- END AUTOGENERATED TEXT -->
4767
<!-- endsemconv -->

model/exceptions/events.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,11 @@ groups:
1414
conditionally_required: Required if `exception.type` is not set, recommended otherwise.
1515
- ref: exception.stacktrace
1616
- ref: exception.escaped
17+
- ref: code.function.name
18+
requirement_level: opt_in
19+
- ref: code.file.path
20+
requirement_level: opt_in
21+
- ref: code.line.number
22+
requirement_level: opt_in
23+
- ref: code.column.number
24+
requirement_level: opt_in

0 commit comments

Comments
 (0)