Skip to content

Commit f681575

Browse files
Merge branch 'master' into codeflash/optimize-extract_sentrytrace_data-mg9m9ul7
2 parents 5eb586a + 4325802 commit f681575

Some content is hidden

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

84 files changed

+6055
-2548
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -27,34 +27,12 @@ jobs:
2727
- uses: actions/[email protected]
2828
- uses: actions/setup-python@v6
2929
with:
30-
python-version: 3.12
30+
python-version: 3.14
3131

3232
- run: |
3333
pip install tox
3434
tox -e linters
3535
36-
check-ci-config:
37-
name: Check CI config
38-
runs-on: ubuntu-latest
39-
timeout-minutes: 10
40-
41-
steps:
42-
- uses: actions/[email protected]
43-
with:
44-
ref: ${{ github.event.pull_request.head.sha }}
45-
fetch-depth: 0
46-
- uses: actions/setup-python@v6
47-
with:
48-
python-version: 3.12
49-
50-
- name: Detect unexpected changes to tox.ini or CI
51-
run: |
52-
pip install -e .
53-
pip install -r scripts/populate_tox/requirements.txt
54-
python scripts/populate_tox/populate_tox.py --fail-on-changes
55-
pip install -r scripts/split_tox_gh_actions/requirements.txt
56-
python scripts/split_tox_gh_actions/split_tox_gh_actions.py --fail-on-changes
57-
5836
build_lambda_layer:
5937
name: Build Package
6038
runs-on: ubuntu-latest

.github/workflows/codeql-analysis.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ jobs:
5252

5353
# Initializes the CodeQL tools for scanning.
5454
- name: Initialize CodeQL
55-
uses: github/codeql-action/init@v3
55+
uses: github/codeql-action/init@v4
5656
with:
5757
languages: ${{ matrix.language }}
5858
# If you wish to specify custom queries, you can do so here or in a config file.
@@ -63,7 +63,7 @@ jobs:
6363
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
6464
# If this step fails, then you should remove it and run the build manually (see below)
6565
- name: Autobuild
66-
uses: github/codeql-action/autobuild@v3
66+
uses: github/codeql-action/autobuild@v4
6767

6868
# ℹ️ Command-line programs to run using the OS shell.
6969
# 📚 https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions
@@ -77,4 +77,4 @@ jobs:
7777
# make release
7878

7979
- name: Perform CodeQL Analysis
80-
uses: github/codeql-action/analyze@v3
80+
uses: github/codeql-action/analyze@v4

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

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,14 @@ jobs:
5858
run: |
5959
set -x # print commands that are executed
6060
./scripts/runtox.sh "py${{ matrix.python-version }}-cohere"
61+
- name: Test google_genai
62+
run: |
63+
set -x # print commands that are executed
64+
./scripts/runtox.sh "py${{ matrix.python-version }}-google_genai"
65+
- name: Test huggingface_hub
66+
run: |
67+
set -x # print commands that are executed
68+
./scripts/runtox.sh "py${{ matrix.python-version }}-huggingface_hub"
6169
- name: Test langchain-base
6270
run: |
6371
set -x # print commands that are executed
@@ -66,6 +74,14 @@ jobs:
6674
run: |
6775
set -x # print commands that are executed
6876
./scripts/runtox.sh "py${{ matrix.python-version }}-langchain-notiktoken"
77+
- name: Test langgraph
78+
run: |
79+
set -x # print commands that are executed
80+
./scripts/runtox.sh "py${{ matrix.python-version }}-langgraph"
81+
- name: Test litellm
82+
run: |
83+
set -x # print commands that are executed
84+
./scripts/runtox.sh "py${{ matrix.python-version }}-litellm"
6985
- name: Test openai-base
7086
run: |
7187
set -x # print commands that are executed
@@ -74,18 +90,10 @@ jobs:
7490
run: |
7591
set -x # print commands that are executed
7692
./scripts/runtox.sh "py${{ matrix.python-version }}-openai-notiktoken"
77-
- name: Test langgraph
78-
run: |
79-
set -x # print commands that are executed
80-
./scripts/runtox.sh "py${{ matrix.python-version }}-langgraph"
8193
- name: Test openai_agents
8294
run: |
8395
set -x # print commands that are executed
8496
./scripts/runtox.sh "py${{ matrix.python-version }}-openai_agents"
85-
- name: Test huggingface_hub
86-
run: |
87-
set -x # print commands that are executed
88-
./scripts/runtox.sh "py${{ matrix.python-version }}-huggingface_hub"
8997
- name: Generate coverage XML (Python 3.6)
9098
if: ${{ !cancelled() && matrix.python-version == '3.6' }}
9199
run: |

CHANGELOG.md

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

3+
## 2.42.0
4+
5+
### Various fixes & improvements
6+
7+
- feat: Add source information for slow outgoing HTTP requests (#4902) by @alexander-alderman-webb
8+
- tests: Update tox (#4913) by @sentrivana
9+
- fix(Ray): Retain the original function name when patching Ray tasks (#4858) by @svartalf
10+
- feat(ai): Add `python-genai` integration (#4891) by @vgrozdanic
11+
Enable the new Google GenAI integration with the code snippet below, and you can use the Sentry AI dashboards to observe your AI calls:
12+
13+
```python
14+
import sentry_sdk
15+
from sentry_sdk.integrations.google_genai import GoogleGenAIIntegration
16+
sentry_sdk.init(
17+
dsn="<your-dsn>",
18+
# Set traces_sample_rate to 1.0 to capture 100%
19+
# of transactions for tracing.
20+
traces_sample_rate=1.0,
21+
# Add data like inputs and responses;
22+
# see https://docs.sentry.io/platforms/python/data-management/data-collected/ for more info
23+
send_default_pii=True,
24+
integrations=[
25+
GoogleGenAIIntegration(),
26+
],
27+
)
28+
```
29+
30+
## 2.41.0
31+
32+
### Various fixes & improvements
33+
34+
- feat: Add `concurrent.futures` patch to threading integration (#4770) by @alexander-alderman-webb
35+
36+
The SDK now makes sure to automatically preserve span relationships when using `ThreadPoolExecutor`.
37+
- chore: Remove old metrics code (#4899) by @sentrivana
38+
39+
Removed all code related to the deprecated experimental metrics feature (`sentry_sdk.metrics`).
40+
- ref: Remove "experimental" from log function name (#4901) by @sentrivana
41+
- fix(ai): Add mapping for gen_ai message roles (#4884) by @shellmayr
42+
- feat(metrics): Add trace metrics behind an experiments flag (#4898) by @k-fish
43+
44+
## 2.40.0
45+
46+
### Various fixes & improvements
47+
48+
- Add LiteLLM integration (#4864) by @constantinius
49+
Once you've enabled the [new LiteLLM integration](https://docs.sentry.io/platforms/python/integrations/litellm/), you can use the Sentry AI Agents Monitoring, a Sentry dashboard that helps you understand what's going on with your AI requests:
50+
51+
```python
52+
import sentry_sdk
53+
from sentry_sdk.integrations.litellm import LiteLLMIntegration
54+
sentry_sdk.init(
55+
dsn="<your-dsn>",
56+
# Set traces_sample_rate to 1.0 to capture 100%
57+
# of transactions for tracing.
58+
traces_sample_rate=1.0,
59+
# Add data like inputs and responses;
60+
# see https://docs.sentry.io/platforms/python/data-management/data-collected/ for more info
61+
send_default_pii=True,
62+
integrations=[
63+
LiteLLMIntegration(),
64+
],
65+
)
66+
```
67+
68+
- Litestar: Copy request info to prevent cookies mutation (#4883) by @alexander-alderman-webb
69+
- Add tracing to `DramatiqIntegration` (#4571) by @Igreh
70+
- Also emit spans for MCP tool calls done by the LLM (#4875) by @constantinius
71+
- Option to not trace HTTP requests based on status codes (#4869) by @alexander-alderman-webb
72+
You can now disable transactions for incoming requests with specific HTTP status codes. The [new `trace_ignore_status_codes` option](https://docs.sentry.io/platforms/python/configuration/options/#trace_ignore_status_codes) accepts a `set` of status codes as integers. If a transaction wraps a request that results in one of the provided status codes, the transaction will be unsampled.
73+
74+
```python
75+
import sentry_sdk
76+
77+
sentry_sdk.init(
78+
trace_ignore_status_codes={301, 302, 303, *range(305, 400), 404},
79+
)
80+
```
81+
82+
- Move `_set_agent_data` call to `ai_client_span` function (#4876) by @constantinius
83+
- Add script to determine lowest supported versions (#4867) by @sentrivana
84+
- Update `CONTRIBUTING.md` (#4870) by @sentrivana
85+
386
## 2.39.0
487

588
### Various fixes & improvements

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

3737

pyproject.toml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,10 @@ ignore_missing_imports = true
118118
module = "langgraph.*"
119119
ignore_missing_imports = true
120120

121+
[[tool.mypy.overrides]]
122+
module = "google.genai.*"
123+
ignore_missing_imports = true
124+
121125
[[tool.mypy.overrides]]
122126
module = "executing.*"
123127
ignore_missing_imports = true
@@ -179,6 +183,10 @@ ignore_missing_imports = true
179183
module = "agents.*"
180184
ignore_missing_imports = true
181185

186+
[[tool.mypy.overrides]]
187+
module = "dramatiq.*"
188+
ignore_missing_imports = true
189+
182190
#
183191
# Tool: Ruff (linting and formatting)
184192
#

scripts/populate_tox/README.md

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14,25 +14,24 @@ combination of hardcoded and generated entries.
1414

1515
The `populate_tox.py` script fills out the auto-generated part of that template.
1616
It does this by querying PyPI for each framework's package and its metadata and
17-
then determining which versions make sense to test to get good coverage.
17+
then determining which versions it makes sense to test to get good coverage.
1818

1919
By default, the lowest supported and latest version of a framework are always
2020
tested, with a number of releases in between:
2121
- If the package has majors, we pick the highest version of each major.
2222
- If the package doesn't have multiple majors, we pick two versions in between
2323
lowest and highest.
2424

25-
#### Caveats
25+
Each test suite requires at least some configuration to be added to
26+
`TEST_SUITE_CONFIG` in `scripts/populate_tox/config.py`. If you're adding a new
27+
integration, check out the [Add a new test suite](#add-a-new-test-suite) section.
2628

27-
- Make sure the integration name is the same everywhere. If it consists of
28-
multiple words, use an underscore instead of a hyphen.
29+
## Test suite config
2930

30-
## Defining constraints
31-
32-
The `TEST_SUITE_CONFIG` dictionary defines, for each integration test suite,
33-
the main package (framework, library) to test with; any additional test
34-
dependencies, optionally gated behind specific conditions; and optionally
35-
the Python versions to test on.
31+
The `TEST_SUITE_CONFIG` dictionary in `scripts/populate_tox/config.py` defines,
32+
for each integration test suite, the main package (framework, library) to test
33+
with; any additional test dependencies, optionally gated behind specific
34+
conditions; and optionally the Python versions to test on.
3635

3736
Constraints are defined using the format specified below. The following sections
3837
describe each key.
@@ -58,7 +57,7 @@ in [packaging.specifiers](https://packaging.pypa.io/en/stable/specifiers.html).
5857

5958
### `package`
6059

61-
The name of the third party package as it's listed on PyPI. The script will
60+
The name of the third-party package as it's listed on PyPI. The script will
6261
be picking different versions of this package to test.
6362

6463
This key is mandatory.
@@ -69,15 +68,15 @@ The test dependencies of the test suite. They're defined as a dictionary of
6968
`rule: [package1, package2, ...]` key-value pairs. All packages
7069
in the package list of a rule will be installed as long as the rule applies.
7170

72-
`rule`s are predefined. Each `rule` must be one of the following:
71+
Each `rule` must be one of the following:
7372
- `*`: packages will be always installed
7473
- a version specifier on the main package (e.g. `<=0.32`): packages will only
7574
be installed if the main package falls into the version bounds specified
7675
- specific Python version(s) in the form `py3.8,py3.9`: packages will only be
7776
installed if the Python version matches one from the list
7877

7978
Rules can be used to specify version bounds on older versions of the main
80-
package's dependencies, for example. If e.g. Flask tests generally need
79+
package's dependencies, for example. If Flask tests generally need
8180
Werkzeug and don't care about its version, but Flask older than 3.0 needs
8281
a specific Werkzeug version to work, you can say:
8382

@@ -176,7 +175,7 @@ be expressed like so:
176175
### `integration_name`
177176

178177
Sometimes, the name of the test suite doesn't match the name of the integration.
179-
For example, we have the `openai_base` and `openai_notiktoken` test suites, both
178+
For example, we have the `openai-base` and `openai-notiktoken` test suites, both
180179
of which are actually testing the `openai` integration. If this is the case, you
181180
can use the `integration_name` key to define the name of the integration. If not
182181
provided, it will default to the name of the test suite.
@@ -193,6 +192,11 @@ greater than 2, as the oldest and latest supported versions will always be
193192
picked. Additionally, if there is a recent prerelease, it'll also always be
194193
picked (this doesn't count towards `num_versions`).
195194

195+
For instance, `num_versions` set to `2` will only test the first supported and
196+
the last release of the package. `num_versions` equal to `3` will test the first
197+
supported, the last release, and one release in between; `num_versions` set to `4`
198+
will test an additional release in between. In all these cases, if there is
199+
a recent prerelease, it'll be picked as well in addition to the picked versions.
196200

197201
## How-Tos
198202

@@ -202,9 +206,10 @@ picked (this doesn't count towards `num_versions`).
202206
in `integrations/__init__.py`. This should be the lowest version of the
203207
framework that we can guarantee works with the SDK. If you've just added the
204208
integration, you should generally set this to the latest version of the framework
205-
at the time.
209+
at the time, unless you've verified the integration works for earlier versions
210+
as well.
206211
2. Add the integration and any constraints to `TEST_SUITE_CONFIG`. See the
207-
"Defining constraints" section for the format.
212+
[Test suite config](#test-suite-config) section for the format.
208213
3. Add the integration to one of the groups in the `GROUPS` dictionary in
209214
`scripts/split_tox_gh_actions/split_tox_gh_actions.py`.
210215
4. Run `scripts/generate-test-files.sh` and commit the changes.

scripts/populate_tox/config.py

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# The TEST_SUITE_CONFIG dictionary defines, for each integration test suite,
2-
# the main package (framework, library) to test with; any additional test
3-
# dependencies, optionally gated behind specific conditions; and optionally
4-
# the Python versions to test on.
2+
# at least the main package (framework, library) to test with. Additional
3+
# test dependencies, Python versions to test on, etc. can also be defined here.
54
#
65
# See scripts/populate_tox/README.md for more info on the format and examples.
76

@@ -143,6 +142,13 @@
143142
"package": "gql[all]",
144143
"num_versions": 2,
145144
},
145+
"google_genai": {
146+
"package": "google-genai",
147+
"deps": {
148+
"*": ["pytest-asyncio"],
149+
},
150+
"python": ">=3.9",
151+
},
146152
"graphene": {
147153
"package": "graphene",
148154
"deps": {
@@ -183,9 +189,8 @@
183189
"huggingface_hub": {
184190
"package": "huggingface_hub",
185191
"deps": {
186-
"*": ["responses"],
192+
"*": ["responses", "pytest-httpx"],
187193
},
188-
"include": "<1.0",
189194
},
190195
"langchain-base": {
191196
"package": "langchain",
@@ -214,6 +219,9 @@
214219
"package": "launchdarkly-server-sdk",
215220
"num_versions": 2,
216221
},
222+
"litellm": {
223+
"package": "litellm",
224+
},
217225
"litestar": {
218226
"package": "litestar",
219227
"deps": {
@@ -232,7 +240,10 @@
232240
"*": ["pytest-asyncio", "tiktoken"],
233241
"<1.55": ["httpx<0.28"],
234242
},
235-
"python": ">=3.8",
243+
"python": {
244+
">0.0,<2.3": ">=3.8",
245+
">=2.3": ">=3.9",
246+
},
236247
},
237248
"openai-notiktoken": {
238249
"package": "openai",
@@ -241,7 +252,10 @@
241252
"*": ["pytest-asyncio"],
242253
"<1.55": ["httpx<0.28"],
243254
},
244-
"python": ">=3.8",
255+
"python": {
256+
">0.0,<2.3": ">=3.8",
257+
">=2.3": ">=3.9",
258+
},
245259
},
246260
"openai_agents": {
247261
"package": "openai-agents",

0 commit comments

Comments
 (0)