Add YAML definition for code-related semantic attributes. (#1229)

* Introduce code-related semantic attributes.

* Generate table for `code` semantic attributes from the yaml spec.

* Update semantic_conventions/trace/general.yaml

Co-authored-by: Christian Neumüller <christian+github@neumueller.me>

* Update semantic_conventions/trace/general.yaml

Co-authored-by: Christian Neumüller <christian+github@neumueller.me>

* Generate table for `code` semantic attributes from the yaml spec.

* Revert line-endings-only change

* Better function name for code.function example.

Co-authored-by: Armin Ruech <armin.ruech@dynatrace.com>

Co-authored-by: Christian Neumüller <christian+github@neumueller.me>
Co-authored-by: Armin Ruech <armin.ruech@dynatrace.com>
This commit is contained in:
Vladimir Šor 2020-11-19 19:55:10 +02:00 committed by GitHub
parent fdb736a7a3
commit f2bc1ad6bd
2 changed files with 30 additions and 2 deletions

View File

@ -95,3 +95,29 @@ groups:
with an [OAuth 2.0 Access Token](https://tools.ietf.org/html/rfc6749#section-3.3) with an [OAuth 2.0 Access Token](https://tools.ietf.org/html/rfc6749#section-3.3)
or an attribute value in a [SAML 2.0 Assertion](http://docs.oasis-open.org/security/saml/Post2.0/sstc-saml-tech-overview-2.0.html). or an attribute value in a [SAML 2.0 Assertion](http://docs.oasis-open.org/security/saml/Post2.0/sstc-saml-tech-overview-2.0.html).
examples: 'read:message, write:files' examples: 'read:message, write:files'
- id: code
prefix: code
brief: >
These attributes allow to report this unit of code and therefore to provide more context about the span.
attributes:
- id: function
type: string
brief: >
The method or function name, or equivalent (usually rightmost part of the code unit's name).
examples: serveRequest
- id: namespace
type: string
brief: >
The "namespace" within which `code.function` is defined. Usually the qualified class or module name,
such that `code.namespace` + some separator + `code.function` form a unique identifier for the code unit.
examples: com.example.MyHttpService
- id: filepath
type: string
brief: >
The source code file name that identifies the code unit as uniquely as possible (preferably an absolute file path).
examples: /usr/local/MyApplication/content_root/app/index.php
- id: lineno
type: number
brief: >
The line number in `code.filepath` best representing the operation. It SHOULD point within the code unit named in `code.function`.
examples: 42

View File

@ -168,9 +168,11 @@ For an HTTP server span, this would be the function that handles the incoming re
The attributes listed below allow to report this unit of code and therefore to provide more context The attributes listed below allow to report this unit of code and therefore to provide more context
about the span. about the span.
<!-- semconv code -->
| Attribute | Type | Description | Example | Required | | Attribute | Type | Description | Example | Required |
|---|---|---|---|---| |---|---|---|---|---|
| `code.function` | string | The method or function name, or equivalent (usually rightmost part of the code unit's name). | `serveRequest` | No | | `code.function` | string | The method or function name, or equivalent (usually rightmost part of the code unit's name). | `serveRequest` | No |
| `code.namespace` | string | The "namespace" within which `code.function` is defined. Usually the qualified class or module name, such that `code.namespace` + some separator + `code.function` form a unique identifier for the code unit. | `com.example.MyHttpService` | No | | `code.namespace` | string | The "namespace" within which `code.function` is defined. Usually the qualified class or module name, such that `code.namespace` + some separator + `code.function` form a unique identifier for the code unit. | `com.example.MyHttpService` | No |
| `code.filepath` | string | The source code file name that identifies the code unit as uniquely as possible (preferably an absolute file path). | `/usr/local/MyApplication/src/main/java/com/example/MyHttpService.java` | No | | `code.filepath` | 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` | No |
| `code.lineno` | number | The line number in `code.filepath` best representing the operation. It SHOULD point within the code unit named in `code.function`. | `42` | No | | `code.lineno` | number | The line number in `code.filepath` best representing the operation. It SHOULD point within the code unit named in `code.function`. | `42` | No |
<!-- endsemconv -->