From 9a803247d8fb652f9cf7b11270820415ed5dd2ce Mon Sep 17 00:00:00 2001 From: Armin Ruech Date: Tue, 15 Sep 2020 17:33:58 +0200 Subject: [PATCH] Add semantic convention for source code attributes (#901) --- CHANGELOG.md | 2 ++ .../trace/semantic_conventions/span-general.md | 16 ++++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2d96cd1ef85..38fc643b771 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,8 @@ New: ([#891](/~https://github.com/open-telemetry/opentelemetry-specification/pull/891)) - Add resource semantic conventions for operating systems ([#693](/~https://github.com/open-telemetry/opentelemetry-specification/pull/693)) +- Add semantic convention for source code attributes + ([#901](/~https://github.com/open-telemetry/opentelemetry-specification/pull/901)) - Add semantic conventions for outgoing Function as a Service (FaaS) invocations ([#862](/~https://github.com/open-telemetry/opentelemetry-specification/pull/862)) - Add resource semantic convention for deployment environment diff --git a/specification/trace/semantic_conventions/span-general.md b/specification/trace/semantic_conventions/span-general.md index 353345951e4..d250d8ba376 100644 --- a/specification/trace/semantic_conventions/span-general.md +++ b/specification/trace/semantic_conventions/span-general.md @@ -14,6 +14,7 @@ Particular operations may refer to or require some of these attributes. - [General remote service attributes](#general-remote-service-attributes) - [General identity attributes](#general-identity-attributes) - [General thread attributes](#general-thread-attributes) +- [Source Code Attributes](#source-code-attributes) @@ -158,3 +159,18 @@ Examples of where `thread.id` and `thread.name` can be extracted from: | Ruby | | `Thread.current.name` | | C++ | `std::this_thread::get_id()` | | | Erlang | `erlang:system_info(scheduler_id)` | | + +## Source Code Attributes + +Often a span is closely tied to a certain unit of code that is logically responsible for handling +the operation that the span describes (usually the method that starts the span). +For an HTTP server span, this would be the function that handles the incoming request, for example. +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.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 |