Add __contains__ to TraceState#1773
Merged
lzchen merged 8 commits intoopen-telemetry:mainfrom Apr 16, 2021
Merged
Conversation
added 3 commits
April 14, 2021 14:49
Having this prevents accidentally assuming it's present and will work as expected.
Closed
5 tasks
ocelotl
approved these changes
Apr 14, 2021
Contributor
ocelotl
left a comment
There was a problem hiding this comment.
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__.
srikanthccv
reviewed
Apr 15, 2021
As @lonewolf3739 suggested, this is the actual fix, it should raise `KeyError` rather than return `None`.
srikanthccv
approved these changes
Apr 15, 2021
Member
srikanthccv
left a comment
There was a problem hiding this comment.
LGTM. Suggested small change.
Contributor
Author
|
That broken test seems unrelated, especially since it passed other times, but let me know if there's something I can do. |
Contributor
Pypy has this behavior sometimes, I am running the tests in this PR again 👍 |
lzchen
approved these changes
Apr 16, 2021
codeboten
pushed a commit
to codeboten/opentelemetry-python
that referenced
this pull request
Apr 16, 2021
This file contains hidden or 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
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
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_containsDoes This PR Require a Contrib Repo Change?
Checklist: