From 51baa9a867916d83a74398f154f1a28b5102860a Mon Sep 17 00:00:00 2001 From: Tigran Najaryan Date: Mon, 2 Dec 2019 12:01:33 -0500 Subject: [PATCH] Allow array values for attributes Resolves https://github.com/open-telemetry/opentelemetry-specification/issues/341 Array values are useful for representing attributes that can have multiple values (e.g. representing a Memcached `get` that can be over multiple keys and making the keys a span attribute). This change allows homogeneous array values for span attributes and specifies that array values should be JSON encoded stirng when exporting using protocols that do not natively support array values. --- specification/api-tracing.md | 6 ++++-- specification/data-semantic-conventions.md | 5 +++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/specification/api-tracing.md b/specification/api-tracing.md index 4834dfa895c..adaa7c28e23 100644 --- a/specification/api-tracing.md +++ b/specification/api-tracing.md @@ -344,8 +344,10 @@ A `Span` MUST have the ability to set attributes associated with it. An `Attribute` is defined by the following properties: - (Required) The attribute key, which must be a string. -- (Required) The attribute value, which must be either a string, a boolean - value, or a numeric type. +- (Required) The attribute value, which is either: + - A primitive type: string, boolean or numeric. + - An array of primitive type values. The array MUST be homogeneous, + i.e. it MUST NOT contain values of different types. The Span interface MUST provide: diff --git a/specification/data-semantic-conventions.md b/specification/data-semantic-conventions.md index cfda1326b78..627de6c59fc 100644 --- a/specification/data-semantic-conventions.md +++ b/specification/data-semantic-conventions.md @@ -6,6 +6,11 @@ Span attributes. * [Resource Conventions](data-resource-semantic-conventions.md) * [Span Conventions](#span-conventions) +The type of the attribute SHOULD be specified in the semantic convention +for that attribute. Array values are allowed for attributes. For +protocols that do not natively support array values such values MUST be +represented as JSON strings. + ## Span Conventions In OpenTelemetry spans can be created freely and it’s up to the implementor to