opentelemetry-rust icon indicating copy to clipboard operation
opentelemetry-rust copied to clipboard

opentelemetry::logs::AnyValue is missing a None variant

Open FSMaxB opened this issue 2 years ago • 9 comments

According to https://opentelemetry.io/docs/specs/otel/common/attribute-type-mapping/:

If the source data has no type associated with it and is empty, null, nil or otherwise indicates absence of data it SHOULD be converted to an empty AnyValue, where all the fields are unset.

This is currently unrepresentable with opentelemetry::logs::AnyValue, I suggest adding a new None variant and serializing that accordingly.

FSMaxB avatar Sep 07 '23 10:09 FSMaxB

Makes sense -- are you able to submit a PR? Seems like a straightforward addition.

djc avatar Sep 07 '23 10:09 djc

I can probably submit a PR within next week. Feel free to ping me again if it hasn't happened by then.

FSMaxB avatar Sep 07 '23 11:09 FSMaxB

Is there any reason why both opentelemetry::Value and opentelemetry::logs::AnyValue exist btw.? It seems to me that they should be the same type. (at least according to protocol buffers, they are the same type)

FSMaxB avatar Sep 13 '23 07:09 FSMaxB

@lalith @vibhavp can we remove logs::AnyValue in favor of the normal Value?

djc avatar Sep 13 '23 07:09 djc

As per the log data model - the attribute value can be an array of Any values i,e can have heterogenous values. While the Span attributes can only have an array of homogenous primitive values. This was the reason to keep them separate. I guess the proto uses AnyValue::ArrayValue which can be used to store either of these types of values.

lalitb avatar Sep 13 '23 08:09 lalitb

Ok, this also answers the next question I had, which is whether I should add None to Value as well, the answer is no:

Attribute values of null are not valid and attempting to set a null value is undefined behavior.

FSMaxB avatar Sep 13 '23 08:09 FSMaxB

Is this related? https://github.com/open-telemetry/opentelemetry-specification/pull/3826

hdost avatar Feb 21 '24 09:02 hdost

I think it is related to this one: https://github.com/open-telemetry/opentelemetry-specification/pull/3853

pellared avatar Feb 21 '24 09:02 pellared