Add support for []interface{} as ArrayValue if all values are primitive types#2151
Add support for []interface{} as ArrayValue if all values are primitive types#2151dmarkhas wants to merge 2 commits intoopen-telemetry:mainfrom
Conversation
|
|
Allowing
One thing I'd worry about allowing |
|
Thanks for the comment @Aneurysm9. I missed that part of the spec, but it's not too much of an effort to restrict it to match the spec. The problem IMO with the current implementation is that doing Would stringifying all non-homogenous arrays (as the spec suggests) be a sufficiently safe solution, in your opinion? |
I think I can be convinced that allowing homogenous
I probably shouldn't have included the second sentence in that quote, it's speaking to something distinct. That sentence is intended to provide a means to convey array attributes over protocols that do not support arrays. It does not provide for serializing non-homogenous array attributes. The caller is free to do so if they want, though. |
|
Thanks. |
The conversion to string is a topic that needs to be resolved at the specification level. It has been a topic of discussion there in the past. The exact format of strigification needs to be explicit and well defined to ensure compatibility between OTel implementations. However, prior discussions could not reach agreement about what that format should be or even if it is possible for all languages. Personally, I do not like the idea of allowing Given generics are not yet a part of the Go language, I think we need to resolve this issue by explicitly breaking out the allowed array types into their own values. I think the best place for this discussion is in an issue of it's own. I'll open one to track this. |
|
Superseded by #2162 |
Currently, only arrays of specific primitive types are supported as attribute array values ([]string, []int, etc.), however it's not uncommon to deal with []interface{}, where the runtime type of every element is in fact a primitive type.
In such a case, there's no reason to discard the array, and it can be treated like other primitive arrays.