Repository navigation
[do not merge] Testing sync - #8230
Merged
Merged
Conversation
…den (#8185) ### Description If there's an incoming sampling decision, `traces_sample_rate` is irrelevant and shouldn't overwrite the sampling rate in the DSC. There are cases where we do want to override the incoming sampling decision, but only in cases where the SDK actually uses a different sample rate for some reason (`traces_sampler`). #### Issues Closes #8182 #### Reminders - Please add tests to validate your changes, and lint your code using `uv run ruff`. - Add GH Issue ID _&_ Linear ID (if applicable) - PR title should use [conventional commit](https://develop.sentry.dev/engineering-practices/commit-messages/#type) style (`feat:`, `fix:`, `ref:`, `meta:`) - For external contributors: [CONTRIBUTING.md](https://github.com/getsentry/sentry-python/blob/master/CONTRIBUTING.md), [Sentry SDK development docs](https://develop.sentry.dev/sdk/), [Discord community](https://discord.gg/Ww9hbqr)
Include reasoning parts in `gen_ai.output.messages` based on Anthropic thinking blocks. Extend `EXAMPLE_MESSAGE` in tests to include a thinking part when a supported library version is installed. Stop re-using `EXAMPLE_MESSAGE` in streaming responses and create two fixtures to reduce duplication among streaming responses in tests.
Accumulate thinking output in the same format as the nonstreaming path so `_set_output_data()` can format the thinking parts as reasoning parts that the product understands.
Migrate to https://conventions.sentry.dev/ Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Turns on Warden incremental review for `find-bugs`, `code-review`, `skill-scanner`. On each push, these skills now skip hunks that an earlier clean run on the same PR already reviewed, instead of re-reviewing the whole PR. Other skills in this repo keep full review. Warden falls back to a full review when there is no usable baseline: first push, force push, config or skill change, or an earlier run that requested changes or had failures. This needs the org base config to set `incrementalApp = "sentry-warden"` (getsentry/.github#223); until that lands, Warden warns and keeps doing full reviews. <!-- junior-request-attribution:start --> via **Jeffrey Hung**. <!-- junior-request-attribution:end --> <!-- junior-session-footer:start --> <!-- junior-conversation-id:slack%3AD0AH1TP6CHJ%3A1793906366.333339 --> -- [View Session](https://junior-prod.sentry.dev/conversations/slack%3AD0AH1TP6CHJ%3A1793906366.333339) [[Sentry]](https://sentry.sentry.io/explore/conversations/slack%3AD0AH1TP6CHJ%3A1793906366.333339/?project=4510944073809921) <!-- junior-session-footer:end --> Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com> Co-authored-by: Jeffrey Hung <jeffrey.hung@sentry.io>
…8198) ### Description Marks functions wrapped with `@sentry_sdk.monitor`, so scheduler integrations can skip jobs that already send their own check-ins. The arq integration now does this, so those jobs don't report twice. Also moves arq's time zone lookup into `sentry_sdk/crons/utils.py` so other cron integrations can share it, and stops sending names that aren't IANA zones (like tzlocal's `local`), which Sentry would reject. This is the base for #7840 (APScheduler), which uses both. ### Testing New arq test for a `@sentry_sdk.monitor` cron job. The existing arq time zone tests cover the helper.
### Description Removes `ContinuousScheduler.pause()` from `sentry_sdk/profiler/continuous_profiler.py` (3 lines). It's a stub that only raises `NotImplementedError`, and nothing implements it or calls it. #2830 (Jun 2024, "Introduce continuous profiling mode") added it next to `ensure_running()` and `teardown()`. Unlike those two, no subclass ever overrode it, and the SDK never called it. The stub makes it look like the continuous profiler can be paused, but it can't. **Evidence** - `git grep -nw pause` on `master` finds only the definition. Nothing in `sentry_sdk/`, `tests/`, `scripts/` or `docs/` refers to it. - `ThreadContinuousScheduler` and `GeventContinuousScheduler`, the only subclasses, override `ensure_running()` and `teardown()` but not `pause()`. - `git log -S "def pause"` finds only #2830. `git log -S ".pause("` across `sentry_sdk` and `tests` finds no commits, so it has never had a caller. - `ContinuousScheduler` isn't exported from `sentry_sdk.profiler` (`__all__` lists only the transaction-profiler schedulers) and isn't documented. - No open PR or issue mentions it. #7275 also touches `continuous_profiler.py`, but in different hunks (`ThreadContinuousScheduler.__init__`). **Why it's safe** - `ContinuousScheduler` is an internal class. The method is unreachable, so behavior doesn't change, and no public API or documented behavior is affected. **Checks** - `uv run ruff check` / `ruff format --check` on `sentry_sdk/profiler`: clean - `uv run --group typing mypy sentry_sdk`: no issues - `TESTPATH=tests/profiler uv run tox -e py3.14-common`: 106 passed, 69 skipped. The skipped tests are the gevent cases, which need gevent installed. #### Issues None. Found by the weekly sentry-python removal scout. <!-- junior-request-attribution:start --> via [automation `sched_65eed06cc199036c2b13411096f412d4`](https://junior-prod.sentry.dev/automations/sched_65eed06cc199036c2b13411096f412d4) · Run ID `sched_65eed06cc199036c2b13411096f412d4:1794211200000`. <!-- junior-request-attribution:end --> <!-- junior-session-footer:start --> <!-- junior-conversation-id:agent-dispatch%3Adispatch_0096be51ec4ca0f294d1b5786520632b --> -- [View Session](https://junior-prod.sentry.dev/conversations/agent-dispatch%3Adispatch_0096be51ec4ca0f294d1b5786520632b) [[Sentry]](https://sentry.sentry.io/explore/conversations/agent-dispatch%3Adispatch_0096be51ec4ca0f294d1b5786520632b/?project=4510944073809921) <!-- junior-session-footer:end --> Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com>
find-bugs overlaps code-review, so this consolidates Warden on one bug-finding skill. This repo already runs code-review on the same PR triggers, so this only drops the duplicate skill. <!-- junior-request-attribution:start --> via @dcramer. <!-- junior-request-attribution:end --> <!-- junior-session-footer:start --> <!-- junior-conversation-id:agent%3A002d98fb2946503b1e169e66abf9b139 --> -- [View Session](https://junior-prod.sentry.dev/conversations/agent%3A002d98fb2946503b1e169e66abf9b139) [[Sentry]](https://sentry.sentry.io/explore/conversations/agent%3A002d98fb2946503b1e169e66abf9b139/?project=4510944073809921) <!-- junior-session-footer:end --> Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com> Co-authored-by: David Cramer <23610+dcramer@users.noreply.github.com>
…ackages (#8215) ### Description `package_version()` in `sentry_sdk/utils.py` rebuilt the full installed-package mapping on every call: `_get_installed_modules()` iterates `importlib.metadata.distributions()` (parsing every installed distribution's metadata), and `package_version` additionally re-normalized that whole mapping per call. Integrations call `package_version` during `sentry_sdk.init()` to check minimum versions, so in environments with a few hundred installed packages this scan measurably slowed SDK startup. This change makes `package_version` look up the single requested distribution with `importlib.metadata.version()` instead: - Top-level guarded `from importlib import metadata as importlib_metadata` (no inline imports, per the repo guidelines); `PackageNotFoundError` maps to `None`, matching the previous behaviour for missing packages. - The existing `_get_installed_modules()` scan remains as the fallback for environments without `importlib.metadata` (Python < 3.8), so supported old interpreters keep working. - Name handling is unchanged: the requested name is PEP 503-normalized first, which is also how `importlib.metadata.version()` resolves distribution names. Tests in `tests/test_utils.py`: - `test_package_version_installed_package` asserts an installed package (`pytest`) resolves to the same parsed version as `importlib.metadata`. - `test_package_version_does_not_scan_all_installed_packages` monkeypatches `_get_installed_modules` to fail if invoked (the only way to assert the scan no longer happens) and asserts both hit and miss lookups still work. Validation: - `TESTPATH=tests/test_utils.py uv run tox -e py3.12-common -- -k package_version` — 3 passed. - `uv run ruff check` / `ruff format --check` on the changed files — clean. - `uv run --group typing mypy sentry_sdk` — no issues in 203 files. #### Issues * resolves: #8190 #### Reminders - Tests added and linted with `uv run ruff` as requested. - PR title uses conventional-commit style. Co-authored-by: Adityaaa <144815351+addydude@users.noreply.github.com>
Contributor
Coverage Results 📊✅ 57871 passed | ⏭️ 3012 skipped | Total: 60883 | Pass Rate: 95.05% | Execution Time: 154m 24s All tests are passing successfully. ✅ Patch coverage is 88.79% (2852 of 3212 changed executable lines covered; target 80%). Changed files with executable lines (143)
Coverage diff@@ Coverage Diff @@
## master #8230 +/-##
==========================================
+ Coverage 90.34% 90.36% +0.02%
==========================================
Files 203 199 -4
Tracked lines 26931 21337 -5594
Branches 10058 7378 -2680
==========================================
- Hits 24331 19281 -5050
+ Misses 2600 2056 -544
+ Partials 1517 1234 -283Generated by Coverage Action |
6 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.