-
Notifications
You must be signed in to change notification settings - Fork 894
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
Define null
as a valid attribute value
#971
Define null
as a valid attribute value
#971
Conversation
The protobuf does but I'm not sure the protocol allows it, i.e., if consumers are prepared. |
@arminru I don't think this resolves the initial issue, for example let's assume an API I feel that |
To clarify, I am not against adding the new type null, but I think just that the issue with null String in Java is not resolved |
Why not? Do we really need to distinguish null strings from null string arrays? |
To clarify: Even if we accept nulls, I'm strongly against distinguishing nulls of different types in our data model. Also, even in Java, |
Think about the API not the exporting value (where indeed you probably no longer know if that supposed to be a string or a array). Can you please write the API in Java for example and I will show you that you have 3-4 ways to record null which is strange |
You would indeed have multiple options to record a null value in Java but if the doc clearly states that the different types are not distinguished in case of null, I don't see this as problematic. I would rather have the option to pass a null String to the overload accepting Strings and likewise for arrays rather than only accepting null in one single API. This would force users to do something like I think it is fine to state that the type of null (in languages that have this in their type system) is not preserved and will not be distinguished by exporters. I don't see any benefit in preserving the type, if any, for consumers. They either expect a particular type if it's a well-known attribute for which a semantic convention exists, and will know what "kind" of null this is or it's an attribute with unknown semantics anyway and then the type of null won't matter. |
@bogdandrutu I stated more explicitly in 8875058 that implementations may and exporters should ignore different types of null. If SIGs decide that they preserve the value for any reason (e.g., because it's just easier to implement or more canonical in that language), it should be fine IMHO but there should not be any need to do so. Exporters must have the option to discard the type, since OTLP, for example, does not support specifying a type when expressing an attribute value of null and it is not expected to have any semantic difference. |
My preference is to try to maybe keep the type if possible (semantic conventions also use types). So having a SetNullAtrribute is fine because we want to support null, but for SetStringAttribute I was thinking to default to empty string if null is passed (like protobufs), and preserve the type. |
So you would like to change the existing types in the data model to allow an additional value of null, rather than adding a new null type? |
Note that in JS, Python, Ruby, |
@bogdandrutu Apart from that, what is the motivation of preserving the type? I'd rather keep the current wording allowing implementations to drop the type. We don't define any semantic difference for the "type" of null, it's not part of the type system in some languages and not supported by OTLP. I also think that - given we deem null a valid value - accepting it for each overload where null can be expressed is just natural and not undesirable. I don't think we should just assume an empty string if a null string is passed since that does indeed make a semantic difference (value not available/retrieved vs. value is verified to be an empty string). Same for false/0/empty array. Adding an API |
Let me write down how I read the current specs proposal:
This will make me thing we need a
This is very interesting text, and may lead to unexpected behaviors. I may be wrong, but for me personally it is strange that the next two examples are equivalent (and maybe inconsistent across languages): String val = null
span.SetStringAttribute("my_key", val) span.SetNullAttribute("my_key") I am worried that this may lead to strange usages of the API, and may be something we will regret later (maybe I am too conservative). One interesting inconsistency is different between languages, go for example does not have |
I think from the discussion on the issue, we'd indeed need a We could, however, explicitly call out that no dedicated way to generate a null value should be provided and nulls values should only be recoded if they naturally occur, and semantic conventions should never prescribe any meaning to null (that is different from "not set"). That way, we would have the null attribute type purely as a debugging aid. Personally, I'd prefer that. |
@bogdandrutu Since we don't attribute any semantic difference to a null of type string and a null of no type, I don't see any problem with these two calls being equivalent. Could you please elaborate what bothers you about that?
I'm fine with both but would personally also prefer this over adding an explicit If I follow the discussion on #797 correctly, the concerns about the current spec were more about an inconsistent implicit API to delete attributes using null (where available) rather than actually having the desire to express a meaningful null value in languages where this cannot occur naturally but would have to be recorded using an "artificial" |
If there are concerns about allowing My main beef is that "delete" requirement. |
@tigrannajaryan I considered that as well but thought it would be better to have a defined behavior that is consistent across implementations rather than declaring it as undefined since it might be common enough to happen if one does not explicitly add null checks. While having the delete semantics as error handling is well documented, I agree that it might not be the least surprising behavior. |
null
as a valid span attribute valuenull
as a valid attribute value
Resolves #797.
Closes #992.
See #992 for an alternative proposal.
Changes
Specifies
null
as a valid attribute value.As a consequence, attempting to set
null
no longer removes a previously set attribute but overwrites it withnull
.Exporters will have to be adapted accordingly. OTLP already supports specifying null values (see common.proto).