Skip to content

Commit 70a348f

Browse files
merge master
2 parents 645aaa3 + 6b7982f commit 70a348f

51 files changed

Lines changed: 3292 additions & 1727 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.github/workflows/test-integrations-network.yml‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,10 @@ jobs:
4141
run: |
4242
set -x # print commands that are executed
4343
./scripts/runtox.sh "py${{ matrix.python-version }}-grpc"
44-
- name: Test httpx
44+
- name: Test httpx0
4545
run: |
4646
set -x # print commands that are executed
47-
./scripts/runtox.sh "py${{ matrix.python-version }}-httpx"
47+
./scripts/runtox.sh "py${{ matrix.python-version }}-httpx0"
4848
- name: Test httpx2
4949
run: |
5050
set -x # print commands that are executed

‎CHANGELOG.md‎

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

3+
## 2.69.1
4+
5+
### New Features ✨
6+
7+
- (django) Add `http.route` attribute by @alexander-alderman-webb in [#7428](https://github.com/getsentry/sentry-python/pull/7428)
8+
9+
### Bug Fixes 🐛
10+
11+
- (aiohttp) Preserve SigV4-signed propagation headers by @Robinbinu in [#7427](https://github.com/getsentry/sentry-python/pull/7427)
12+
13+
### Internal Changes 🔧
14+
15+
#### Mcp
16+
17+
- Parametrize tests on the streaming trace lifecycle by @alexander-alderman-webb in [#7424](https://github.com/getsentry/sentry-python/pull/7424)
18+
- Remove vacuous tests by @alexander-alderman-webb in [#7420](https://github.com/getsentry/sentry-python/pull/7420)
19+
20+
#### Other
21+
22+
- (cohere) Parametrize tests on the streaming trace lifecycle by @alexander-alderman-webb in [#7419](https://github.com/getsentry/sentry-python/pull/7419)
23+
- (openai-agents) Parametrize tests on `stream_gen_ai_spans` and the streaming trace lifecycle by @alexander-alderman-webb in [#7405](https://github.com/getsentry/sentry-python/pull/7405)
24+
25+
## 2.69.0
26+
27+
### New Features ✨
28+
29+
#### Other
30+
31+
- (aiohttp) Add `http.route` attribute by @alexander-alderman-webb in [#7341](https://github.com/getsentry/sentry-python/pull/7341)
32+
- (bottle) Add `http.route` attribute by @alexander-alderman-webb in [#7343](https://github.com/getsentry/sentry-python/pull/7343)
33+
- (clickhouse_driver) Set breadcrumbs in the streaming trace lifecycle by @alexander-alderman-webb in [#7325](https://github.com/getsentry/sentry-python/pull/7325)
34+
- (docs) Add Plausible analytics to Sphinx docs by @ericapisani in [#7319](https://github.com/getsentry/sentry-python/pull/7319)
35+
- (falcon) Add `http.route` attribute by @alexander-alderman-webb in [#7340](https://github.com/getsentry/sentry-python/pull/7340)
36+
- (fastapi) Add `http.route` attribute by @alexander-alderman-webb in [#7322](https://github.com/getsentry/sentry-python/pull/7322)
37+
- (flask) Add `http.route` attribute by @alexander-alderman-webb in [#7344](https://github.com/getsentry/sentry-python/pull/7344)
38+
- (pyramid) Add `http.route` attribute by @alexander-alderman-webb in [#7347](https://github.com/getsentry/sentry-python/pull/7347)
39+
- (quart) Add `http.route` attribute by @alexander-alderman-webb in [#7348](https://github.com/getsentry/sentry-python/pull/7348)
40+
- (sqlalchemy) Add more db system names for span data by @ericapisani in [#7329](https://github.com/getsentry/sentry-python/pull/7329)
41+
- (starlette) Add `http.route` attribute by @alexander-alderman-webb in [#7338](https://github.com/getsentry/sentry-python/pull/7338)
42+
- (types) Export SpanJSON type by @ericapisani in [#7331](https://github.com/getsentry/sentry-python/pull/7331)
43+
- Add Python 3.15 to test matrix by @sentrivana in [#7326](https://github.com/getsentry/sentry-python/pull/7326)
44+
45+
### Bug Fixes 🐛
46+
47+
#### Mcp
48+
49+
- Handle `None` arguments in tool and prompt handlers by @alexander-alderman-webb in [#7387](https://github.com/getsentry/sentry-python/pull/7387)
50+
- Don't report stateless StreamableHTTP servers as stdio by @Snaylaker in [#7224](https://github.com/getsentry/sentry-python/pull/7224)
51+
52+
#### Openai
53+
54+
- Read `input_text` parts for the Responses API by @alexander-alderman-webb in [#7333](https://github.com/getsentry/sentry-python/pull/7333)
55+
- Check `Response.output` is a `list` before iterating by @alexander-alderman-webb in [#7238](https://github.com/getsentry/sentry-python/pull/7238)
56+
57+
#### Starlette
58+
59+
- Use `url` transaction source for host routing by @mjq in [#7266](https://github.com/getsentry/sentry-python/pull/7266)
60+
- Set transaction name on current scope in sync handler by @mjq in [#7201](https://github.com/getsentry/sentry-python/pull/7201)
61+
62+
#### Other
63+
64+
- (batcher) Do not let a failed flush kill the flusher thread (#7138) by @zkasuran in [#7186](https://github.com/getsentry/sentry-python/pull/7186)
65+
- (boto3) Fix botocore SigV4 failures caused by post-sign trace propagation by @pabloDeputter in [#7050](https://github.com/getsentry/sentry-python/pull/7050)
66+
- (httpx,httpx2) Always capture breadcrumb by @sentrivana in [#7351](https://github.com/getsentry/sentry-python/pull/7351)
67+
- (mcp,langchain) Add mechanism to captured exceptions by @gmassello in [#7226](https://github.com/getsentry/sentry-python/pull/7226)
68+
- (openai-agents) Use `isinstance` to determine tool type by @alexander-alderman-webb in [#7412](https://github.com/getsentry/sentry-python/pull/7412)
69+
- (quart) Skip quart-flask-patch and adjust error test for quart>=0.23 by @ericapisani in [#7320](https://github.com/getsentry/sentry-python/pull/7320)
70+
- Allow to correctly compare parsed versions by @sentrivana in [#7184](https://github.com/getsentry/sentry-python/pull/7184)
71+
72+
### Internal Changes 🔧
73+
74+
#### Openai Agents
75+
76+
- Capture spans instead of reading from span recorder by @alexander-alderman-webb in [#7404](https://github.com/getsentry/sentry-python/pull/7404)
77+
- Pin `openai` version when incompatible by @alexander-alderman-webb in [#7236](https://github.com/getsentry/sentry-python/pull/7236)
78+
79+
#### Pydantic Ai
80+
81+
- Replace individual hooks with `hooks.on.model_request` by @alexander-alderman-webb in [#7327](https://github.com/getsentry/sentry-python/pull/7327)
82+
- Fix instructions test for pydantic-ai >=2.36.0 by @ericapisani in [#7321](https://github.com/getsentry/sentry-python/pull/7321)
83+
84+
#### Other
85+
86+
- (aiohttp) Remove dead segment name code by @mjq in [#7284](https://github.com/getsentry/sentry-python/pull/7284)
87+
- (anthropic) Include `StreamedSpan` in type annotations by @alexander-alderman-webb in [#7373](https://github.com/getsentry/sentry-python/pull/7373)
88+
- (mcp) Inline `_extract_handler_data_from_args()` by @alexander-alderman-webb in [#7386](https://github.com/getsentry/sentry-python/pull/7386)
89+
- (quart) Fix flake caused by flushing spans on segment end by @alexander-alderman-webb in [#7240](https://github.com/getsentry/sentry-python/pull/7240)
90+
- (stdlib) Remove urllib3 workaround by @pabloDeputter in [#7283](https://github.com/getsentry/sentry-python/pull/7283)
91+
- Add `openai-agents` to uv typing group by @alexander-alderman-webb in [#7415](https://github.com/getsentry/sentry-python/pull/7415)
92+
- Add `aiohttp` to uv typing group by @alexander-alderman-webb in [#7395](https://github.com/getsentry/sentry-python/pull/7395)
93+
- Isolate `httpx` test suite from `httpx2` by @ZaafirRizwan in [#7398](https://github.com/getsentry/sentry-python/pull/7398)
94+
- Remove `test_langchain_embeddings_error_handling()` by @alexander-alderman-webb in [#7389](https://github.com/getsentry/sentry-python/pull/7389)
95+
- Add `tiktoken` to uv typing group by @alexander-alderman-webb in [#7394](https://github.com/getsentry/sentry-python/pull/7394)
96+
- Reference renamed coverage action by @MathurAditya724 in [#7371](https://github.com/getsentry/sentry-python/pull/7371)
97+
- Remove flaky detector by @sl0thentr0py in [#7363](https://github.com/getsentry/sentry-python/pull/7363)
98+
- Add `openai` to uv typing group by @alexander-alderman-webb in [#7334](https://github.com/getsentry/sentry-python/pull/7334)
99+
- 🤖 Update test matrix with new releases (08/31) by @github-actions in [#7303](https://github.com/getsentry/sentry-python/pull/7303)
100+
- Add `anthropic` to uv typing group by @alexander-alderman-webb in [#7324](https://github.com/getsentry/sentry-python/pull/7324)
101+
- Add `google-genai` to uv typing group by @alexander-alderman-webb in [#7323](https://github.com/getsentry/sentry-python/pull/7323)
102+
- Use tagged versions for `getsentry/codecov-action` by @alexander-alderman-webb in [#7241](https://github.com/getsentry/sentry-python/pull/7241)
103+
- Update test matrix with new releases (08/24) by @alexander-alderman-webb in [#7228](https://github.com/getsentry/sentry-python/pull/7228)
104+
- Add `httpx` dependency to tests relying on `get_model_response()` by @alexander-alderman-webb in [#7235](https://github.com/getsentry/sentry-python/pull/7235)
105+
- Access the 'type' in an event using `.get` by @ericapisani in [#7239](https://github.com/getsentry/sentry-python/pull/7239)
106+
3107
## 2.68.1
4108

5109
### `enable_logs`

‎docs/conf.py‎

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

34-
release = "2.68.1"
34+
release = "2.69.1"
3535
version = ".".join(release.split(".")[:2]) # The short X.Y version.
3636

3737

‎pyproject.toml‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,9 @@ typing = [
7777
"anthropic>=1.2.0",
7878
"google-genai>=2.21.0",
7979
"openai>=3.7.0",
80+
"tiktoken>=0.14.0",
81+
"aiohttp>=3.14.3",
82+
"openai-agents>=0.22.0",
8083
]
8184
test = [
8285
"dataclasses ; python_full_version < '3.7'",

‎scripts/populate_tox/README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ a Python version older than 3.9 if the HTTPX version is 0.28 or higher, you can
146146
say:
147147

148148
```python
149-
"httpx": {
149+
"httpx0": {
150150
"python": {
151151
# run the test suite for httpx v0.28+ on Python 3.9+ only
152152
">=0.28": ">=3.9",

‎scripts/populate_tox/config.py‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,8 +205,9 @@
205205
},
206206
"python": ">=3.7",
207207
},
208-
"httpx": {
208+
"httpx0": {
209209
"package": "httpx",
210+
"integration_name": "httpx",
210211
"deps": {
211212
"*": ["anyio>=3,<5", "pytest-asyncio"],
212213
"<0.24": ["anyio<4"],

‎scripts/split_tox_gh_actions/split_tox_gh_actions.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@
128128
],
129129
"Network": [
130130
"grpc",
131-
"httpx",
131+
"httpx0",
132132
"httpx2",
133133
"pyreqwest",
134134
"requests",

‎sentry_sdk/client.py‎

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@
4242
from sentry_sdk.serializer import serialize
4343
from sentry_sdk.sessions import SessionFlusher
4444
from sentry_sdk.traces import SpanStatus, StreamedSpan
45-
from sentry_sdk.tracing import trace
45+
from sentry_sdk.traces import trace as streaming_trace
46+
from sentry_sdk.tracing import trace as legacy_trace
4647
from sentry_sdk.tracing_utils import has_span_streaming_enabled
4748
from sentry_sdk.transport import (
4849
AsyncHttpTransport,
@@ -533,8 +534,14 @@ def _setup_instrumentation(
533534
self, functions_to_trace: "Sequence[Dict[str, str]]"
534535
) -> None:
535536
"""
536-
Instruments the functions given in the list `functions_to_trace` with the `@sentry_sdk.tracing.trace` decorator.
537+
Instruments the functions given in the list `functions_to_trace` with a trace decorator.
537538
"""
539+
trace = (
540+
streaming_trace
541+
if has_span_streaming_enabled(self.options)
542+
else legacy_trace
543+
)
544+
538545
for function in functions_to_trace:
539546
class_name = None
540547
function_qualname = function["qualified_name"]

‎sentry_sdk/consts.py‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
DEFAULT_MAX_STACK_FRAMES = 100
88
DEFAULT_ADD_FULL_STACK = False
99

10+
_SENTRY_HEADER_NAMES = frozenset(("baggage", "sentry-trace"))
11+
1012

1113
# Also needs to be at the top to prevent circular import
1214
class EndpointType(Enum):
@@ -1846,4 +1848,4 @@ def _get_default_options() -> "dict[str, Any]":
18461848
del _get_default_options
18471849

18481850

1849-
VERSION = "2.68.1"
1851+
VERSION = "2.69.1"

‎sentry_sdk/integrations/aiohttp.py‎

Lines changed: 45 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
import sentry_sdk
66
from sentry_sdk.api import continue_trace
7-
from sentry_sdk.consts import OP, SPANDATA, SPANSTATUS
7+
from sentry_sdk.consts import _SENTRY_HEADER_NAMES, OP, SPANDATA, SPANSTATUS
88
from sentry_sdk.data_collection import (
99
_apply_data_collection_filtering_to_query_string,
1010
)
@@ -29,6 +29,7 @@
2929
)
3030
from sentry_sdk.tracing import (
3131
BAGGAGE_HEADER_NAME,
32+
SENTRY_TRACE_HEADER_NAME,
3233
SOURCE_FOR_STYLE,
3334
TransactionSource,
3435
)
@@ -43,6 +44,8 @@
4344
HAS_REAL_CONTEXTVARS,
4445
SENSITIVE_DATA_SUBSTITUTE,
4546
AnnotatedValue,
47+
_get_aws_sigv4_signed_headers_from_authorization_header,
48+
_get_aws_sigv4_signed_headers_from_url_query_string,
4649
_register_control_flow_exception,
4750
capture_internal_exceptions,
4851
ensure_integration_enabled,
@@ -310,7 +313,7 @@ async def sentry_app_handle(
310313

311314
return response
312315

313-
Application._handle = sentry_app_handle
316+
Application._handle = sentry_app_handle # type: ignore[method-assign]
314317

315318
old_urldispatcher_resolve = UrlDispatcher.resolve
316319

@@ -350,7 +353,7 @@ async def sentry_urldispatcher_resolve(
350353

351354
return rv
352355

353-
UrlDispatcher.resolve = sentry_urldispatcher_resolve
356+
UrlDispatcher.resolve = sentry_urldispatcher_resolve # type: ignore[method-assign]
354357

355358
old_client_session_init = ClientSession.__init__
356359

@@ -363,7 +366,7 @@ def init(*args: "Any", **kwargs: "Any") -> None:
363366
kwargs["trace_configs"] = client_trace_configs
364367
return old_client_session_init(*args, **kwargs)
365368

366-
ClientSession.__init__ = init
369+
ClientSession.__init__ = init # type: ignore[method-assign]
367370

368371

369372
def create_trace_config() -> "TraceConfig":
@@ -464,12 +467,50 @@ async def on_request_start(
464467
span = legacy_span
465468

466469
if should_propagate_trace(client, str(params.url)):
470+
# existing `sentry-trace`: skip so it is not duplicated.
471+
headers_to_skip: "set[str]" = set()
472+
if SENTRY_TRACE_HEADER_NAME in params.headers:
473+
headers_to_skip.add(SENTRY_TRACE_HEADER_NAME)
474+
475+
with capture_internal_exceptions():
476+
authorization = params.headers.get("Authorization")
477+
if authorization:
478+
if isinstance(authorization, bytes):
479+
authorization = authorization.decode("latin-1")
480+
# `SignedHeaders` lists fields covered by SigV4.
481+
signed_headers = (
482+
_get_aws_sigv4_signed_headers_from_authorization_header(
483+
authorization
484+
)
485+
)
486+
# skip signed `sentry-trace` and `baggage`.
487+
headers_to_skip.update(
488+
_SENTRY_HEADER_NAMES.intersection(signed_headers)
489+
)
490+
491+
# presigned URLs list signed names in the query string.
492+
query_signed_headers = (
493+
_get_aws_sigv4_signed_headers_from_url_query_string(str(params.url))
494+
)
495+
headers_to_skip.update(
496+
_SENTRY_HEADER_NAMES.intersection(query_signed_headers)
497+
)
498+
467499
for (
468500
key,
469501
value,
470502
) in sentry_sdk.get_current_scope().iter_trace_propagation_headers(
471503
span=span
472504
):
505+
# skip signed headers and an existing `sentry-trace`.
506+
if key.lower() in headers_to_skip:
507+
logger.debug(
508+
"[Tracing] Not adding `{key}` header to outgoing request "
509+
"to {url}: it already exists or is covered by the AWS "
510+
"SigV4 signature.".format(key=key, url=params.url)
511+
)
512+
continue
513+
473514
logger.debug(
474515
"[Tracing] Adding `{key}` header {value} to outgoing request to {url}.".format(
475516
key=key, value=value, url=params.url

0 commit comments

Comments
 (0)