-
Notifications
You must be signed in to change notification settings - Fork 624
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
Add __contains__ to TraceState #1773
Conversation
Having this prevents accidentally assuming it's present and will work as expected.
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.
This fixes the issue, approving.
That being said, I think we should instead subclass TraceState from OrderedDict
so that we don't have to keep adding these methods by hand. If we want to avoid items being set, we can raise a proper exception in __setitem__
.
As @lonewolf3739 suggested, this is the actual fix, it should raise `KeyError` rather than return `None`.
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.
LGTM. Suggested small change.
That broken test seems unrelated, especially since it passed other times, but let me know if there's something I can do. |
Pypy has this behavior sometimes, I am running the tests in this PR again 👍 |
Description
Adds
__contains__
toTraceState
- having this prevents accidentally assuming it's present and will work as expected.This actually fixes a bug reported in the contrib repo: open-telemetry/opentelemetry-python-contrib#262 and possibly others.
Type of change
Please delete options that are not relevant.
How Has This Been Tested?
Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration
TestTraceContextFormat.test_trace_contains
Does This PR Require a Contrib Repo Change?
Checklist: