-
Notifications
You must be signed in to change notification settings - Fork 896
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
Support maps and heterogeneous arrays as attribute values #2888
Changes from all commits
8c497e3
c0ef00f
c2d2941
1a385e7
b15695c
5e0d081
5ccaaf0
dc31a43
4f5e141
58cbb1a
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 |
---|---|---|
|
@@ -29,16 +29,31 @@ 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 is either: | ||
- The attribute value can be of `any` type, where any is defined as one of the following: | ||
tigrannajaryan marked this conversation as resolved.
Show resolved
Hide resolved
|
||
- 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. | ||
- An array of values of primitive type [before 1.29.0]. | ||
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. Should we also include a byte array (as for logs attributes)? |
||
- An array of `any` values [since 1.29.0]. | ||
- A key/value map, where key is string and value is `any` value. Any form of reference | ||
tigrannajaryan marked this conversation as resolved.
Show resolved
Hide resolved
|
||
cycle is disallowed. [since 1.29.0]. | ||
|
||
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 `[]`. | ||
Complex attribute types (such as arrays and maps) SHOULD be used sparingly. They may | ||
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. This normative statement is meaningless. Users define attributes not OTel SDKs. 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. This is for semantic convention authors. Will be moved to semconv repo. 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.
Makes sense. Can we track that with an issue if this merges? |
||
be useful for example in situations where their use minimizes manipulation | ||
of the data’s original structure. | ||
|
||
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. | ||
The following value types MUST NOT be used as metric attribute values: | ||
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. This is not viable. Stable implementations have already been released for this signal. Those implementations already accept attributes. Adding this statement here is hiding a breaking change. 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. @jack-berg actually implemented this and found it to be possible in non-breaking manner for Java. Do you think it is impossible to do for Go in a non-breaking way? 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. Thanks for the link to the example implementation, I missed that. I'm not that knowledgeable in Java, but I don't see in that implementation where it restricts attributes values in the metric signal. The Go implementation passes the same type 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. OK, that is very important. If we think this is impossible to implement in non-breaking way then it is a blocker, we can't accept the PR. I would like to take a closer look at Go implementation and see if we can find a non-breaking way to apply this change. Since this came up I would also want to be more careful and check some other languages (strongly typed/compiled languages are most likely to be impacted). 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. I think the alternative could be to describe in metrics SDK specification how the SDK should/must handle such cases (when these types of attributes are passed). Moreover, it would be good to add a rationale what are the reasons to have these constraints. |
||
|
||
- Non-homogeneous arrays (arrays containing values of different types). | ||
- Nested arrays. | ||
- Key/value maps. | ||
|
||
When exporting to protocols that do not natively support a particular non-string | ||
tigrannajaryan marked this conversation as resolved.
Show resolved
Hide resolved
|
||
value type the value should be converted to a string JSON-encoding of the value. | ||
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 `[]`. | ||
tigrannajaryan marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
Attribute values expressing a numerical value of zero, an empty string, an | ||
empty array or empty key/value map are considered meaningful and MUST be stored and | ||
passed on to processors / exporters. | ||
|
||
Attribute values of `null` are not valid and attempting to set a `null` value is | ||
undefined behavior. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
JavaScript has this as experimental as
LogAttributes
https://github.com/open-telemetry/opentelemetry-js/blob/bf8714edcba8a2384db857696a1608215548d182/experimental/packages/api-logs/src/types/LogRecord.ts#L20-L22