Skip to content

Commit 141de46

Browse files
committed
Merge branch 'master' into py-2305-add-query-source-to-methods-that-were-missing-it
2 parents 03a3269 + 0e47ead commit 141de46

15 files changed

Lines changed: 217 additions & 54 deletions

File tree

.github/workflows/ai-integration-test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ jobs:
3434
token: ${{ secrets.GITHUB_TOKEN }}
3535

3636
- name: Run Python SDK Tests
37-
uses: getsentry/testing-ai-sdk-integrations@1dd9ee2a2d821f41473fc90809a758e8394c689c
37+
uses: getsentry/testing-ai-sdk-integrations@18229d1da4bb8120ce923bdf7aac00fcf6f38311
3838
env:
3939
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4040
with:

.github/workflows/changelog-preview.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,5 @@ permissions:
1515

1616
jobs:
1717
changelog-preview:
18-
uses: getsentry/craft/.github/workflows/changelog-preview.yml@97d0c4286f32a80d09c8b89366d762fecc3e27b6 # v2
18+
uses: getsentry/craft/.github/workflows/changelog-preview.yml@bae212ca7aec50bb716eafd387c80bcfb28da937 # v2
1919
secrets: inherit

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ jobs:
3131
token: ${{ steps.token.outputs.token }}
3232
fetch-depth: 0
3333
- name: Prepare release
34-
uses: getsentry/craft@97d0c4286f32a80d09c8b89366d762fecc3e27b6 # v2.25.4
34+
uses: getsentry/craft@bae212ca7aec50bb716eafd387c80bcfb28da937 # v2.26.3
3535
env:
3636
GITHUB_TOKEN: ${{ steps.token.outputs.token }}
3737
with:

.github/workflows/validate-pr.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
permissions:
1111
pull-requests: write
1212
steps:
13-
- uses: getsentry/github-workflows/validate-pr@71588ddf95134f804e82c5970a8098588e2eaecd
13+
- uses: getsentry/github-workflows/validate-pr@43bf14b190c12080cfbedf2d2c82337bc559a0e1
1414
with:
1515
app-id: ${{ vars.SDK_MAINTAINER_BOT_APP_ID }}
1616
private-key: ${{ secrets.SDK_MAINTAINER_BOT_PRIVATE_KEY }}

requirements-docs.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
gevent
22
shibuya
33
sphinx<8.2
4-
sphinx-autodoc-typehints[type_comments]>=1.8.0
4+
sphinx-autodoc-typehints[type_comments]>=2.3.0
55
typing-extensions

scripts/populate_tox/config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@
310310
"num_versions": 2,
311311
},
312312
"pydantic_ai": {
313-
"package": "pydantic-ai",
313+
"package": "pydantic-ai-slim",
314314
"deps": {
315315
"*": ["pytest-asyncio"],
316316
},

sentry_sdk/_batcher.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,9 +153,10 @@ def _add_to_envelope(self, envelope: "Envelope") -> None:
153153
},
154154
payload=PayloadRef(
155155
json={
156+
"version": 2,
156157
"items": [
157158
self._to_transport_format(item) for item in self._buffer
158-
]
159+
],
159160
}
160161
),
161162
)

sentry_sdk/_log_batcher.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,12 @@ def _record_lost(self, item: "Log") -> None:
4545
headers={
4646
"item_count": 1,
4747
},
48-
payload=PayloadRef(json={"items": [self._to_transport_format(item)]}),
48+
payload=PayloadRef(
49+
json={
50+
"version": 2,
51+
"items": [self._to_transport_format(item)],
52+
}
53+
),
4954
)
5055

5156
self._record_lost_func(

sentry_sdk/_span_batcher.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,10 +224,11 @@ def _flush(self, only_pending: bool = False) -> None:
224224
},
225225
payload=PayloadRef(
226226
json={
227+
"version": 2,
227228
"items": [
228229
self._to_transport_format(spans[j])
229230
for j in range(start, end)
230-
]
231+
],
231232
}
232233
),
233234
)

sentry_sdk/integrations/asyncpg.py

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
)
1717
from sentry_sdk.utils import (
1818
capture_internal_exceptions,
19-
ensure_integration_enabled,
2019
parse_version,
2120
)
2221

@@ -52,8 +51,12 @@ def setup_once() -> None:
5251
asyncpg.Connection._executemany = _wrap_connection_method(
5352
asyncpg.Connection._executemany, executemany=True
5453
)
55-
asyncpg.Connection.cursor = _wrap_cursor_creation(asyncpg.Connection.cursor)
5654
asyncpg.Connection.prepare = _wrap_connection_method(asyncpg.Connection.prepare)
55+
56+
BaseCursor._bind_exec = _wrap_cursor_method(BaseCursor._bind_exec)
57+
BaseCursor._bind = _wrap_cursor_method(BaseCursor._bind)
58+
BaseCursor._exec = _wrap_cursor_method(BaseCursor._exec)
59+
5760
asyncpg.connect_utils._connect_addr = _wrap_connect_addr(
5861
asyncpg.connect_utils._connect_addr
5962
)
@@ -159,21 +162,26 @@ async def _inner(*args: "Any", **kwargs: "Any") -> "T":
159162
return _inner
160163

161164

162-
def _wrap_cursor_creation(f: "Callable[..., T]") -> "Callable[..., T]":
163-
@ensure_integration_enabled(AsyncPGIntegration, f)
164-
def _inner(*args: "Any", **kwargs: "Any") -> "T": # noqa: N807
165-
query = args[1]
166-
params_list = args[2] if len(args) > 2 else None
165+
def _wrap_cursor_method(
166+
f: "Callable[..., Awaitable[T]]",
167+
) -> "Callable[..., Awaitable[T]]":
168+
async def _inner(*args: "Any", **kwargs: "Any") -> "T":
169+
if sentry_sdk.get_client().get_integration(AsyncPGIntegration) is None:
170+
return await f(*args, **kwargs)
167171

168-
with _record(
169-
None,
170-
query,
171-
params_list,
172+
cursor = args[0]
173+
query = _normalize_query(cursor._query)
174+
with record_sql_queries_supporting_streaming(
175+
cursor=cursor,
176+
query=query,
177+
params_list=None,
178+
paramstyle=None,
172179
executemany=False,
180+
record_cursor_repr=True,
181+
span_origin=AsyncPGIntegration.origin,
173182
) as span:
174-
_set_db_data(span, args[0])
175-
176-
res = f(*args, **kwargs)
183+
_set_db_data(span, cursor._connection)
184+
res = await f(*args, **kwargs)
177185

178186
if isinstance(span, StreamedSpan):
179187
with capture_internal_exceptions():

0 commit comments

Comments
 (0)