Skip to content

Commit 6b78794

Browse files
tigrannajaryanpyohannes
authored andcommitted
Clarify that attribute keys are unique in collections (open-telemetry#2248)
Attributes keys must be unique. The key/value pair collections in the specification was always intended to model a map. There was a recent confusion about this. This change clarifies the spec. Resolves open-telemetry/opentelemetry-specification#2245
1 parent cb2aa28 commit 6b78794

1 file changed

Lines changed: 33 additions & 0 deletions

File tree

specification/common/common.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
- [Attribute](#attribute)
1111
* [Attribute Limits](#attribute-limits)
1212
+ [Exempt Entities](#exempt-entities)
13+
- [Attribute Collections](#attribute-collections)
1314

1415
<!-- tocstop -->
1516

@@ -105,3 +106,35 @@ attribute limits for Resources.
105106
Attributes, which belong to Metrics, are exempt from the limits described above
106107
at this time, as discussed in
107108
[Metrics Attribute Limits](../metrics/sdk.md#attribute-limits).
109+
110+
## Attribute Collections
111+
112+
[Resources](../resource/sdk.md), Metrics
113+
[data points](../metrics/datamodel.md#metric-points),
114+
[Spans](../trace/api.md#set-attributes), Span
115+
[Events](../trace/api.md#add-events), Span
116+
[Links](../trace/api.md#specifying-links) and
117+
[Log Records](../logs/data-model.md) may contain a collection of attributes. The
118+
keys in each such collection are unique, i.e. there MUST NOT exist more than one
119+
key-value pair with the same key. The enforcement of uniqueness may be performed
120+
in a variety of ways as it best fits the limitations of the particular
121+
implementation.
122+
123+
Normally for the telemetry generated using OpenTelemetry SDKs the attribute
124+
key-value pairs are set via an API that either accepts a single key-value pair
125+
or a collection of key-value pairs. Setting an attribute with the same key as an
126+
existing attribute SHOULD overwrite the existing attribute's value. See for
127+
example Span's [SetAttribute](../trace/api.md#set-attributes) API.
128+
129+
A typical implementation of [SetAttribute](../trace/api.md#set-attributes) API
130+
will enforce the uniqueness by overwriting any existing attribute values pending
131+
to be exported, so that when the Span is eventually exported the exporters see
132+
only unique attributes. The OTLP format in particular requires that exported
133+
Resources, Spans, Metric data points and Log Records contain only unique
134+
attributes.
135+
136+
Some other implementations may use a streaming approach where every
137+
[SetAttribute](../trace/api.md#set-attributes) API call immediately results in
138+
that individual attribute value being exported using a streaming wire protocol.
139+
In such cases the enforcement of uniqueness will likely be the responsibility of
140+
the recipient of this data.

0 commit comments

Comments
 (0)