You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Support maps and heterogeneous arrays as attribute values
Resolvesopen-telemetry#376
Use cases where this is necessary or useful:
1. Specify more than one resource in the telemetry: open-telemetry#579
2. Data coming from external source, e.g. AWS Metadata: open-telemetry#596 (comment)
or open-telemetry#376 (comment)
3. Capturing HTTP headers: open-telemetry#376 (comment)
4. Structured stack traces: open-telemetry#2841
5. Payloads as attributes: open-telemetry/oteps#219 (comment)
This is a draft PR to see what the change looks like.
If this PR is merged it will be nice to follow it up with:
- A standard way of flattening maps and nested objects when converting from OTLP
to formats that don't support maps/nested objects.
- Recommendations for semantic conventions to use/not use complex objects.
Copy file name to clipboardexpand all lines: specification/common/README.md
+13-4
Original file line number
Diff line number
Diff line change
@@ -29,12 +29,21 @@ An `Attribute` is a key-value pair, which MUST have the following properties:
29
29
30
30
- The attribute key MUST be a non-`null` and non-empty string.
31
31
- Case sensitivity of keys is preserved. Keys that differ in casing are treated as distinct keys.
32
-
- The attribute value is either:
32
+
- The attribute value can be of `any` type, where any is defined as one of the following:
33
33
- A primitive type: string, boolean, double precision floating point (IEEE 754-1985) or signed 64 bit integer.
34
-
- An array of primitive type values. The array MUST be homogeneous,
35
-
i.e., it MUST NOT contain values of different types.
34
+
- A homogeneous array of values of primitive type [before 1.29.0].
35
+
- An array of `any` values [since 1.29.0].
36
+
- A key/value map, where key is string and value is `any` value [since 1.29.0].
36
37
37
-
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 `[]`.
38
+
Complex attribute types (such as homogenous arrays, arrays of any, and maps) SHOULD be
39
+
used sparingly, in situations where their use minimizes manipulation of the data’s
40
+
original structure.
41
+
42
+
When exporting to protocols that do not natively support a particular non-string
43
+
value type the value should be converted to a string JSON-encoding of the value.
44
+
45
+
For example, the expression `int64(100)` will be encoded as `100`, `float64(1.5)` will
46
+
be encoded as `1.5`, and an empty array of any type will be encoded as `[]`.
38
47
39
48
Attribute values expressing a numerical value of zero, an empty string, or an
40
49
empty array are considered meaningful and MUST be stored and passed on to
0 commit comments