Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/changelog-preview.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ permissions:

jobs:
changelog-preview:
uses: getsentry/craft/.github/workflows/changelog-preview.yml@3f2abdc5703191d12ef2cc013f792f1bd220f44d # v2
uses: getsentry/craft/.github/workflows/changelog-preview.yml@7a7857552e2cdc08b502de96e6076849c01fba32 # v2
secrets:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
token: ${{ steps.token.outputs.token }}
fetch-depth: 0
- name: Prepare release
uses: getsentry/craft@3f2abdc5703191d12ef2cc013f792f1bd220f44d # 2.34.1
uses: getsentry/craft@7a7857552e2cdc08b502de96e6076849c01fba32 # 2.35.0
env:
GITHUB_TOKEN: ${{ steps.token.outputs.token }}
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-integrations-tasks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:
with:
enable-cache: false
- name: Install Java
uses: actions/setup-java@de7274f081f381c8f8158605e0321c36c376e2e6 # v6
uses: actions/setup-java@b843ebf9b913146b38da2eaa7aeddf76074ae1ad # v6
with:
distribution: 'temurin'
java-version: '21'
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ jobs:
uv run coverage combine .coverage-sentry-*
uv run coverage xml
- name: Report coverage and test results
uses: getsentry/coverage-action@88418cdae07a8bac2beaec1550bcafff9ec55c8b # 0.4.3
uses: getsentry/coverage-action@b3db4e382bd9859c913a96093a3d369b67f59177 # 0.4.4
with:
token: ${{ secrets.GITHUB_TOKEN }}
files: coverage.xml
Expand Down
76 changes: 58 additions & 18 deletions AGENTS.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Agent Instructions
# Working with the Codebase

## Tox

Expand Down Expand Up @@ -40,21 +40,61 @@ Do NOT edit these directly — modify source scripts instead:
3. Add to group in `scripts/split_tox_gh_actions/split_tox_gh_actions.py`
4. Run `scripts/generate-test-files.sh`

## Integration Contract

- Don't crash applications or swallow exceptions
- Don't mutate object references or alter function signatures
- Don't leak file descriptors or make unexpected DB requests
- Write defensive code
- Use end-to-end tests (not mocks)

## Key Paths

| Path | Description |
|------|-------------|
| `sentry_sdk/integrations/` | integration modules |
| `sentry_sdk/ai/` | AI monitoring |
| `sentry_sdk/crons/` | Cron monitoring |
| `sentry_sdk/profiler/` | Performance profiling |
| `tests/integrations/{name}/` | Integration test suites |
| `scripts/populate_tox/config.py` | Test suite configuration |
# SDK Implementation Guidelines

## General Guidelines

- Don't crash applications. SDK-caused exceptions should always be handled with `capture_internal_exceptions`.
- Don't swallow exceptions not caused by the SDK. The user's app should behave the same as it would without the SDK. If exceptions would bubble all the way up and crash the app, they should do that.
- Don't submit huge PRs. If a big feature can be meaningfully split into several PRs, split it. If the PRs depend on each other, stack them.
- No side effects. Don't make extra DB or HTTP requests or leak file descriptors.
- The user is instructed to initialize the SDK as early as possible. You may assume this is the case.

## Maintainability & Code Structure

- **Don't fragment code unnecessarily**:
- Only extract code into a function if it's used in multiple places or if it's overly complex and distracts from understanding the flow of the neighboring code.
- Prefer one file over splitting implementation into multiple files. Having to follow the flow of code by jumping through several files is not good style.
- Keep constants at the top of the file, under imports.
- Don't inline imports in functions. Strongly prefer adding imports to the top of the file, on the top level.

## Integration Guidelines

When integrating with a package:

- Prefer the following approaches, in this order of preference:
1) Signals, hooks, callbacks provided by the package
2) Monkeypatching public functions
3) Monkeypatching private functions (the more integral to the package, the better, as they're less likely to change)
4) Other approaches only if the above fails
- A mix of the approaches above is also acceptable.
- **Minimize state.**
- If you need to store state (for instance, a running span), prefer storing it on an object of the package that gets passed around "for free".
- Keeping state manually (e.g., implementing lookup tables) should be a last resort option.
- Write code for the most common usecase. Keep scope small. Features can always be added later, if requested. Don't design for special cases.
- Don't mutate object references or alter function signatures.
- Take into account that packages evolve and change.
- When monkeypatching a function, unless it's public, allow for it changing the order of arguments, or adding an argument, in the future.
```python
# Bad monkeypatching
def patched_func(arg_you_need, another_arg, third_arg):
# Don't spell out all arguments. If a new argument is added or an argument
# we don't use is renamed, the patch breaks.
...

# Good monkeypatching
def patched_func(arg_you_need, *args, **kwargs):
# Only assume the argument you need is there. Leave the rest of the
# arguments flexible, so that we don't break if they change.
...
```

## Test Guidelines

- Don't use mocks unless it can't be avoided.
- Use end-to-end tests, not unit tests.
- Avoid testing integration helpers or private methods directly.
- Avoid testing things that can't realistically break.
- Avoid duplicating tests (extend an existing one or use `parametrize`).
- Assert on what Sentry captures with `capture_events`/`capture_items`.
50 changes: 41 additions & 9 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,38 @@ Want to give it a spin? Be our guest and [let us know](https://github.com/getsen
- [2.x to 3.x migration guide](https://docs.sentry.io/platforms/python/migration/2.x-to-3.x)
- [detailed changelog](https://github.com/getsentry/sentry-python/blob/major/3.0/MIGRATION_GUIDE.md)

## 2.73.0

### New Features ✨

- (arq) Add an option to monitor arq cron jobs by @wedamija in [#8051](https://github.com/getsentry/sentry-python/pull/8051)
- (huey) Add an option to monitor Huey periodic tasks by @wedamija in [#8052](https://github.com/getsentry/sentry-python/pull/8052)
- (rq) Add an option to monitor rq-scheduler jobs by @wedamija in [#8053](https://github.com/getsentry/sentry-python/pull/8053)
- (types) Export Attributes from the public types module by @sansynx in [#8019](https://github.com/getsentry/sentry-python/pull/8019)

### Bug Fixes 🐛

- (arq) Don't monitor cron jobs with unsupported schedules by @wedamija in [#8098](https://github.com/getsentry/sentry-python/pull/8098)
- (attributes) Handle special float values correctly by @sentrivana in [#8067](https://github.com/getsentry/sentry-python/pull/8067)
- (celery) Don't round down beat schedule intervals by @wedamija in [#7842](https://github.com/getsentry/sentry-python/pull/7842)
- (cohere) Stop swallowing exceptions during stream iteration by @intertermux-code in [#8017](https://github.com/getsentry/sentry-python/pull/8017)
- (huggingface_hub) Stop swallowing exceptions during stream iteration by @intertermux-code in [#8018](https://github.com/getsentry/sentry-python/pull/8018)
- Exclude litellm==1.107.0 from extras by @jonny-norwine in [#8104](https://github.com/getsentry/sentry-python/pull/8104)

### Internal Changes 🔧

#### Deps

- Update github workflows by @renovate in [#8045](https://github.com/getsentry/sentry-python/pull/8045)
- Update github workflows by @renovate in [#8036](https://github.com/getsentry/sentry-python/pull/8036)
- Update github workflows by @renovate in [#7276](https://github.com/getsentry/sentry-python/pull/7276)

#### Other

- (litellm) Require filelock>=4.0.3 on Python 3.10/3.11 by @sentry-junior in [#8026](https://github.com/getsentry/sentry-python/pull/8026)
- (monitor) Stop background health checks in tests that drive the monitor by @sentry-junior in [#8032](https://github.com/getsentry/sentry-python/pull/8032)
- Update `AGENTS.md` by @sentrivana in [#8077](https://github.com/getsentry/sentry-python/pull/8077)
- 🤖 Update test matrix with new releases (10/12) by @github-actions in [#7944](https://github.com/getsentry/sentry-python/pull/7944)

## 2.72.0

Expand Down Expand Up @@ -162,7 +194,7 @@ sentry_sdk.init(
Offers much more flexibility than `send_default_pii`, allowing you to specify what
data should be collected. If `data_collection` is defined, it takes precedence over
`send_default_pii`.

See https://docs.sentry.io/platforms/python/configuration/options/#data_collection
for the available configuration options.

Expand Down Expand Up @@ -767,7 +799,7 @@ Self-hosted Sentry users should opt out with `stream_gen_ai_spans=False`, since
### New Features ✨

- Add integration for `aiomysql` by @tonal in [#4703](https://github.com/getsentry/sentry-python/pull/4703)

We're adding support for the `aiomysql` package. To enable the integration, add it to your `integrations` list:

```python
Expand All @@ -790,7 +822,7 @@ Self-hosted Sentry users should opt out with `stream_gen_ai_spans=False`, since
import sentry_sdk

sentry_sdk.init(...)

with sentry_sdk.start_transaction(name="testing_sentry"):
httpx2.get("https://sentry.io/")
```
Expand Down Expand Up @@ -846,7 +878,7 @@ Self-hosted Sentry users should opt out with `stream_gen_ai_spans=False`, since

Following a previous significant increase of the string truncation limit, we've now completely removed the limit by default.
In case you have large strings in your events, you should now be able to see them.

In rare cases, if you have really long strings (or a lot of them), you might see envelopes being dropped because of their size.
If that happens, you can set the `max_value_length` `init` option to the previous value of `100_000`:

Expand Down Expand Up @@ -1319,17 +1351,17 @@ We've put additional data that might contain sensitive information, like GraphQL

```python
import sentry_sdk

sentry_sdk.init(...)

sentry_sdk.set_attribute("my.attribute", "my value")

# This metric will have "my.attribute" set
sentry_sdk.metrics.count("counter", 1)

# Remove the attribute
sentry_sdk.remove_attribute("my.attribute")

# This log will not have "my.attribute" set
sentry_sdk.logger.info("An info log")
```
Expand Down
1 change: 1 addition & 0 deletions scripts/populate_tox/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,7 @@
# The default "addr" value was removed in https://github.com/cunla/fakeredis-py/commit/0441288fb22c8c191fc716b561e0001cf512abe5.
# from fakeredis.
">=1.1.14": ["fakeredis<2.36.0"],
">=2.0": ["rq-scheduler"],
"<0.9": ["fakeredis<1.0", "redis<3.2.2"],
">=0.9,<0.14": ["fakeredis>=1.0,<1.7.4"],
"py3.7": ["fakeredis!=2.26.0"],
Expand Down
Loading
Loading