-
Notifications
You must be signed in to change notification settings - Fork 471
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
fix(api): Fix tracing TypeError for static and class methods #2559
Merged
Merged
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
3909e91
Fix static/class method tracing
szokeasaurusrex 166a410
Add tests, fix classmethod
szokeasaurusrex bfcaa58
Merge branch 'master' into szokeasaurusrex/fastapi-typeerror
szokeasaurusrex 5ce591a
Fix Python 2
szokeasaurusrex a17e04a
Merge branch 'master' into szokeasaurusrex/fastapi-typeerror
sentrivana 2e815cb
Restructure tracing decorator tests
szokeasaurusrex 056b30a
Rename decorator tests
szokeasaurusrex 38138cc
Restore incorrectly deleted file
szokeasaurusrex 8a99a8b
Delete incorrectly renamed file
szokeasaurusrex 94bb77c
Rename py3 decorator test
szokeasaurusrex 419628e
Correct decorator tests for new file name
szokeasaurusrex bd5d43e
Fix CI errors
szokeasaurusrex 20c17c4
Removed unused `type: ignore` comments
szokeasaurusrex 7d064f3
Fix test failures (hopefully)
szokeasaurusrex 40cb9ca
Change `assert_called_once` to `assert_called_once_with`
szokeasaurusrex d296a32
Change to call_count check
szokeasaurusrex e2b915d
Only use `__qualname__` in Python 3
szokeasaurusrex 1628160
Correcting typo
szokeasaurusrex File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
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 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 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 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 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
from unittest import mock | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This file moved from |
||
import pytest | ||
import sys | ||
|
||
from tests.conftest import patch_start_tracing_child | ||
|
||
from sentry_sdk.tracing_utils_py3 import ( | ||
start_child_span_decorator as start_child_span_decorator_py3, | ||
) | ||
from sentry_sdk.utils import logger | ||
|
||
if sys.version_info < (3, 6): | ||
pytest.skip("Async decorator only works on Python 3.6+", allow_module_level=True) | ||
|
||
|
||
async def my_async_example_function(): | ||
return "return_of_async_function" | ||
|
||
|
||
@pytest.mark.asyncio | ||
async def test_trace_decorator_async_py3(): | ||
with patch_start_tracing_child() as fake_start_child: | ||
result = await my_async_example_function() | ||
fake_start_child.assert_not_called() | ||
assert result == "return_of_async_function" | ||
|
||
result2 = await start_child_span_decorator_py3(my_async_example_function)() | ||
fake_start_child.assert_called_once_with( | ||
op="function", | ||
description="test_decorator_async_py3.my_async_example_function", | ||
) | ||
assert result2 == "return_of_async_function" | ||
|
||
|
||
@pytest.mark.asyncio | ||
async def test_trace_decorator_async_py3_no_trx(): | ||
with patch_start_tracing_child(fake_transaction_is_none=True): | ||
with mock.patch.object(logger, "warning", mock.Mock()) as fake_warning: | ||
result = await my_async_example_function() | ||
fake_warning.assert_not_called() | ||
assert result == "return_of_async_function" | ||
|
||
result2 = await start_child_span_decorator_py3(my_async_example_function)() | ||
fake_warning.assert_called_once_with( | ||
"Can not create a child span for %s. " | ||
"Please start a Sentry transaction before calling this function.", | ||
"test_decorator_async_py3.my_async_example_function", | ||
) | ||
assert result2 == "return_of_async_function" |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
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.
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.
mypy
was complaining about thetype: ignore
comments in this file, so I had to make changes here, even though the changes are unrelated to the rest of the PR