Skip to content

Commit 08c6611

Browse files
authored
Stabilize complex AnyValue types and related attribute limits (#4794)
Fixes #4710 OTEP #4485 (Extending attributes to support complex values) ## What Stabilize the complex `AnyValue` attribute value types and the corresponding attribute limits. Simplifiy the Logs Data Model to rely on `AnyValue` and Attribute Collections instead of custom `any` / `map<string, any>` types. ## Why Per the OTEP-implementing PR [#4485](#4485) tht was merged on **2025‑07‑15**, so the 6‑month window ends around **2026‑01‑15**. This PR is intended to be merged around **2026‑01‑15**, in line with that requirement. > Stable exporters will be prohibited from emitting complex attributes by default on signals other than Logs until at least 6 months after this OTEP is merged. OpenTelemetry **Go** and **Java** treat the common package as a **stable cross‑cutting surface**. They need these `AnyValue` types and limits to be Stable in the spec before they can add corresponding features to their APIs, SDKs, and exporters. ## Prototypes We have **three independent prototypes** that exercised the complex `AnyValue` attribute types and limits: - Java: open-telemetry/opentelemetry-java#7814 ( - Python: open-telemetry/opentelemetry-python#4587 - Go: open-telemetry/opentelemetry-go#6809 In summary, they: 1. Validated that complex attributes can be represented and processed end‑to‑end using `AnyValue`. 2. Confirmed that the specified attribute limits (length and count) are acceptable. 3. Demonstrated that existing implementations can adopt complex attributes without breaking current stable behavior. ## Other I was thinking about adding something to `spec-compliance-matrix.md`, but I do not see any obvious place where it could be located. I think we can tackle it in a separate PR if there would be a demand for it. EDIT: Tracked under #4808
1 parent 837b2f1 commit 08c6611

File tree

3 files changed

+20
-58
lines changed

3 files changed

+20
-58
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ release.
4949

5050
### Common
5151

52+
- Stabilize complex `AnyValue` attribute value types and related attribute limits.
53+
([#4794](https://github.com/open-telemetry/opentelemetry-specification/issues/4794))
54+
5255
### Supplementary Guidelines
5356

5457
### OTEPs

specification/common/README.md

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,10 @@ path_base_for_github_subdir:
3535
(IEEE 754-1985), or signed 64 bit integer,
3636
- a homogeneous array of primitive type values. A homogeneous array MUST NOT
3737
contain values of different types.
38-
- **Status**: [Development](../document-status.md) - a byte array.
39-
- **Status**: [Development](../document-status.md) - an array of `AnyValue`,
40-
- **Status**: [Development](../document-status.md) - a [`map<string, AnyValue>`](#mapstring-anyvalue),
41-
- **Status**: [Development](../document-status.md) - an empty value if supported by the language,
38+
- a byte array.
39+
- an array of `AnyValue`,
40+
- a [`map<string, AnyValue>`](#mapstring-anyvalue),
41+
- an empty value if supported by the language,
4242
(e.g. `null`, `undefined` in JavaScript/TypeScript, `None` in Python, `nil` in Go/Ruby, not supported in Erlang, etc.)
4343

4444
Arbitrary deep nesting of values for arrays and maps is allowed (essentially
@@ -70,8 +70,6 @@ both containing an array of strings to represent a mapping
7070

7171
### map<string, AnyValue>
7272

73-
**Status**: [Development](../document-status.md)
74-
7573
`map<string, AnyValue>` is a map of string keys to `AnyValue` values.
7674
The keys in the map are unique (duplicate keys are not allowed).
7775

@@ -181,22 +179,22 @@ If an SDK provides a way to:
181179
- if it is a string, if it exceeds that limit (counting any character in it as
182180
1), SDKs MUST truncate that value, so that its length is at most equal
183181
to the limit,
184-
- **Status**: [Development](../document-status.md) - if it is a byte array,
182+
- if it is a byte array,
185183
if its length exceeds that limit (counting each byte as 1),
186184
SDKs MUST truncate that value, so that its length is at most equal to the limit,
187185
- if it is an array of strings, then apply the limit to
188186
each value within the array separately,
189-
- **Status**: [Development](../document-status.md) - if it is an array of [AnyValue](#anyvalue),
187+
- if it is an array of [AnyValue](#anyvalue),
190188
then apply the limit to each element of the array separately (and recursively),
191-
- **Status**: [Development](../document-status.md) - if it is a [map](#mapstring-anyvalue),
189+
- if it is a [map](#mapstring-anyvalue),
192190
then apply the limit to each value within the map separately (and recursively),
193191
- otherwise a value MUST NOT be truncated;
194192
- set an attribute count limit such that:
195193
- if adding an attribute to an attribute collection would result
196194
in exceeding the limit (counting each attribute in the collection as 1),
197195
the SDK MUST discard that attribute, so that the total number of attributes in
198196
an attribute collection is at most equal to the limit;
199-
- **Status**: [Development](../document-status.md) - the count limit applies only to top-level attributes, not to nested key-value
197+
- the count limit applies only to top-level attributes, not to nested key-value
200198
pairs within [maps](#mapstring-anyvalue);
201199
- otherwise an attribute MUST NOT be discarded.
202200

specification/logs/data-model.md

Lines changed: 9 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,6 @@ weight: 2
1515
- [Design Notes](#design-notes)
1616
* [Requirements](#requirements)
1717
* [Events](#events)
18-
* [Definitions Used in this Document](#definitions-used-in-this-document)
19-
+ [Type `any`](#type-any)
20-
+ [Type `map`](#type-mapstring-any)
2118
* [Field Kinds](#field-kinds)
2219
- [Log and Event Record Definition](#log-and-event-record-definition)
2320
* [Field: `Timestamp`](#field-timestamp)
@@ -112,43 +109,6 @@ conventions defined for logs SHOULD be formatted as Events. Requirements and det
112109
Events are intended to be used by OpenTelemetry instrumentation. It is not a
113110
requirement that all LogRecords are formatted as Events.
114111

115-
### Definitions Used in this Document
116-
117-
In this document we refer to types `any` and `map<string, any>`, defined as
118-
follows.
119-
120-
#### Type `any`
121-
122-
Value of type `any` can be one of the following:
123-
124-
- A scalar value: string, boolean, signed 64 bit integer, or double precision floating point (IEEE 754-1985)
125-
126-
- A byte array,
127-
128-
- An array (a list) of `any` values,
129-
130-
- A `map<string, any>`,
131-
132-
- [since 1.31.0] An empty value (e.g. `null`).
133-
134-
#### Type `map<string, any>`
135-
136-
Value of type `map<string, any>` is a map of string keys to `any` values. The
137-
keys in the map are unique (duplicate keys are not allowed).
138-
139-
Arbitrary deep nesting of values for arrays and maps is allowed (essentially
140-
allows to represent an equivalent of a JSON object).
141-
142-
The representation of the map is language-dependent.
143-
144-
The implementation MUST by default ensure that the exported maps contain only unique keys.
145-
146-
The implementation MAY have an option to allow exporting maps with duplicate keys
147-
(e.g. for better performance).
148-
If such option is provided, it MUST be documented that for many receivers,
149-
handling of maps with duplicate keys is unpredictable and it is the users'
150-
responsibility to ensure keys are not duplicate.
151-
152112
### Field Kinds
153113

154114
This Data Model defines a logical model for a log record (irrespective of the
@@ -157,11 +117,12 @@ fields:
157117

158118
- Named top-level fields of specific type and meaning.
159119

160-
- Fields stored as `map<string, any>`, which can contain arbitrary values of
161-
different types. The keys and values for well-known fields follow semantic
162-
conventions for key names and possible values that allow all parties that work
163-
with the field to have the same interpretation of the data. See references to
164-
semantic conventions for `Resource` and `Attributes` fields and examples in
120+
- Fields stored as [Attribute Collections](../common/README.md#attribute-collections),
121+
whose values are [AnyValue](../common/README.md#anyvalue). The keys and values
122+
for well-known fields follow semantic conventions for key names and possible
123+
values that allow all parties that work with the field to have the same
124+
interpretation of the data. See references to semantic conventions for
125+
`Resource` and `Attributes` fields and examples in
165126
[Appendix A](./data-model-appendix.md#appendix-a-example-mappings).
166127

167128
The reasons for having these 2 kinds of fields are:
@@ -173,7 +134,7 @@ The reasons for having these 2 kinds of fields are:
173134
- Ability to enforce types of named fields, which is very useful for compiled
174135
languages with type checks.
175136

176-
- Flexibility to represent less frequent data as `map<string, any>`. This
137+
- Flexibility to represent less frequent data in Attribute Collections. This
177138
includes well-known data that has standardized semantics as well as arbitrary
178139
custom data that the application may want to include in the logs.
179140

@@ -430,7 +391,7 @@ when it is used to represent an unspecified severity.
430391

431392
### Field: `Body`
432393

433-
Type: [`any`](#type-any) or [AnyValue](../common/README.md#anyvalue).
394+
Type: [AnyValue](../common/README.md#anyvalue).
434395

435396
Description: A value containing the body of the log record. Can be for example
436397
a human-readable string message (including multi-line) describing the event in
@@ -465,7 +426,7 @@ they all have the same value of `InstrumentationScope`. This field is optional.
465426

466427
### Field: `Attributes`
467428

468-
Type: [`map<string, any>`](#type-mapstring-any) or [Attribute Collection](../common/README.md#attribute-collections).
429+
Type: [Attribute Collection](../common/README.md#attribute-collections).
469430

470431
Description: Additional information about the specific event occurrence. Unlike
471432
the `Resource` field, which is fixed for a particular source, `Attributes` can

0 commit comments

Comments
 (0)