-
Notifications
You must be signed in to change notification settings - Fork 667
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
Freeze sequence-valued span attributes #449
Conversation
Codecov Report
@@ Coverage Diff @@
## master #449 +/- ##
=======================================
Coverage 89.64% 89.65%
=======================================
Files 43 43
Lines 2240 2242 +2
Branches 248 249 +1
=======================================
+ Hits 2008 2010 +2
Misses 159 159
Partials 73 73
Continue to review full report at Codecov.
|
Seems an expensive defense 😃 |
I don't have a dog in this fight, just trying to close some old PRs. I'm happy to require immutable sequence attribute args instead or agree that the cost isn't worth the protection here. |
If this is of any help, we can also declare a class that implements an immutable sequence: class ImmutableSequence:
def __init__(self, sequence):
self._sequence = sequence
def __getitem__(self, index):
return self._sequence[index] Then, instead of taking a sequence and casting it to tuple (which is the slow part), we can just use it to instantiate an |
I think this is the main problem we want to protect against here though. |
So does anyone have an opinion on this PR? |
This was @toumorokoshi's issue from #348 and #352. I'd prefer to merge this and revisit later if this ends up being a bottleneck. #352 (comment) suggests it won't be, and FWIW users can still call |
I'd prefer to have this check in here now, and prevent as many erroneous uses as possible. In the future we can potentially remove this. We already have validation of the span attributes in the repo as an additional defense. I guess I'm of the opinion of making this interface as defensive as possible. we should probably have benchmarks to bring here. This isn't the most time-sensitive PR, so I'll try to bring that here. Although we should also have a clearer idea of what we actually want our target overhead to be. otherwise the argument is too qualitative. |
I don't have a strong opinion here, I'm slightly leaned toward having it, if we find it is very expensive during a follow up optimization we can remove it. The thing that worries me now is that we have to guarantee that this validation is uniform across all places where attributes are used. For instance, now attributes validation is only done on |
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.
Thanks for the reimplementation!
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.
Better to have this check for now. If during an optimization pass we find it is to expensive we can remove it.
…#449) * fix: allow recording links only at Span creation time * fix: build
Re-implements #401 as the original author didn't sign the CLA before going MIA.