Skip to content

Commit 152fccf

Browse files
committed
Merge branch 'master' into major/3.0
2 parents 74bbd38 + 3fbf49b commit 152fccf

56 files changed

Lines changed: 11819 additions & 7444 deletions

Some content is hidden

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

.craft.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
minVersion: 2.21.1
1+
minVersion: 2.28.0
22
preReleaseCommand: bash scripts/bump-version.sh
33
targets:
44
- name: pypi
@@ -12,6 +12,8 @@ targets:
1212
# This regex that matches the version is taken from craft:
1313
# https://github.com/getsentry/craft/blob/8d77c38ddbe4be59f98f61b6e42952ca087d3acd/src/utils/version.ts#L11
1414
includeNames: /^sentry-python-serverless-\bv?(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(?:-?([\da-z-]+(?:\.[\da-z-]+)*))?(?:\+([\da-z-]+(?:\.[\da-z-]+)*))?\b.zip$/
15+
# If we ever want per-major layer names like JavaScript's
16+
# SentryNodeServerlessSDKv10:84, craft supports {{{major}}} templating.
1517
layerName: SentryPythonServerlessSDK
1618
compatibleRuntimes:
1719
- name: python
@@ -28,6 +30,11 @@ targets:
2830
- python3.11
2931
- python3.12
3032
- python3.13
33+
- python3.14
34+
compatibleArchitectures:
35+
# Both x86_64 and arm64 are supported by default; explicitly listing for better visibility
36+
- x86_64
37+
- arm64
3138
license: MIT
3239
- name: sentry-pypi
3340
internalPypiRepo: getsentry/pypi

CHANGELOG.md

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

3+
## 2.67.0
4+
5+
### New Features ✨
6+
7+
#### Batcher
8+
9+
- Add global flush trigger based on summed size estimates by @alexander-alderman-webb in [#7144](https://github.com/getsentry/sentry-python/pull/7144)
10+
- Add hard span limit by @alexander-alderman-webb in [#7143](https://github.com/getsentry/sentry-python/pull/7143)
11+
12+
#### Integrations
13+
14+
- Add span for DRF authentication by @mgaligniana in [#6984](https://github.com/getsentry/sentry-python/pull/6984)
15+
16+
#### Langchain
17+
18+
- Record reasoning token usage attribute by @alexander-alderman-webb in [#7136](https://github.com/getsentry/sentry-python/pull/7136)
19+
- Record cached token usage attributes by @alexander-alderman-webb in [#7132](https://github.com/getsentry/sentry-python/pull/7132)
20+
21+
#### Openai
22+
23+
- Set `gen_ai.tool.definitions` for the Responses API by @alexander-alderman-webb in [#6951](https://github.com/getsentry/sentry-python/pull/6951)
24+
- Set `gen_ai.tool.definitions` for the Chat Completions API by @alexander-alderman-webb in [#6950](https://github.com/getsentry/sentry-python/pull/6950)
25+
- Add `gen_ai.request.reasoning.level` to OpenAI spans by @pabloDeputter in [#6892](https://github.com/getsentry/sentry-python/pull/6892)
26+
27+
#### Streaming
28+
29+
- Support ai_track decorator by @sentrivana in [#6895](https://github.com/getsentry/sentry-python/pull/6895)
30+
- Promote `before_send_span` to top-level option by @sentrivana in [#6885](https://github.com/getsentry/sentry-python/pull/6885)
31+
- Make `set_conversation_id` API work by @sentrivana in [#6866](https://github.com/getsentry/sentry-python/pull/6866)
32+
33+
#### Other
34+
35+
- (api) Add top-level `set_attributes` API by @sentrivana in [#6897](https://github.com/getsentry/sentry-python/pull/6897)
36+
- (aws-lambda) Enable Python 3.14 support to the Lambda layer by @pabloDeputter in [#6916](https://github.com/getsentry/sentry-python/pull/6916)
37+
- (openai-agents) Set the `gen_ai.tool.definitions` attribute by @alexander-alderman-webb in [#6956](https://github.com/getsentry/sentry-python/pull/6956)
38+
- (pydantic-ai) Record `gen_ai.output.messages` including `ThinkingPart` by @alexander-alderman-webb in [#7037](https://github.com/getsentry/sentry-python/pull/7037)
39+
- Add possibility to allowlist integrations in toxgen by @sentrivana in [#6996](https://github.com/getsentry/sentry-python/pull/6996)
40+
41+
### Bug Fixes 🐛
42+
43+
#### Openai Agents
44+
45+
- Patch correct `run_single_turn_streamed` reference by @alexander-alderman-webb in [#7032](https://github.com/getsentry/sentry-python/pull/7032)
46+
- Stop destructively wrapping tools by @alexander-alderman-webb in [#6961](https://github.com/getsentry/sentry-python/pull/6961)
47+
48+
#### Tests
49+
50+
- Adapt to new exception propagation behavior in Quart by @sentrivana in [#6995](https://github.com/getsentry/sentry-python/pull/6995)
51+
- Remove redundant type filters after `capture_items` with args by @sentrivana in [#6867](https://github.com/getsentry/sentry-python/pull/6867)
52+
53+
#### Other
54+
55+
- (aws-lambda) Fix flake in aws lambda tests by @pabloDeputter in [#6937](https://github.com/getsentry/sentry-python/pull/6937)
56+
- (langchain) Stop double-counting usage in multi-candidate responses by @alexander-alderman-webb in [#7064](https://github.com/getsentry/sentry-python/pull/7064)
57+
- (mcp) Stop adding the prompt name to arguments by @alexander-alderman-webb in [#6765](https://github.com/getsentry/sentry-python/pull/6765)
58+
- (pydantic-ai) Stop recording duplicate spans by @alexander-alderman-webb in [#7056](https://github.com/getsentry/sentry-python/pull/7056)
59+
- (sampling) `sentry-trace` should take precedence over baggage by @sentrivana in [#6863](https://github.com/getsentry/sentry-python/pull/6863)
60+
- (streaming) Set segment source if unset by @sentrivana in [#6791](https://github.com/getsentry/sentry-python/pull/6791)
61+
- Do not let exceptions in before_breadcrumb bubble up by @sentrivana in [#7133](https://github.com/getsentry/sentry-python/pull/7133)
62+
- Correct typo in test function name by @TheGreatApollyon in [#6967](https://github.com/getsentry/sentry-python/pull/6967)
63+
- Include query string and fragment in `url.full` span attribute by @sentrivana in [#6861](https://github.com/getsentry/sentry-python/pull/6861)
64+
65+
### Documentation 📚
66+
67+
- Remove AI commit attribution requirement from AGENTS.md by @ericapisani in [#6828](https://github.com/getsentry/sentry-python/pull/6828)
68+
69+
### Internal Changes 🔧
70+
71+
#### Fastmcp
72+
73+
- Skip SSE test for `fastmcp>=4` by @alexander-alderman-webb in [#6923](https://github.com/getsentry/sentry-python/pull/6923)
74+
- Remove assertions on `RootModel` instances by @alexander-alderman-webb in [#6909](https://github.com/getsentry/sentry-python/pull/6909)
75+
- Replace broad `try...except` with `skipif` by @alexander-alderman-webb in [#6922](https://github.com/getsentry/sentry-python/pull/6922)
76+
77+
#### Mcp
78+
79+
- Replace instance patches with middleware by @alexander-alderman-webb in [#6764](https://github.com/getsentry/sentry-python/pull/6764)
80+
- Remove redundant `mcp.tool.result.is_error` by @alexander-alderman-webb in [#6915](https://github.com/getsentry/sentry-python/pull/6915)
81+
- Use `mcp_types` package by @alexander-alderman-webb in [#6763](https://github.com/getsentry/sentry-python/pull/6763)
82+
- Inline `_set_span_output_data()` by @alexander-alderman-webb in [#6762](https://github.com/getsentry/sentry-python/pull/6762)
83+
- Inline `_get_span_config()` by @alexander-alderman-webb in [#6761](https://github.com/getsentry/sentry-python/pull/6761)
84+
- Inline `_prepare_handler_data()` by @alexander-alderman-webb in [#6758](https://github.com/getsentry/sentry-python/pull/6758)
85+
- Separate tool, prompt and resource patches by @alexander-alderman-webb in [#6726](https://github.com/getsentry/sentry-python/pull/6726)
86+
87+
#### Openai Agents
88+
89+
- Stop setting `gen_ai.response.model` on Invoke Agent spans by @alexander-alderman-webb in [#7028](https://github.com/getsentry/sentry-python/pull/7028)
90+
- Use first class tool hooks when available by @alexander-alderman-webb in [#6994](https://github.com/getsentry/sentry-python/pull/6994)
91+
- Assert subset of expected dictionary is in `gen_ai.response.tool_calls` by @alexander-alderman-webb in [#6973](https://github.com/getsentry/sentry-python/pull/6973)
92+
- Stop setting `gen_ai.request.available_tools` on Invoke Agent spans by @alexander-alderman-webb in [#6955](https://github.com/getsentry/sentry-python/pull/6955)
93+
- Stop setting `gen_ai.request.available_tools` on Execute Tool spans by @alexander-alderman-webb in [#6954](https://github.com/getsentry/sentry-python/pull/6954)
94+
95+
#### Other
96+
97+
- (ai) Route AI integration tests through OpenRouter by @sentry-junior in [#6979](https://github.com/getsentry/sentry-python/pull/6979)
98+
- (arq) Avoid race between the exception and transaction events by @alexander-alderman-webb in [#7052](https://github.com/getsentry/sentry-python/pull/7052)
99+
- (aws_lambda) Add ARM64 architecture support for local Lambda testing by @ericapisani in [#7053](https://github.com/getsentry/sentry-python/pull/7053)
100+
- (deps) Lock file maintenance by @renovate in [#6734](https://github.com/getsentry/sentry-python/pull/6734)
101+
- (django) Use `iscoroutinefunction` shim in `patch_views()` by @alexander-alderman-webb in [#7024](https://github.com/getsentry/sentry-python/pull/7024)
102+
- (httpx) Replace deprecated `asyncio.iscoroutinefunction` by @alexander-alderman-webb in [#7023](https://github.com/getsentry/sentry-python/pull/7023)
103+
- (huggingface-hub) Fix chat completion stream type by @alexander-alderman-webb in [#7070](https://github.com/getsentry/sentry-python/pull/7070)
104+
- (langchain) Remove `on_agent_finish()` hook by @alexander-alderman-webb in [#7059](https://github.com/getsentry/sentry-python/pull/7059)
105+
- (pydantic-ai) Use `FunctionModel` for testing output data transformations by @alexander-alderman-webb in [#7036](https://github.com/getsentry/sentry-python/pull/7036)
106+
- (serializer) Avoid copying the whole Mapping before trimming to `MAX_DATABAG_BREADTH` by @Malkiz223 in [#6783](https://github.com/getsentry/sentry-python/pull/6783)
107+
- (tests) Replace \_transport_works_cases loop with explicit case list by @ericapisani in [#6978](https://github.com/getsentry/sentry-python/pull/6978)
108+
- 🤖 Update test matrix with new releases (08/10) by @github-actions in [#7142](https://github.com/getsentry/sentry-python/pull/7142)
109+
- Pin `litellm<=1.96` for generating test suites by @alexander-alderman-webb in [#7147](https://github.com/getsentry/sentry-python/pull/7147)
110+
- Unpin Django version for generating test suites by @alexander-alderman-webb in [#7146](https://github.com/getsentry/sentry-python/pull/7146)
111+
- Move Redis breadcrumbs to integration by @sentrivana in [#7129](https://github.com/getsentry/sentry-python/pull/7129)
112+
- Move subprocess breadcrumbs to integration by @sentrivana in [#7128](https://github.com/getsentry/sentry-python/pull/7128)
113+
- Avoid scanning installed packages when MCP SDK is not installed by @mangodxd in [#6865](https://github.com/getsentry/sentry-python/pull/6865)
114+
- Remove `test-lambda-locally` by @alexander-alderman-webb in [#7069](https://github.com/getsentry/sentry-python/pull/7069)
115+
- Add `pydantic-ai-slim` to uv typing group by @alexander-alderman-webb in [#7025](https://github.com/getsentry/sentry-python/pull/7025)
116+
- Add `langchain-base` to uv typing group by @alexander-alderman-webb in [#7016](https://github.com/getsentry/sentry-python/pull/7016)
117+
- 🤖 Update test matrix with new releases (08/03) by @github-actions in [#6985](https://github.com/getsentry/sentry-python/pull/6985)
118+
- Mock attributes in redis cluster tests by @sentrivana in [#7022](https://github.com/getsentry/sentry-python/pull/7022)
119+
- Deprecate `ai_track()` by @alexander-alderman-webb in [#7005](https://github.com/getsentry/sentry-python/pull/7005)
120+
- Reduce common test suite while not reducing coverage by @ericapisani in [#6972](https://github.com/getsentry/sentry-python/pull/6972)
121+
- Use top-level options if available by @sentrivana in [#6959](https://github.com/getsentry/sentry-python/pull/6959)
122+
- Restore wrapped functions in `functions_to_trace` tests by @alexander-alderman-webb in [#6933](https://github.com/getsentry/sentry-python/pull/6933)
123+
- Pin `mcp<2` for `fastmcp<0.3` by @alexander-alderman-webb in [#6925](https://github.com/getsentry/sentry-python/pull/6925)
124+
- Pin Python > 3.7 for `huey>=3.3.0` by @alexander-alderman-webb in [#6913](https://github.com/getsentry/sentry-python/pull/6913)
125+
- Add `httpx` dependency to `mcp` and `fastmcp` tests by @alexander-alderman-webb in [#6905](https://github.com/getsentry/sentry-python/pull/6905)
126+
- Remove flaky circular references tests by @alexander-alderman-webb in [#6903](https://github.com/getsentry/sentry-python/pull/6903)
127+
- Remove old Python compat code by @sentrivana in [#6902](https://github.com/getsentry/sentry-python/pull/6902)
128+
- Add span streaming DSC tests by @sentrivana in [#6884](https://github.com/getsentry/sentry-python/pull/6884)
129+
- Add streaming logs tests by @sentrivana in [#6880](https://github.com/getsentry/sentry-python/pull/6880)
130+
- Add streaming API tests by @sentrivana in [#6883](https://github.com/getsentry/sentry-python/pull/6883)
131+
- Add streaming continous profiler tests by @sentrivana in [#6879](https://github.com/getsentry/sentry-python/pull/6879)
132+
- Add streaming monitor test by @sentrivana in [#6882](https://github.com/getsentry/sentry-python/pull/6882)
133+
- Add streaming metrics test by @sentrivana in [#6881](https://github.com/getsentry/sentry-python/pull/6881)
134+
- Add sample_rand span streaming tests by @sentrivana in [#6781](https://github.com/getsentry/sentry-python/pull/6781)
135+
3136
## 2.66.1
4137

5138
### Bug Fixes 🐛

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.66.1"
34+
release = "2.67.0"
3535
version = ".".join(release.split(".")[:2]) # The short X.Y version.
3636

3737

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ typing = [
7373
"pydantic>=2.13.4",
7474
"pydantic-ai-slim>=2.23.0",
7575
"langchain-core>=1.5.3",
76+
"huggingface-hub>=1.26.1",
7677
]
7778
test = [
7879
"dataclasses ; python_full_version < '3.7'",
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
#!/usr/bin/env bash
2+
#
3+
# Attach the layer first with: ./scripts/aws/aws-attach-layer-to-lambda-function.sh
4+
#
5+
# Replaces handler, SENTRY_DSN, SENTRY_INITIAL_HANDLER and SENTRY_TRACES_SAMPLE_RATE.
6+
7+
# Usage: ./scripts/aws/aws-configure-layer-on-lambda-function.sh <lambda-function-name> <dsn> <region (optional)>
8+
9+
set -euo pipefail
10+
11+
if [ $# -lt 2 ] || [ $# -gt 3 ]; then
12+
SCRIPT_NAME=$(basename "$0")
13+
echo "ERROR: Missing arguments."
14+
echo "Usage: $SCRIPT_NAME <lambda-function-name> <dsn> <region (optional)>"
15+
exit 1
16+
fi
17+
18+
FUNCTION_NAME=$1
19+
DSN=$2
20+
SENTRY_HANDLER="sentry_sdk.integrations.init_serverless_sdk.sentry_lambda_handler"
21+
REGION=${3:-"eu-north-1"}
22+
TRACES_SAMPLE_RATE="1.0"
23+
24+
echo "Fetching current configuration for function '$FUNCTION_NAME'..."
25+
CONFIG=$(aws lambda get-function-configuration \
26+
--function-name "$FUNCTION_NAME" \
27+
--region "$REGION" \
28+
--no-cli-pager)
29+
CURRENT_HANDLER=$(echo "$CONFIG" | jq -r '.Handler')
30+
31+
if [ "$CURRENT_HANDLER" = "$SENTRY_HANDLER" ]; then
32+
INITIAL_HANDLER=$(echo "$CONFIG" | jq -r '.Environment.Variables.SENTRY_INITIAL_HANDLER // empty')
33+
if [ -z "$INITIAL_HANDLER" ] || [ "$INITIAL_HANDLER" = "$SENTRY_HANDLER" ]; then
34+
echo "Handler is already set to '$SENTRY_HANDLER' but SENTRY_INITIAL_HANDLER is missing or points at it."
35+
echo "Set SENTRY_INITIAL_HANDLER to real handler first."
36+
exit 1
37+
fi
38+
echo "SENTRY_INITIAL_HANDLER already set to $INITIAL_HANDLER."
39+
else
40+
INITIAL_HANDLER=$CURRENT_HANDLER
41+
fi
42+
43+
ENV_JSON=$(echo "$CONFIG" | jq -c \
44+
--arg dsn "$DSN" \
45+
--arg initial "$INITIAL_HANDLER" \
46+
--arg traces_sample_rate "$TRACES_SAMPLE_RATE" \
47+
'
48+
((.Environment.Variables // {})
49+
| del(.SENTRY_DSN, .SENTRY_INITIAL_HANDLER, .SENTRY_TRACES_SAMPLE_RATE))
50+
+ {
51+
SENTRY_DSN: $dsn,
52+
SENTRY_INITIAL_HANDLER: $initial,
53+
SENTRY_TRACES_SAMPLE_RATE: $traces_sample_rate
54+
}
55+
| {Variables: .}
56+
')
57+
58+
echo "Updating function configuration..."
59+
aws lambda update-function-configuration \
60+
--function-name "$FUNCTION_NAME" \
61+
--region "$REGION" \
62+
--handler "$SENTRY_HANDLER" \
63+
--environment "$ENV_JSON" \
64+
--no-cli-pager

scripts/aws/aws-deploy-local-layer.sh

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,23 @@ set -euo pipefail
99

1010
# Creating Lambda layer
1111
echo "Creating Lambda layer in ./dist ..."
12-
make aws-lambda-layer
12+
uv build
13+
uv run --group aws --with-editable . python scripts/build_aws_lambda_layer.py
1314
echo "Done creating Lambda layer in ./dist"
1415

1516
# Deploying zipped Lambda layer to AWS
1617
ZIP=$(ls dist | grep serverless | head -n 1)
1718
echo "Deploying zipped Lambda layer $ZIP to AWS..."
1819

1920
aws lambda publish-layer-version \
20-
--layer-name "SentryPythonServerlessSDK-local-dev" \
21-
--region "eu-central-1" \
22-
--zip-file "fileb://dist/$ZIP" \
23-
--description "Local test build of SentryPythonServerlessSDK (can be deleted)" \
24-
--compatible-runtimes python3.7 python3.8 python3.9 python3.10 python3.11 \
25-
--no-cli-pager
21+
--layer-name "SentryPythonServerlessSDK-local-dev" \
22+
--region "eu-central-1" \
23+
--zip-file "fileb://dist/$ZIP" \
24+
--description "Local test build of SentryPythonServerlessSDK (can be deleted)" \
25+
--compatible-runtimes python3.7 python3.8 python3.9 python3.10 python3.11 python3.12 python3.13 python3.14 \
26+
--compatible-architectures x86_64 arm64 \
27+
--license-info "MIT" \
28+
--no-cli-pager
2629

2730
echo "Done deploying zipped Lambda layer to AWS as 'SentryPythonServerlessSDK-local-dev'."
2831

scripts/populate_tox/config.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,6 @@
117117
"<3.1": ["pytest-django<4.0", "six"],
118118
"py3.14,py3.14t": ["coverage==7.11.0"],
119119
},
120-
"include": "<6.1b1",
121120
},
122121
"dramatiq": {
123122
"package": "dramatiq",
@@ -200,7 +199,7 @@
200199
"httpx": {
201200
"package": "httpx",
202201
"deps": {
203-
"*": ["anyio>=3,<5"],
202+
"*": ["anyio>=3,<5", "pytest-asyncio"],
204203
"<0.24": ["anyio<4"],
205204
">=0.16,<0.17": ["pytest-httpx==0.10.0"],
206205
">=0.17,<0.19": ["pytest-httpx==0.12.0"],
@@ -220,7 +219,7 @@
220219
"httpx2": {
221220
"package": "httpx2",
222221
"deps": {
223-
"*": ["anyio>=3,<5", "httpx2-pytest==1.0.1"],
222+
"*": ["anyio>=3,<5", "httpx2-pytest==1.0.1", "pytest-asyncio"],
224223
},
225224
"python": ">=3.10",
226225
},
@@ -245,6 +244,7 @@
245244
"<=0.1": ["httpx<0.28.0"],
246245
">=0.3": ["langchain-community"],
247246
">=1.0": ["langchain-classic"],
247+
">=1.1.2": ["google-genai", "langchain-google-genai>=4"],
248248
},
249249
"python": {
250250
"<1.0": "<3.14", # https://github.com/langchain-ai/langchain/issues/33449#issuecomment-3408876631
@@ -258,6 +258,7 @@
258258
"<=0.1": ["httpx<0.28.0"],
259259
">=0.3": ["langchain-community"],
260260
">=1.0": ["langchain-classic"],
261+
">=1.1.2": ["google-genai", "langchain-google-genai>=4"],
261262
},
262263
"python": {
263264
"<1.0": "<3.14", # https://github.com/langchain-ai/langchain/issues/33449#issuecomment-3408876631
@@ -275,6 +276,7 @@
275276
"deps": {
276277
"*": ["anthropic", "google-genai", "pytest-asyncio"],
277278
},
279+
"include": "<=1.96", # https://github.com/BerriAI/litellm/issues/36384
278280
},
279281
"litestar": {
280282
"package": "litestar",

0 commit comments

Comments
 (0)