Skip to content

Commit 896fcb7

Browse files
authored
Merge branch 'master' into txiao/feat/set-active-thread-id-for-quart
2 parents 073e658 + 72455f4 commit 896fcb7

34 files changed

+1238
-218
lines changed

.github/workflows/test-common.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ jobs:
2929
# ubuntu-20.04 is the last version that supported python3.6
3030
# see https://github.com/actions/setup-python/issues/544#issuecomment-1332535877
3131
os: [ubuntu-20.04]
32-
python-version: ["2.7", "3.5", "3.6", "3.7", "3.8", "3.9", "3.10"]
32+
python-version: ["2.7", "3.5", "3.6", "3.7", "3.8", "3.9", "3.10", "3.11"]
3333
services:
3434
postgres:
3535
image: postgres
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
name: Test huey
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
- release/**
8+
9+
pull_request:
10+
11+
# Cancel in progress workflows on pull_requests.
12+
# https://docs.github.com/en/actions/using-jobs/using-concurrency#example-using-a-fallback-value
13+
concurrency:
14+
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
15+
cancel-in-progress: true
16+
17+
permissions:
18+
contents: read
19+
20+
env:
21+
BUILD_CACHE_KEY: ${{ github.sha }}
22+
CACHED_BUILD_PATHS: |
23+
${{ github.workspace }}/dist-serverless
24+
25+
jobs:
26+
test:
27+
name: huey, python ${{ matrix.python-version }}, ${{ matrix.os }}
28+
runs-on: ${{ matrix.os }}
29+
timeout-minutes: 45
30+
31+
strategy:
32+
fail-fast: false
33+
matrix:
34+
python-version: ["2.7","3.5","3.6","3.7","3.8","3.9","3.10","3.11"]
35+
# python3.6 reached EOL and is no longer being supported on
36+
# new versions of hosted runners on Github Actions
37+
# ubuntu-20.04 is the last version that supported python3.6
38+
# see https://github.com/actions/setup-python/issues/544#issuecomment-1332535877
39+
os: [ubuntu-20.04]
40+
41+
steps:
42+
- uses: actions/checkout@v3
43+
- uses: actions/setup-python@v4
44+
with:
45+
python-version: ${{ matrix.python-version }}
46+
47+
- name: Setup Test Env
48+
run: |
49+
pip install codecov "tox>=3,<4"
50+
51+
- name: Test huey
52+
timeout-minutes: 45
53+
shell: bash
54+
run: |
55+
set -x # print commands that are executed
56+
coverage erase
57+
58+
./scripts/runtox.sh "${{ matrix.python-version }}-huey" --cov=tests --cov=sentry_sdk --cov-report= --cov-branch
59+
coverage combine .coverage*
60+
coverage xml -i
61+
codecov --file coverage.xml
62+
63+
check_required_tests:
64+
name: All huey tests passed or skipped
65+
needs: test
66+
# Always run this, even if a dependent job failed
67+
if: always()
68+
runs-on: ubuntu-20.04
69+
steps:
70+
- name: Check for failures
71+
if: contains(needs.test.result, 'failure')
72+
run: |
73+
echo "One of the dependent jobs have failed. You may need to re-run it." && exit 1

CHANGELOG.md

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,115 @@
11
# Changelog
22

3+
## 1.15.0
4+
5+
### Various fixes & improvements
6+
7+
- New: Add [Huey](https://huey.readthedocs.io/en/latest/) Integration (#1555) by @Zhenay
8+
9+
This integration will create performance spans when Huey tasks will be enqueued and when they will be executed.
10+
11+
Usage:
12+
13+
Task definition in `demo.py`:
14+
15+
```python
16+
import time
17+
18+
from huey import SqliteHuey, crontab
19+
20+
import sentry_sdk
21+
from sentry_sdk.integrations.huey import HueyIntegration
22+
23+
sentry_sdk.init(
24+
dsn="...",
25+
integrations=[
26+
HueyIntegration(),
27+
],
28+
traces_sample_rate=1.0,
29+
)
30+
31+
huey = SqliteHuey(filename='/tmp/demo.db')
32+
33+
@huey.task()
34+
def add_numbers(a, b):
35+
return a + b
36+
```
37+
38+
Running the tasks in `run.py`:
39+
40+
```python
41+
from demo import add_numbers, flaky_task, nightly_backup
42+
43+
import sentry_sdk
44+
from sentry_sdk.integrations.huey import HueyIntegration
45+
from sentry_sdk.tracing import TRANSACTION_SOURCE_COMPONENT, Transaction
46+
47+
48+
def main():
49+
sentry_sdk.init(
50+
dsn="...",
51+
integrations=[
52+
HueyIntegration(),
53+
],
54+
traces_sample_rate=1.0,
55+
)
56+
57+
with sentry_sdk.start_transaction(name="testing_huey_tasks", source=TRANSACTION_SOURCE_COMPONENT):
58+
r = add_numbers(1, 2)
59+
60+
if __name__ == "__main__":
61+
main()
62+
```
63+
64+
- Profiling: Do not send single sample profiles (#1879) by @Zylphrex
65+
- Profiling: Add additional test coverage for profiler (#1877) by @Zylphrex
66+
- Profiling: Always use builtin time.sleep (#1869) by @Zylphrex
67+
- Profiling: Defaul in_app decision to None (#1855) by @Zylphrex
68+
- Profiling: Remove use of threading.Event (#1864) by @Zylphrex
69+
- Profiling: Enable profiling on all transactions (#1797) by @Zylphrex
70+
- FastAPI: Fix check for Starlette in FastAPI integration (#1868) by @antonpirker
71+
- Flask: Do not overwrite default for username with email address in FlaskIntegration (#1873) by @homeworkprod
72+
- Tests: Add py3.11 to test-common (#1871) by @Zylphrex
73+
- Fix: Don't log whole event in before_send / event_processor drops (#1863) by @sl0thentr0py
74+
75+
## 1.14.0
76+
77+
### Various fixes & improvements
78+
79+
- Add `before_send_transaction` (#1840) by @antonpirker
80+
81+
Adds a hook (similar to `before_send`) that is called for all transaction events (performance releated data).
82+
83+
Usage:
84+
85+
```python
86+
import sentry_sdk
87+
88+
def strip_sensitive_data(event, hint):
89+
# modify event here (or return `None` if you want to drop the event entirely)
90+
return event
91+
92+
sentry_sdk.init(
93+
# ...
94+
before_send_transaction=strip_sensitive_data,
95+
)
96+
```
97+
98+
See also: https://docs.sentry.io/platforms/python/configuration/filtering/#using-platformidentifier-namebefore-send-transaction-
99+
100+
- Django: Always remove values of Django session related cookies. (#1842) by @antonpirker
101+
- Profiling: Enable profiling for ASGI frameworks (#1824) by @Zylphrex
102+
- Profiling: Better gevent support (#1822) by @Zylphrex
103+
- Profiling: Add profile context to transaction (#1860) by @Zylphrex
104+
- Profiling: Use co_qualname in python 3.11 (#1831) by @Zylphrex
105+
- OpenTelemetry: fix Use dict for sentry-trace context instead of tuple (#1847) by @AbhiPrasad
106+
- OpenTelemetry: fix extra dependency (#1825) by @bernardotorres
107+
- OpenTelemetry: fix NoOpSpan updates scope (#1834) by @Zylphrex
108+
- OpenTelemetry: Make sure to noop when there is no DSN (#1852) by @antonpirker
109+
- FastAPI: Fix middleware being patched multiple times (#1841) by @JohnnyDeuss
110+
- Starlette: Avoid import of pkg_resource with Starlette integration (#1836) by @mgu
111+
- Removed code coverage target (#1862) by @antonpirker
112+
3113
## 1.13.0
4114

5115
### Various fixes & improvements

codecov.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ coverage:
55
patch:
66
default: false
77
python:
8-
target: 90%
8+
target: 65%
99
comment: false
1010
ignore:
1111
- "tests"

docs/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
copyright = "2019, Sentry Team and Contributors"
3030
author = "Sentry Team and Contributors"
3131

32-
release = "1.13.0"
32+
release = "1.15.0"
3333
version = ".".join(release.split(".")[:2]) # The short X.Y version.
3434

3535

mypy.ini

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,3 +63,5 @@ disallow_untyped_defs = False
6363
ignore_missing_imports = True
6464
[mypy-flask.signals]
6565
ignore_missing_imports = True
66+
[mypy-huey.*]
67+
ignore_missing_imports = True

sentry_sdk/client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ def _prepare_event(
241241
with capture_internal_exceptions():
242242
new_event = before_send(event, hint or {})
243243
if new_event is None:
244-
logger.info("before send dropped event (%s)", event)
244+
logger.info("before send dropped event")
245245
if self.transport:
246246
self.transport.record_lost_event(
247247
"before_send", data_category="error"
@@ -254,7 +254,7 @@ def _prepare_event(
254254
with capture_internal_exceptions():
255255
new_event = before_send_transaction(event, hint or {})
256256
if new_event is None:
257-
logger.info("before send transaction dropped event (%s)", event)
257+
logger.info("before send transaction dropped event")
258258
if self.transport:
259259
self.transport.record_lost_event(
260260
"before_send", data_category="transaction"

sentry_sdk/consts.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@
4444
DEFAULT_QUEUE_SIZE = 100
4545
DEFAULT_MAX_BREADCRUMBS = 100
4646

47+
SENSITIVE_DATA_SUBSTITUTE = "[Filtered]"
48+
4749

4850
class INSTRUMENTER:
4951
SENTRY = "sentry"
@@ -70,6 +72,8 @@ class OP:
7072
QUEUE_SUBMIT_CELERY = "queue.submit.celery"
7173
QUEUE_TASK_CELERY = "queue.task.celery"
7274
QUEUE_TASK_RQ = "queue.task.rq"
75+
QUEUE_SUBMIT_HUEY = "queue.submit.huey"
76+
QUEUE_TASK_HUEY = "queue.task.huey"
7377
SUBPROCESS = "subprocess"
7478
SUBPROCESS_WAIT = "subprocess.wait"
7579
SUBPROCESS_COMMUNICATE = "subprocess.communicate"
@@ -142,4 +146,4 @@ def _get_default_options():
142146
del _get_default_options
143147

144148

145-
VERSION = "1.13.0"
149+
VERSION = "1.15.0"

sentry_sdk/hub.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from sentry_sdk.consts import INSTRUMENTER
99
from sentry_sdk.scope import Scope
1010
from sentry_sdk.client import Client
11+
from sentry_sdk.profiler import Profile
1112
from sentry_sdk.tracing import NoOpSpan, Span, Transaction
1213
from sentry_sdk.session import Session
1314
from sentry_sdk.utils import (
@@ -548,6 +549,9 @@ def start_transaction(
548549
sampling_context.update(custom_sampling_context)
549550
transaction._set_initial_sampling_decision(sampling_context=sampling_context)
550551

552+
profile = Profile(transaction, hub=self)
553+
profile._set_initial_sampling_decision(sampling_context=sampling_context)
554+
551555
# we don't bother to keep spans if we already know we're not going to
552556
# send the transaction
553557
if transaction.sampled:

sentry_sdk/integrations/asgi.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
from sentry_sdk.hub import Hub, _should_send_default_pii
1515
from sentry_sdk.integrations._wsgi_common import _filter_headers
1616
from sentry_sdk.integrations.modules import _get_installed_modules
17-
from sentry_sdk.profiler import start_profiling
1817
from sentry_sdk.sessions import auto_session_tracking
1918
from sentry_sdk.tracing import (
2019
SOURCE_FOR_STYLE,
@@ -176,7 +175,7 @@ async def _run_app(self, scope, callback):
176175

177176
with hub.start_transaction(
178177
transaction, custom_sampling_context={"asgi_scope": scope}
179-
), start_profiling(transaction, hub):
178+
):
180179
# XXX: Would be cool to have correct span status, but we
181180
# would have to wrap send(). That is a bit hard to do with
182181
# the current abstraction over ASGI 2/3.

0 commit comments

Comments
 (0)