-
Notifications
You must be signed in to change notification settings - Fork 631
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
AttributeValues accepting a list could lead to invalid types being added #352
Comments
We could accept any sequence and copy all of its values in a tuple when we store them. Does the OpenTelemetry specification says anything about sequences that hold sequences themselves? |
@ocelotl I was wondering that when implementing attribute validation. The OT spec says:
Since the array values must all be of a primitive values, this seems to indicate that a list of lists is invalid. |
Correct, there should not be sequences of sequences. 👍 |
I don't think we need to make the SDK completely fool-proof. Checking list values on every |
@Oberon00 looks like you're looking at #348, which is a good venue to discuss the choice of validation at all. looks like there's roughly a 183ns cost to including this in the trace construction, at the gain of immutability. I think there's merit to make this change:
I'll put help wanted on this, as it's a good starter task. |
I can take this |
Created a PR here, PTAL https://github.com/open-telemetry/opentelemetry-python/pull/678/files |
This PR addresses issue #352 Validates attribute values and events upon span creation and setting attributes on spans. Validation logic involves checking if value is one of (int, float, str, bool, list), and if list, each element must be valid and must be all the same primitive, valid type list values will not contain nested lists If value is a list, grants immutable property by converting value to a tuple.
This PR addresses issue open-telemetry#352 Validates attribute values and events upon span creation and setting attributes on spans. Validation logic involves checking if value is one of (int, float, str, bool, list), and if list, each element must be valid and must be all the same primitive, valid type list values will not contain nested lists If value is a list, grants immutable property by converting value to a tuple.
This PR addresses issue open-telemetry#352 Validates attribute values and events upon span creation and setting attributes on spans. Validation logic involves checking if value is one of (int, float, str, bool, list), and if list, each element must be valid and must be all the same primitive, valid type list values will not contain nested lists If value is a list, grants immutable property by converting value to a tuple.
closes open-telemetry#351 Signed-off-by: Olivier Albertini <olivier.albertini@montreal.ca>
#348 is tackling validation for attribute values, of which list is one of them. However, lists can be mutated as long as someone has a handle, so one could potentially misuse the Span api by mutating lists afterward.
The purpose of adding validation during the setting of span attributes was to remove the need to perform such validations in the exporters themselves.
Should we freeze lists as they come in? or should we potentially just allow tuples rather than lists as attribute values?
The text was updated successfully, but these errors were encountered: