-
Notifications
You must be signed in to change notification settings - Fork 657
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
Make event attributes immutable #1195
Merged
lzchen
merged 8 commits into
open-telemetry:master
from
eoinnoble:1038-make-events-immutable
Oct 9, 2020
Merged
Make event attributes immutable #1195
lzchen
merged 8 commits into
open-telemetry:master
from
eoinnoble:1038-make-events-immutable
Oct 9, 2020
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This PR makes it more difficult for someone to edit the attributes of an `Event` once it has been added to a `Span`, as well as adding some regression tests around the other properties of an `Event` to ensure they have similar protections. It isn't particularly straightforward or idiomatic to make objects truly immutable in Python, but if these steps don't go far enough let me know! Fixes open-telemetry#1038
|
lzchen
reviewed
Oct 2, 2020
lzchen
reviewed
Oct 2, 2020
lzchen
requested changes
Oct 2, 2020
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.
Just a few comments
Thanks @lzchen, wasn't sure where to put this code so thanks for clearing that up! |
lzchen
reviewed
Oct 5, 2020
lzchen
approved these changes
Oct 5, 2020
owais
approved these changes
Oct 9, 2020
srikanthccv
pushed a commit
to srikanthccv/opentelemetry-python
that referenced
this pull request
Nov 1, 2020
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This PR makes it more difficult for someone to edit the attributes of an
Event
once it has been added to aSpan
, as well as adding some regression tests around the other properties of anEvent
to ensure they have similar protections.It isn't particularly straightforward or idiomatic to make objects truly immutable in Python, but if these steps don't go far enough let me know!
I don't believe a documentation change is necessary because events are meant to be immutable according to the spec, but this should probably be considered a breaking change in case people were relying on the event attributes being mutable up until now.
Fixes #1038
Type of change
Please delete options that are not relevant.
How Has This Been Tested?
I've added regression tests to:
Event
raise an error when someone directly tries to change them; andattributes
dictionary tuples.I've also added a new test for my change to make sure that an error is raised if someone tryies to directly edit the
attributes
dictionary itself.Checklist: