Skip to content

Commit cb11bb9

Browse files
SylvainJugekamphauslmolkovatrask
authored
clarify code function name (#1944)
Co-authored-by: Christophe Kamphaus <christophe.kamphaus@gmail.com> Co-authored-by: Liudmila Molkova <limolkova@microsoft.com> Co-authored-by: Trask Stalnaker <trask.stalnaker@gmail.com>
1 parent 7170b2d commit cb11bb9

File tree

5 files changed

+73
-15
lines changed

5 files changed

+73
-15
lines changed

.chloggen/1646.yaml

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
change_type: breaking
2+
component: code
3+
note: "`code.function.name` value should contain the fully qualified function name, `code.namespace` is now deprecated"
4+
issues: [1677]
5+
subtext:

docs/attributes-registry/code.md

+19-3
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,34 @@ These attributes provide context about source code
1414
|---|---|---|---|---|
1515
| <a id="code-column-number" href="#code-column-number">`code.column.number`</a> | int | The column number in `code.file.path` best representing the operation. It SHOULD point within the code unit named in `code.function.name`. | `16` | ![Development](https://img.shields.io/badge/-development-blue) |
1616
| <a id="code-file-path" href="#code-file-path">`code.file.path`</a> | string | The source code file name that identifies the code unit as uniquely as possible (preferably an absolute file path). | `/usr/local/MyApplication/content_root/app/index.php` | ![Development](https://img.shields.io/badge/-development-blue) |
17-
| <a id="code-function-name" href="#code-function-name">`code.function.name`</a> | string | The method or function name, or equivalent (usually rightmost part of the code unit's name). | `serveRequest` | ![Development](https://img.shields.io/badge/-development-blue) |
17+
| <a id="code-function-name" href="#code-function-name">`code.function.name`</a> | 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. [1] | `com.example.MyHttpService.serveRequest`; `GuzzleHttp\Client::transfer`; `fopen` | ![Development](https://img.shields.io/badge/-development-blue) |
1818
| <a id="code-line-number" href="#code-line-number">`code.line.number`</a> | int | The line number in `code.file.path` best representing the operation. It SHOULD point within the code unit named in `code.function.name`. | `42` | ![Development](https://img.shields.io/badge/-development-blue) |
19-
| <a id="code-namespace" href="#code-namespace">`code.namespace`</a> | string | The "namespace" within which `code.function.name` is defined. Usually the qualified class or module name, such that `code.namespace` + some separator + `code.function.name` form a unique identifier for the code unit. | `com.example.MyHttpService` | ![Development](https://img.shields.io/badge/-development-blue) |
2019
| <a id="code-stacktrace" href="#code-stacktrace">`code.stacktrace`</a> | 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. | `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)` | ![Development](https://img.shields.io/badge/-development-blue) |
2120

21+
**[1] `code.function.name`:** Values and format depends on each language runtime, thus it is impossible to provide an exhaustive list of examples.
22+
The values are usually the same (or prefixes of) the ones found in native stack trace representation stored in
23+
`code.stacktrace` without information on arguments.
24+
25+
Examples:
26+
27+
* Java method: `com.example.MyHttpService.serveRequest`
28+
* Java anonymous class method: `com.mycompany.Main$1.myMethod`
29+
* Java lambda method: `com.mycompany.Main$$Lambda/0x0000748ae4149c00.myMethod`
30+
* PHP function: `GuzzleHttp\Client::transfer
31+
* Go function: `github.com/my/repo/pkg.foo.func5`
32+
* Elixir: `OpenTelemetry.Ctx.new`
33+
* Erlang: `opentelemetry_ctx:new`
34+
* Rust: `playground::my_module::my_cool_func`
35+
* C function: `fopen`
36+
2237
## Deprecated Code Attributes
2338

2439
These deprecated attributes provide context about source code
2540

2641
| Attribute | Type | Description | Examples | Stability |
2742
|---|---|---|---|---|
2843
| <a id="code-column" href="#code-column">`code.column`</a> | int | Deprecated, use `code.column.number` | `16` | ![Deprecated](https://img.shields.io/badge/-deprecated-red)<br>Replaced by `code.column.number` |
29-
| <a id="code-filepath" href="#code-filepath">`code.filepath`</a> | string | Deprecated, use `code.file.path` instead | `/usr/local/MyApplication/content_root/app/index.php` | ![Development](https://img.shields.io/badge/-development-blue) |
44+
| <a id="code-filepath" href="#code-filepath">`code.filepath`</a> | string | Deprecated, use `code.file.path` instead | `/usr/local/MyApplication/content_root/app/index.php` | ![Deprecated](https://img.shields.io/badge/-deprecated-red)<br>Replaced by `code.file.path` |
3045
| <a id="code-function" href="#code-function">`code.function`</a> | string | Deprecated, use `code.function.name` instead | `serveRequest` | ![Deprecated](https://img.shields.io/badge/-deprecated-red)<br>Replaced by `code.function.name` |
3146
| <a id="code-lineno" href="#code-lineno">`code.lineno`</a> | int | Deprecated, use `code.line.number` instead | `42` | ![Deprecated](https://img.shields.io/badge/-deprecated-red)<br>Replaced by `code.line.number` |
47+
| <a id="code-namespace" href="#code-namespace">`code.namespace`</a> | string | Deprecated, namespace is now included into `code.function.name` | `com.example.MyHttpService` | ![Deprecated](https://img.shields.io/badge/-deprecated-red)<br>Value should be included in `code.function.name` which is expected to be a fully-qualified name. |

docs/general/attributes.md

+19-3
Original file line numberDiff line numberDiff line change
@@ -431,12 +431,28 @@ about the span.
431431
| Attribute | Type | Description | Examples | [Requirement Level](https://opentelemetry.io/docs/specs/semconv/general/attribute-requirement-level/) | Stability |
432432
|---|---|---|---|---|---|
433433
| [`code.column.number`](/docs/attributes-registry/code.md) | int | The column number in `code.file.path` best representing the operation. It SHOULD point within the code unit named in `code.function.name`. | `16` | `Recommended` | ![Development](https://img.shields.io/badge/-development-blue) |
434-
| [`code.filepath`](/docs/attributes-registry/code.md) | string | Deprecated, use `code.file.path` instead | `/usr/local/MyApplication/content_root/app/index.php` | `Recommended` | ![Development](https://img.shields.io/badge/-development-blue) |
435-
| [`code.function.name`](/docs/attributes-registry/code.md) | string | The method or function name, or equivalent (usually rightmost part of the code unit's name). | `serveRequest` | `Recommended` | ![Development](https://img.shields.io/badge/-development-blue) |
434+
| [`code.filepath`](/docs/attributes-registry/code.md) | string | Deprecated, use `code.file.path` instead | `/usr/local/MyApplication/content_root/app/index.php` | `Recommended` | ![Deprecated](https://img.shields.io/badge/-deprecated-red)<br>Replaced by `code.file.path` |
435+
| [`code.function.name`](/docs/attributes-registry/code.md) | 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. [1] | `com.example.MyHttpService.serveRequest`; `GuzzleHttp\Client::transfer`; `fopen` | `Recommended` | ![Development](https://img.shields.io/badge/-development-blue) |
436436
| [`code.line.number`](/docs/attributes-registry/code.md) | int | The line number in `code.file.path` best representing the operation. It SHOULD point within the code unit named in `code.function.name`. | `42` | `Recommended` | ![Development](https://img.shields.io/badge/-development-blue) |
437-
| [`code.namespace`](/docs/attributes-registry/code.md) | string | The "namespace" within which `code.function.name` is defined. Usually the qualified class or module name, such that `code.namespace` + some separator + `code.function.name` form a unique identifier for the code unit. | `com.example.MyHttpService` | `Recommended` | ![Development](https://img.shields.io/badge/-development-blue) |
437+
| [`code.namespace`](/docs/attributes-registry/code.md) | string | Deprecated, namespace is now included into `code.function.name` | `com.example.MyHttpService` | `Recommended` | ![Deprecated](https://img.shields.io/badge/-deprecated-red)<br>Value should be included in `code.function.name` which is expected to be a fully-qualified name. |
438438
| [`code.stacktrace`](/docs/attributes-registry/code.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. | `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)` | `Opt-In` | ![Development](https://img.shields.io/badge/-development-blue) |
439439

440+
**[1] `code.function.name`:** Values and format depends on each language runtime, thus it is impossible to provide an exhaustive list of examples.
441+
The values are usually the same (or prefixes of) the ones found in native stack trace representation stored in
442+
`code.stacktrace` without information on arguments.
443+
444+
Examples:
445+
446+
* Java method: `com.example.MyHttpService.serveRequest`
447+
* Java anonymous class method: `com.mycompany.Main$1.myMethod`
448+
* Java lambda method: `com.mycompany.Main$$Lambda/0x0000748ae4149c00.myMethod`
449+
* PHP function: `GuzzleHttp\Client::transfer
450+
* Go function: `github.com/my/repo/pkg.foo.func5`
451+
* Elixir: `OpenTelemetry.Ctx.new`
452+
* Erlang: `opentelemetry_ctx:new`
453+
* Rust: `playground::my_module::my_cool_func`
454+
* C function: `fopen`
455+
440456
<!-- markdownlint-restore -->
441457
<!-- prettier-ignore-end -->
442458
<!-- END AUTOGENERATED TEXT -->

model/code/registry-deprecated.yaml

+8
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ groups:
1515
- id: code.filepath
1616
type: string
1717
stability: development
18+
deprecated: Replaced by `code.file.path`
1819
brief: >
1920
Deprecated, use `code.file.path` instead
2021
examples: /usr/local/MyApplication/content_root/app/index.php
@@ -32,3 +33,10 @@ groups:
3233
brief: >
3334
Deprecated, use `code.column.number`
3435
examples: 16
36+
- id: code.namespace
37+
type: string
38+
stability: development
39+
deprecated: Value should be included in `code.function.name` which is expected to be a fully-qualified name.
40+
brief: >
41+
Deprecated, namespace is now included into `code.function.name`
42+
examples: com.example.MyHttpService

model/code/registry.yaml

+22-9
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,28 @@ groups:
99
type: string
1010
stability: development
1111
brief: >
12-
The method or function name, or equivalent (usually rightmost part of the code unit's name).
13-
examples: serveRequest
14-
- id: code.namespace
15-
type: string
16-
stability: development
17-
brief: >
18-
The "namespace" within which `code.function.name` is defined. Usually the qualified class or module name,
19-
such that `code.namespace` + some separator + `code.function.name` form a unique identifier for the code unit.
20-
examples: com.example.MyHttpService
12+
The method or function fully-qualified name without arguments. The value should fit the natural representation of the language
13+
runtime, which is also likely the same used within `code.stacktrace` attribute value.
14+
examples:
15+
- 'com.example.MyHttpService.serveRequest'
16+
- 'GuzzleHttp\Client::transfer'
17+
- 'fopen'
18+
note: |
19+
Values and format depends on each language runtime, thus it is impossible to provide an exhaustive list of examples.
20+
The values are usually the same (or prefixes of) the ones found in native stack trace representation stored in
21+
`code.stacktrace` without information on arguments.
22+
23+
Examples:
24+
25+
* Java method: `com.example.MyHttpService.serveRequest`
26+
* Java anonymous class method: `com.mycompany.Main$1.myMethod`
27+
* Java lambda method: `com.mycompany.Main$$Lambda/0x0000748ae4149c00.myMethod`
28+
* PHP function: `GuzzleHttp\Client::transfer
29+
* Go function: `github.com/my/repo/pkg.foo.func5`
30+
* Elixir: `OpenTelemetry.Ctx.new`
31+
* Erlang: `opentelemetry_ctx:new`
32+
* Rust: `playground::my_module::my_cool_func`
33+
* C function: `fopen`
2134
- id: code.file.path
2235
type: string
2336
stability: development

0 commit comments

Comments
 (0)