-
Notifications
You must be signed in to change notification settings - Fork 569
Sync potel-base with master #4168
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
Merged
Merged
Conversation
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
Handle `None` values in arq configuration gracefully. Fixes #3827
Run `generate-test-files.sh` (this will be automated at some point)
) The URL that works in EC2 does not work in ECS, this can lead to the HTTP request getting stuck. Fixes #2376
Test Sentry AWS Lambda integration locally instead of creating actual Lambda function in AWS: - Create a local AWS Lambda environment using AWS SAM and AWS CDK. (Docker based) - Start a local Sentry server that accepts envelopes. - Run the tests in the local AWS Lambda environment configured with a DSN that tells the SDK to send data to the local Sentry server. - Read the captured envelopes from the local Sentry server to assert their correctness. - Update CI configuration, so AWS tests are now handled the same as test suite matrices of other integrations. There is also a follow-up PR that removes obsolete code handling AWS authentication data: #4076 (This PR will also fix the one failing test) Fixes #2795
Instrumenting asyncio projects can be confusing. Here are two
improvements:
- If users try to init the Sentry SDK outside of an async loop, a
warning message will now printed instructing them how to correctly call
init() in async envrionments. Including a link to the docs.
- During shutdown of Python unfinished async tasks emit an error `Task
was destroyed but it is pending!`. This happens if you use Sentry or
not. The error message is confusing and led people to believe the Sentry
instrumentation caused this problem. This is now remediated by
- The tasks is wrapped by Sentry, but we now **set the name of the
wrapped task to include the original** and (and a hint that is has been
wrapped by Sentry) to show that the original task is failing, not just
some Sentry task unknown to the user.
- When shutting down a **info message** is printed, informing that there
could be `Task was destroyed but it is pending!` but that those are OK
and not a problem with the users code or Sentry.
Before this PR the users saw this during shutdown:
```
Exception ignored in: <coroutine object patch_asyncio.<locals>._sentry_task_factory.<locals>._coro_creating_hub_and_span at 0x103ae84f0>
Traceback (most recent call last):
File "/Users/antonpirker/code/sentry-python/sentry_sdk/integrations/asyncio.py", line 46, in _coro_creating_hub_and_span
with sentry_sdk.isolation_scope():
File "/Users/antonpirker/.pyenv/versions/3.12.3/lib/python3.12/contextlib.py", line 158, in __exit__
self.gen.throw(value)
File "/Users/antonpirker/code/sentry-python/sentry_sdk/scope.py", line 1732, in isolation_scope
_current_scope.reset(current_token)
ValueError: <Token var=<ContextVar name='current_scope' default=None at 0x102a87f60> at 0x103b1cfc0> was created in a different Context
Task was destroyed but it is pending!
task: <Task cancelling name='Task-2' coro=<patch_asyncio.<locals>._sentry_task_factory.<locals>._coro_creating_hub_and_span() done, defined at /Users/antonpirker/code/sentry-python/sentry_sdk/integrations/asyncio.py:42> wait_for=<Future pending cb=[Task.task_wakeup()]> cb=[gather.<locals>._done_callback() at /Users/antonpirker/.pyenv/versions/3.12.3/lib/python3.12/asyncio/tasks.py:767]>
```
With this PR the users will see this during shutdown:
Note the INFO message on top and also the task name on the bottom.
```
[sentry] INFO: AsyncIO is shutting down. If you see 'Task was destroyed but it is pending!' errors with '_task_with_sentry_span_creation', these are normal during shutdown and not a problem with your code or Sentry.
Exception ignored in: <coroutine object patch_asyncio.<locals>._sentry_task_factory.<locals>._task_with_sentry_span_creation at 0x1028fc4f0>
Traceback (most recent call last):
File "/Users/antonpirker/code/sentry-python/sentry_sdk/integrations/asyncio.py", line 62, in _task_with_sentry_span_creation
with sentry_sdk.isolation_scope():
File "/Users/antonpirker/.pyenv/versions/3.12.3/lib/python3.12/contextlib.py", line 158, in __exit__
self.gen.throw(value)
File "/Users/antonpirker/code/sentry-python/sentry_sdk/scope.py", line 1732, in isolation_scope
_current_scope.reset(current_token)
ValueError: <Token var=<ContextVar name='current_scope' default=None at 0x10193ff10> at 0x1029710c0> was created in a different Context
Task was destroyed but it is pending!
task: <Task cancelling name='long_running_task (Sentry-wrapped)' coro=<patch_asyncio.<locals>._sentry_task_factory.<locals>._task_with_sentry_span_creation() done, defined at /Users/antonpirker/code/sentry-python/sentry_sdk/integrations/asyncio.py:58> wait_for=<Future pending cb=[Task.task_wakeup()]> cb=[gather.<locals>._done_callback() at /Users/antonpirker/.pyenv/versions/3.12.3/lib/python3.12/asyncio/tasks.py:767]>
```
Fixes #2908
Improves #2333
This gives us a way to locally run and test our AWS Lambda integration, without needing a real AWS Lambda account. This should make development of AWS Lambda support better. --------- Co-authored-by: Ivana Kellyer <ivana.kellyer@sentry.io>
Nice rendering of log messages containing parameters that are `None` values does not work. There we coerce `None` values into strings to have nicer messages in Sentry UI. Fixes #3660
`request.route` can throw a `RuntimeError: This request is not connected to a route.`. Closes #3583
See #2709 (comment) If `quart_flask_patch` is imported, it monkeypatches stuff so that the Quart app appears to be a Flask app. This confuses our Flask integration, which tries to enable itself and fails. This commit: - Makes the Flask integration detect that what it sees as Flask might actually be Quart. - Reorganizes the Quart test suite a little to allow to test this case (a bit tricky since `import quart_flask_patch` needs to happen before anything else due to its monkeypatching nature). Closes #2709
We only check `logger.handlers` for existing handlers. This ignores any potential parent handlers. By using `hasHandlers()` ([docs](https://docs.python.org/3/library/logging.html#logging.Logger.hasHandlers)) instead we take those into account as well. Closes #3944
Dusting off our Readme a bit. It has been quite some time since it was last updated.
Logs are coming to sentry!
This commit:
- Adds `sentry_sdk._experimental_logger.{info, warn, ...}` methods
- Adds `_experimental` options for `before_send_log` and `enable_sentry_logs`
There are no tests (yet), and this still uses the otel_log schema.
Example usage:
```python
sentry_sdk.init(
dsn=...,
_experiments={"enable_sentry_logs": True},
)
from sentry_sdk import _experimental_logger as sentry_logger
sentry_logger.info('Finished sending answer! #chunks={num_chunks}', num_chunks=10)
```
---------
Co-authored-by: Anton Pirker <anton.pirker@sentry.io>
The `Baggage` class does not enforce mutability. Document this to avoid confusion. <!-- Describe your PR here --> --- Thank you for contributing to `sentry-python`! Please add tests to validate your changes, and lint your code using `tox -e linters`. Running the test suite on your PR might require maintainer approval. The AWS Lambda tests additionally require a maintainer to add a special label, and they will fail until this label is added. Co-authored-by: Anton Pirker <anton.pirker@sentry.io>
….6 (#4113) Bumps [actions/create-github-app-token](https://github.com/actions/create-github-app-token) from 1.11.5 to 1.11.6. <details> <summary>Release notes</summary> <p><em>Sourced from <a href="https://github.com/actions/create-github-app-token/releases">actions/create-github-app-token's releases</a>.</em></p> <blockquote> <h2>v1.11.6</h2> <h2><a href="https://github.com/actions/create-github-app-token/compare/v1.11.5...v1.11.6">1.11.6</a> (2025-03-03)</h2> <h3>Bug Fixes</h3> <ul> <li><strong>deps:</strong> bump the production-dependencies group with 2 updates (<a href="https://redirect.github.com/actions/create-github-app-token/issues/210">#210</a>) (<a href="https://github.com/actions/create-github-app-token/commit/1ff1dea6a9d1de5b4795e5314291e04acc63c38b">1ff1dea</a>)</li> </ul> </blockquote> </details> <details> <summary>Commits</summary> <ul> <li><a href="https://github.com/actions/create-github-app-token/commit/21cfef2b496dd8ef5b904c159339626a10ad380e"><code>21cfef2</code></a> build(release): 1.11.6 [skip ci]</li> <li><a href="https://github.com/actions/create-github-app-token/commit/1ff1dea6a9d1de5b4795e5314291e04acc63c38b"><code>1ff1dea</code></a> fix(deps): bump the production-dependencies group with 2 updates (<a href="https://redirect.github.com/actions/create-github-app-token/issues/210">#210</a>)</li> <li>See full diff in <a href="https://github.com/actions/create-github-app-token/compare/0d564482f06ca65fa9e77e2510873638c82206f2...21cfef2b496dd8ef5b904c159339626a10ad380e">compare view</a></li> </ul> </details> <br /> [](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. [//]: # (dependabot-automerge-start) [//]: # (dependabot-automerge-end) --- <details> <summary>Dependabot commands and options</summary> <br /> You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot show <dependency name> ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself) </details> Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Anton Pirker <anton.pirker@sentry.io>
In Starlette/FastAPI you're able to create subapps. When using `transaction_style="url"` in our integration, this would throw an exception because we try to access `route.path` to determine the transaction name, but `Host` routes have no `path` attribute. Closes #2631
Regular `tox.ini` update
Loguru has two message levels `TRACE` and `SUCCESS` that are not available in Sentry breadcrumbs. This PR maps `TRACE` to `debug` and `SUCCESS` to `info` in Sentry so those breadcrumbs do not show a confusing error message in the Sentry UI. Fixes #2759
Small typo fix
…event (#4142) Imagine an app throws an exception twice, from different places. The first exception is dropped in the user's `before_send`. The second exception is not. Should the second exception appear in Sentry? The current state is that it won't, since `DedupeIntegration` will take the first, dropped exception into account. When encountering the second exception, it'll consider it a duplicate and will drop it, even though the first exception never made it to Sentry. In this PR, we reset `DedupeIntegration`'s `last-seen` if an event has been dropped by `before_send`, ensuring that the next exception will be reported. Closes #371 --------- Co-authored-by: Anton Pirker <anton.pirker@sentry.io>
❌ 903 Tests Failed:
View the top 3 failed test(s) by shortest run time
To view more test analytics, go to the Test Analytics Dashboard |
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.
No description provided.