From f2bc1ad6bd28292b91f48aae7f8fd63cce274fcf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladimir=20=C5=A0or?= Date: Thu, 19 Nov 2020 19:55:10 +0200 Subject: [PATCH] Add YAML definition for code-related semantic attributes. (#1229) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 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 * Update semantic_conventions/trace/general.yaml Co-authored-by: Christian Neumüller * 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 Co-authored-by: Christian Neumüller Co-authored-by: Armin Ruech --- semantic_conventions/trace/general.yaml | 28 ++++++++++++++++++- .../semantic_conventions/span-general.md | 4 ++- 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/semantic_conventions/trace/general.yaml b/semantic_conventions/trace/general.yaml index 27c0c38c7..9da414b53 100644 --- a/semantic_conventions/trace/general.yaml +++ b/semantic_conventions/trace/general.yaml @@ -94,4 +94,30 @@ groups: or application security context. The value would come from the scope associated 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). - examples: 'read:message, write:files' \ No newline at end of file + 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 diff --git a/specification/trace/semantic_conventions/span-general.md b/specification/trace/semantic_conventions/span-general.md index d250d8ba3..dee1761ce 100644 --- a/specification/trace/semantic_conventions/span-general.md +++ b/specification/trace/semantic_conventions/span-general.md @@ -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 about the span. + | 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.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 | +