Skip to content

Commit 4f9257d

Browse files
committed
Merge remote-tracking branch 'origin/master' into potel-base
2 parents 27e9e82 + c210ad6 commit 4f9257d

File tree

8 files changed

+72
-18
lines changed

8 files changed

+72
-18
lines changed

CHANGELOG.md

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

3+
## 2.7.0
4+
5+
- Add `origin` to spans and transactions (#3133) by @antonpirker
6+
- OTel: Set up typing for OTel (#3168) by @sentrivana
7+
- OTel: Auto instrumentation skeleton (#3143) by @sentrivana
8+
- OpenAI: If there is an internal error, still return a value (#3192) by @colin-sentry
9+
- MongoDB: Add MongoDB collection span tag (#3182) by @0Calories
10+
- MongoDB: Change span operation from `db.query` to `db` (#3186) by @0Calories
11+
- MongoDB: Remove redundant command name in query description (#3189) by @0Calories
12+
- Apache Spark: Fix spark driver integration (#3162) by @seyoon-lim
13+
- Apache Spark: Add Spark test suite to tox.ini and to CI (#3199) by @sentrivana
14+
- Codecov: Add failed test commits in PRs (#3190) by @antonpirker
15+
- Update library, Python versions in tests (#3202) by @sentrivana
16+
- Remove Hub from our test suite (#3197) by @antonpirker
17+
- Use env vars for default CA cert bundle location (#3160) by @DragoonAethis
18+
- Create a separate test group for AI (#3198) by @sentrivana
19+
- Add additional stub packages for type checking (#3122) by @Daverball
20+
- Proper naming of requirements files (#3191) by @antonpirker
21+
- Pinning pip because new version does not work with some versions of Celery and Httpx (#3195) by @antonpirker
22+
- build(deps): bump supercharge/redis-github-action from 1.7.0 to 1.8.0 (#3193) by @dependabot
23+
- build(deps): bump actions/checkout from 4.1.6 to 4.1.7 (#3171) by @dependabot
24+
- build(deps): update pytest-asyncio requirement (#3087) by @dependabot
25+
326
## 2.6.0
427

528
- Introduce continuous profiling mode (#2830) by @Zylphrex

docs/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
copyright = "2019-{}, Sentry Team and Contributors".format(datetime.now().year)
2929
author = "Sentry Team and Contributors"
3030

31-
release = "2.6.0"
31+
release = "2.7.0"
3232
version = ".".join(release.split(".")[:2]) # The short X.Y version.
3333

3434

sentry_sdk/consts.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -529,4 +529,4 @@ def _get_default_options():
529529
del _get_default_options
530530

531531

532-
VERSION = "2.6.0"
532+
VERSION = "2.7.0"

sentry_sdk/integrations/django/__init__.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -325,14 +325,10 @@ def sentry_patched_drf_initial(self, request, *args, **kwargs):
325325
def _patch_channels():
326326
# type: () -> None
327327
try:
328-
# Django < 3.0
329328
from channels.http import AsgiHandler # type: ignore
330329
except ImportError:
331-
try:
332-
# DJango 3.0+
333-
from django.core.handlers.asgi import ASGIHandler as AsgiHandler
334-
except ImportError:
335-
return
330+
return
331+
336332
if not HAS_REAL_CONTEXTVARS:
337333
# We better have contextvars or we're going to leak state between
338334
# requests.

sentry_sdk/integrations/django/asgi.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,8 @@ async def sentry_patched_get_response_async(self, request):
134134

135135
def patch_channels_asgi_handler_impl(cls):
136136
# type: (Any) -> None
137-
138137
import channels # type: ignore
138+
139139
from sentry_sdk.integrations.django import DjangoIntegration
140140

141141
if channels.__version__ < "3.0.0":

sentry_sdk/integrations/starlette.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,14 +73,20 @@ class StarletteIntegration(Integration):
7373

7474
transaction_style = ""
7575

76-
def __init__(self, transaction_style="url", failed_request_status_codes=None):
77-
# type: (str, Optional[list[HttpStatusCodeRange]]) -> None
76+
def __init__(
77+
self,
78+
transaction_style="url",
79+
failed_request_status_codes=None,
80+
middleware_spans=True,
81+
):
82+
# type: (str, Optional[list[HttpStatusCodeRange]], bool) -> None
7883
if transaction_style not in TRANSACTION_STYLE_VALUES:
7984
raise ValueError(
8085
"Invalid value for transaction_style: %s (must be in %s)"
8186
% (transaction_style, TRANSACTION_STYLE_VALUES)
8287
)
8388
self.transaction_style = transaction_style
89+
self.middleware_spans = middleware_spans
8490
self.failed_request_status_codes = failed_request_status_codes or [
8591
range(500, 599)
8692
]
@@ -110,7 +116,7 @@ def _enable_span_for_middleware(middleware_class):
110116
async def _create_span_call(app, scope, receive, send, **kwargs):
111117
# type: (Any, Dict[str, Any], Callable[[], Awaitable[Dict[str, Any]]], Callable[[Dict[str, Any]], Awaitable[None]], Any) -> None
112118
integration = sentry_sdk.get_client().get_integration(StarletteIntegration)
113-
if integration is None:
119+
if integration is None or not integration.middleware_spans:
114120
return await old_call(app, scope, receive, send, **kwargs)
115121

116122
middleware_name = app.__class__.__name__

setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def get_file_text(file_name):
2121

2222
setup(
2323
name="sentry-sdk",
24-
version="2.6.0",
24+
version="2.7.0",
2525
author="Sentry Team and Contributors",
2626
author_email="[email protected]",
2727
url="https://github.com/getsentry/sentry-python",
@@ -129,7 +129,7 @@ def get_file_text(file_name):
129129
"sqlalchemy": ["sqlalchemy>=1.2"],
130130
"starlette": ["starlette>=0.19.1"],
131131
"starlite": ["starlite>=1.48"],
132-
"tornado": ["tornado>=5"],
132+
"tornado": ["tornado>=6"],
133133
},
134134
classifiers=[
135135
"Development Status :: 5 - Production/Stable",

tests/integrations/starlette/test_starlette.py

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -637,20 +637,49 @@ def test_middleware_spans(sentry_init, capture_events):
637637

638638
(_, transaction_event) = events
639639

640-
expected = [
640+
expected_middleware_spans = [
641641
"ServerErrorMiddleware",
642642
"AuthenticationMiddleware",
643643
"ExceptionMiddleware",
644+
"AuthenticationMiddleware", # 'op': 'middleware.starlette.send'
645+
"ServerErrorMiddleware", # 'op': 'middleware.starlette.send'
646+
"AuthenticationMiddleware", # 'op': 'middleware.starlette.send'
647+
"ServerErrorMiddleware", # 'op': 'middleware.starlette.send'
644648
]
645649

650+
assert len(transaction_event["spans"]) == len(expected_middleware_spans)
651+
646652
idx = 0
647653
for span in transaction_event["spans"]:
648-
if span["op"] == "middleware.starlette":
649-
assert span["description"] == expected[idx]
650-
assert span["tags"]["starlette.middleware_name"] == expected[idx]
654+
if span["op"].startswith("middleware.starlette"):
655+
assert (
656+
span["tags"]["starlette.middleware_name"]
657+
== expected_middleware_spans[idx]
658+
)
651659
idx += 1
652660

653661

662+
def test_middleware_spans_disabled(sentry_init, capture_events):
663+
sentry_init(
664+
traces_sample_rate=1.0,
665+
integrations=[StarletteIntegration(middleware_spans=False)],
666+
)
667+
starlette_app = starlette_app_factory(
668+
middleware=[Middleware(AuthenticationMiddleware, backend=BasicAuthBackend())]
669+
)
670+
events = capture_events()
671+
672+
client = TestClient(starlette_app, raise_server_exceptions=False)
673+
try:
674+
client.get("/message", auth=("Gabriela", "hello123"))
675+
except Exception:
676+
pass
677+
678+
(_, transaction_event) = events
679+
680+
assert len(transaction_event["spans"]) == 0
681+
682+
654683
def test_middleware_callback_spans(sentry_init, capture_events):
655684
sentry_init(
656685
traces_sample_rate=1.0,

0 commit comments

Comments
 (0)