From b94cd4b24917d0099eb0ddee6f9d6be0bddee469 Mon Sep 17 00:00:00 2001 From: Hussein Al Abry Date: Tue, 23 Feb 2021 01:42:52 +0400 Subject: [PATCH] add code attributes to semconv package (#1558) * add code attributes to semconv package * update changelog * update comment for code semconv attributes Adds a full-stop at the end of the comment. Co-authored-by: Anthony Mirabella Co-authored-by: Tyler Yahn --- CHANGELOG.md | 1 + semconv/trace.go | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index ffb9e1460..a2df2c302 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -25,6 +25,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm - Added `resource.Default()` for use with meter and tracer providers. (#1507) - Added `Keys()` method to `propagation.TextMapCarrier` and `propagation.HeaderCarrier` to adapt `http.Header` to this interface. (#1544) +- Added `code` attributes to `go.opentelemetry.io/otel/semconv` package. (#1558) ### Removed diff --git a/semconv/trace.go b/semconv/trace.go index a90b471c0..145fc6076 100644 --- a/semconv/trace.go +++ b/semconv/trace.go @@ -353,3 +353,24 @@ var ( FaaSDocumentOperationEdit = FaaSDocumentOperationKey.String("edit") FaaSDocumentOperationDelete = FaaSDocumentOperationKey.String("delete") ) + +// Semantic conventions for source code attributes. +const ( + // The method or function name, or equivalent (usually rightmost part of + // the code unit's name). + CodeFunctionKey = attribute.Key("code.function") + + // 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. + CodeNamespaceKey = attribute.Key("code.namespace") + + // The source code file name that identifies the code unit as uniquely as + // possible (preferably an absolute file path). + CodeFilepathKey = attribute.Key("code.filepath") + + // The line number in `code.filepath` best representing the operation. + // It SHOULD point within the code unit named in `code.function`. + CodeLineNumberKey = attribute.Key("code.lineno") +)