-
Couldn't load subscription status.
- Fork 934
Extend the set of attribute value types #4651
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 87 commits
026fad1
1831164
82e8913
9cab0c4
85db60a
eaea1ea
25c2c25
d9ac9f7
75b22ad
c540098
05fa307
aa3c41c
20043e3
bfaf650
c17aec6
95b049b
b98d714
e55416d
49b41b4
db81d62
ad10769
cc41e2f
8b029c8
a5851af
52ccb34
9bd7de9
ecebf40
abfd063
cbe15f5
7a3c387
f2a508b
ee4d8ba
10400ef
f8236e7
d7de5d0
5b46a71
4a15e7c
552e997
b224937
9f04b58
61a9a1b
98fb4ae
f343e4e
253949f
d246e63
9e47faa
1ac516a
2dd712d
0230f74
a9b711d
a1493d4
df85700
708686e
af80d42
dca8512
ec94759
eee4182
d4240f2
9b210ca
851f426
a5178c6
4f92d3d
e3a1a65
bf19f4d
d7d4eaa
4d7c1da
4b69f1f
d756e95
815cf8b
1174a4a
e1386ca
703745c
9c2136f
0baa88c
42bc422
e11dd54
6c8418e
6169089
4817bca
23b00af
4a4af91
2884f43
7c1896d
ab65c41
8fbd4fc
35e2fd4
3bfd222
d739e7c
53adb76
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,15 +8,16 @@ path_base_for_github_subdir: | |
|
|
||
| # Common specification concepts | ||
|
|
||
| **Status**: [Stable](../document-status.md) | ||
| **Status**: [Stable](../document-status.md), except where otherwise specified | ||
|
|
||
| <details> | ||
| <summary>Table of Contents</summary> | ||
|
|
||
| <!-- toc --> | ||
|
|
||
| - [AnyValue](#anyvalue) | ||
| * [map](#mapstring-anyvalue) | ||
| - [Attribute](#attribute) | ||
| * [Standard Attribute](#standard-attribute) | ||
| * [Attribute Limits](#attribute-limits) | ||
| + [Configurable Parameters](#configurable-parameters) | ||
| + [Exempt Entities](#exempt-entities) | ||
|
|
@@ -26,39 +27,81 @@ path_base_for_github_subdir: | |
|
|
||
| </details> | ||
|
|
||
| ## Attribute | ||
| ## AnyValue | ||
|
|
||
| <a id="attributes"></a> | ||
| `AnyValue` is either: | ||
pellared marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| An `Attribute` is a key-value pair, which MUST have the following properties: | ||
| - a primitive type: string, boolean, double precision floating point | ||
| (IEEE 754-1985), or signed 64 bit integer, | ||
| - a homogeneous array of primitive type values. A homogeneous array MUST NOT | ||
| contain values of different types. | ||
| - **Status**: [Development](../document-status.md) - a byte array. | ||
| - **Status**: [Development](../document-status.md) - an array of `AnyValue`, | ||
pellared marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| - **Status**: [Development](../document-status.md) - a [`map<string, AnyValue>`](#mapstring-anyvalue), | ||
pellared marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| - **Status**: [Development](../document-status.md) - an empty value if supported by the language, | ||
| (e.g. `null`, `undefined` in JavaScript/TypeScript, `None` in Python, `nil` in Go/Ruby, not supported in Erlang, etc.) | ||
|
|
||
| - The attribute key MUST be a non-`null` and non-empty string. | ||
| - Case sensitivity of keys is preserved. Keys that differ in casing are treated as distinct keys. | ||
| - The attribute value is either: | ||
| - A primitive type: string, boolean, double precision floating point (IEEE 754-1985) or signed 64 bit integer. | ||
| - An array of primitive type values. The array MUST be homogeneous, | ||
| i.e., it MUST NOT contain values of different types. | ||
| Arbitrary deep nesting of values for arrays and maps is allowed (essentially | ||
| allows to represent an equivalent of a JSON object). | ||
|
|
||
| For protocols that do not natively support non-string values, non-string values SHOULD be represented as JSON-encoded strings. For example, the expression `int64(100)` will be encoded as `100`, `float64(1.5)` will be encoded as `1.5`, and an empty array of any type will be encoded as `[]`. | ||
| APIs SHOULD be documented in a way to communicate to users that using array and | ||
| map values may carry higher performance overhead compared to primitive values. | ||
|
|
||
| Attribute values expressing a numerical value of zero, an empty string, or an | ||
| empty array are considered meaningful and MUST be stored and passed on to | ||
| processors / exporters. | ||
| For protocols that do not natively support some of the value types, corresponding values | ||
| SHOULD be represented as JSON-encoded strings. For example, the expression | ||
| `int64(100)` will be encoded as `100`, `float64(1.5)` will be encoded as `1.5`, | ||
| and an empty array of any type will be encoded as `[]`. | ||
|
|
||
| Attribute values of `null` are not valid and attempting to set a `null` value is | ||
| undefined behavior. | ||
| AnyValues expressing an empty value, a numerical value of zero, an empty string, | ||
| or an empty array are considered meaningful and MUST be stored and passed on to | ||
| processors / exporters. | ||
|
|
||
| `null` values SHOULD NOT be allowed in arrays. However, if it is impossible to | ||
| make sure that no `null` values are accepted | ||
| While `null` is a valid attribute value, its use within homogeneous arrays | ||
| SHOULD generally be avoided unless language constraints make this impossible. | ||
| However, if it is impossible to make sure that no `null` values are accepted | ||
| (e.g. in languages that do not have appropriate compile-time type checking), | ||
| `null` values within arrays MUST be preserved as-is (i.e., passed on to span | ||
| `null` values within arrays MUST be preserved as-is (i.e., passed on to | ||
| processors / exporters as `null`). If exporters do not support exporting `null` | ||
| values, they MAY replace those values by 0, `false`, or empty strings. | ||
| This is required for map/dictionary structures represented as two arrays with | ||
| indices that are kept in sync (e.g., two attributes `header_keys` and `header_values`, | ||
| both containing an array of strings to represent a mapping | ||
| `header_keys[i] -> header_values[i]`). | ||
|
|
||
| ### map<string, AnyValue> | ||
|
|
||
| **Status**: [Development](../document-status.md) | ||
|
|
||
| `map<string, AnyValue>` is a map of string keys to `AnyValue` values. | ||
| The keys in the map are unique (duplicate keys are not allowed). | ||
pellared marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| Case sensitivity of keys MUST be preserved. | ||
| Keys that differ in casing are treated as distinct keys. | ||
|
|
||
| The representation of the map is language-dependent. | ||
|
|
||
| The implementation MUST by default ensure that the exported maps contain only unique keys. | ||
pellared marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| The implementation MAY have an option to allow exporting maps with duplicate keys | ||
| (e.g. for better performance). | ||
| If such option is provided, it MUST be documented that for many receivers, | ||
| handling of maps with duplicate keys is unpredictable and it is the users' | ||
| responsibility to ensure keys are not duplicate. | ||
|
|
||
| Maps are equal when they contain the same key-value pairs, | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Out of curiosity, is there a practical use case that needs this paragraph? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes. This is needed so that the equality of attribute collections can determined when maps are used e.g. in instrumentation scope attributes. |
||
| irrespective of the order in which those elements appear | ||
| (unordered collection equality). | ||
|
|
||
| ## Attribute | ||
pellared marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| <a id="attributes"></a> | ||
pellared marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| An `Attribute` is a key-value pair, which MUST have the following properties: | ||
|
|
||
| - The attribute key MUST be a non-`null` and non-empty string. | ||
| - Case sensitivity of keys is preserved. Keys that differ in casing are treated as distinct keys. | ||
| - The attribute value MUST be one of types defined in [AnyValue](#anyvalue). | ||
|
|
||
| Attributes are equal when their keys and values are equal. | ||
|
|
||
| See [Attribute Naming](https://github.com/open-telemetry/semantic-conventions/blob/main/docs/general/naming.md#attributes) for naming guidelines. | ||
|
|
@@ -68,26 +111,11 @@ See [Requirement Level](https://github.com/open-telemetry/semantic-conventions/b | |
| See [this document](attribute-type-mapping.md) to find out how to map values obtained | ||
| outside OpenTelemetry into OpenTelemetry attribute values. | ||
|
|
||
| ### Standard Attribute | ||
|
|
||
| Attributes are used in various places throughout the OpenTelemetry data model. | ||
| We designate the [previous attribute section](#attribute) as the standard | ||
| attribute definition, in order to facilitate more intuitive and consistent API / | ||
| SDK design. | ||
|
|
||
| The standard attribute definition SHOULD be used to represent attributes in data | ||
| modeling unless there is a strong justification to diverge. For example, the Log | ||
| Data Model has an extended [attributes](../logs/data-model.md#field-attributes) | ||
| definition allowing values of [type `Any`](../logs/data-model.md#type-any). This | ||
| reflects that LogRecord attributes are expected to model data produced from | ||
| external log APIs, which do not necessarily have the same value type | ||
| restrictions as the standard attribute definition. | ||
|
|
||
| ### Attribute Limits | ||
|
|
||
| Execution of erroneous code can result in unintended attributes. If there are no | ||
| limits placed on attributes, they can quickly exhaust available memory, resulting | ||
| in crashes that are difficult to recover from safely. | ||
| limits placed on attribute collections, they can quickly exhaust available memory, | ||
| resulting in crashes that are difficult to recover from safely. | ||
|
|
||
| By default an SDK SHOULD apply truncation as per the list of | ||
| [configurable parameters](#configurable-parameters) below. | ||
|
|
@@ -99,12 +127,24 @@ If an SDK provides a way to: | |
| - if it is a string, if it exceeds that limit (counting any character in it as | ||
| 1), SDKs MUST truncate that value, so that its length is at most equal | ||
| to the limit, | ||
| - if it is an array of strings, then apply the above rule to each of the | ||
| values separately, | ||
| - **Status**: [Development](../document-status.md) - if it is a byte array, | ||
| if its length exceeds that limit (counting each byte as 1), | ||
| SDKs MUST truncate that value, so that its length is at most equal to the limit, | ||
| - if it is an array of strings, then apply the limit to | ||
| each value within the array separately, | ||
pellared marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| - **Status**: [Development](../document-status.md) - if it is an array of [AnyValue](#anyvalue), | ||
| then apply the limit to each element of the array separately (and recursively), | ||
| - **Status**: [Development](../document-status.md) - if it is a [map](#mapstring-anyvalue), | ||
| then apply the limit to each value within the map separately (and recursively), | ||
tigrannajaryan marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| - otherwise a value MUST NOT be truncated; | ||
pellared marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| - set a limit of unique attribute keys such that: | ||
| - for each unique attribute key, addition of which would result in exceeding | ||
| the limit, SDK MUST discard that key/value pair. | ||
| - set an attribute count limit such that: | ||
tigrannajaryan marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| - if adding an attribute to an attribute collection would result | ||
| in exceeding the limit (counting each attribute in the collection as 1), | ||
| the SDK MUST discard that attribute, so that the total number of attributes in | ||
| an attribute collection is at most equal to the limit; | ||
| - **Status**: [Development](../document-status.md) - the count limit applies only to top-level attributes, not to nested key-value | ||
| pairs within [maps](#mapstring-anyvalue); | ||
| - otherwise an attribute MUST NOT be discarded. | ||
|
|
||
| There MAY be a log emitted to indicate to the user that an attribute was | ||
| truncated or discarded. To prevent excessive logging, the log MUST NOT be | ||
|
|
@@ -121,10 +161,14 @@ use the model-specific limit, if it isn't set, then the SDK MUST attempt to use | |
| the general limit. If neither are defined, then the SDK MUST try to use the | ||
| model-specific limit default value, followed by the global limit default value. | ||
|
|
||
| Note that the limits apply only to attributes collections. | ||
pellared marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| Therefore, they do not apply to values within other data structures such as | ||
| [`LogRecord.Body`](../logs/data-model.md#field-body). | ||
|
|
||
| #### Configurable Parameters | ||
|
|
||
| * `AttributeCountLimit` (Default=128) - Maximum allowed attribute count per record; | ||
| * `AttributeValueLengthLimit` (Default=Infinity) - Maximum allowed attribute value length; | ||
| * `AttributeValueLengthLimit` (Default=Infinity) - Maximum allowed attribute value length (applies to string values and byte arrays); | ||
|
|
||
| #### Exempt Entities | ||
|
|
||
|
|
@@ -148,9 +192,11 @@ at this time, as discussed in | |
| [Spans](../trace/api.md#set-attributes), Span | ||
| [Events](../trace/api.md#add-events), Span | ||
| [Links](../trace/api.md#link) and | ||
| [Log Records](../logs/data-model.md) may contain a collection of attributes. The | ||
| keys in each such collection are unique, i.e. there MUST NOT exist more than one | ||
| key-value pair with the same key. The enforcement of uniqueness may be performed | ||
| [Log Records](../logs/data-model.md), | ||
| contain a collection of attributes. | ||
|
|
||
| Implementation MUST by default ensure that the exported attribute collections | ||
| contain only unique keys. The enforcement of uniqueness may be performed | ||
| in a variety of ways as it best fits the limitations of the particular | ||
| implementation. | ||
|
|
||
|
|
@@ -173,6 +219,12 @@ that individual attribute value being exported using a streaming wire protocol. | |
| In such cases the enforcement of uniqueness will likely be the responsibility of | ||
| the recipient of this data. | ||
|
|
||
| Implementations MAY have an option to allow exporting attribute collections | ||
| with duplicate keys (e.g. for better performance). | ||
| If such option is provided, it MUST be documented that for many receivers, | ||
| handling of maps with duplicate keys is unpredictable and it is the users' | ||
| responsibility to ensure keys are not duplicate. | ||
|
|
||
| Collection of attributes are equal when they contain the same attributes, | ||
| irrespective of the order in which those elements appear | ||
| (unordered collection equality). | ||
Uh oh!
There was an error while loading. Please reload this page.