New Beta Feature Enable Sentry logs in logging Integration (#4143) by @colin-sentry
You can now send existing log messages to the new Sentry Logs feature.
For more information see: https://github.com/getsentry/sentry/discussions/86804
This is how you can use it (Sentry Logs is in beta right now so the API can still change):
import logging
import sentry_sdk
from sentry_sdk.integrations.logging import LoggingIntegration
# Setup Sentry SDK to send log messages with a level of "error" or higher to Sentry.
sentry_sdk.init(
dsn="...",
_experiments={
"enable_sentry_logs": True
}
integrations=[
LoggingIntegration(sentry_logs_level=logging.ERROR),
]
)
# Your existing logging setup
some_logger = logging.Logger("some-logger")
some_logger.info('In this example info events will not be sent to Sentry logs. my_value=%s', my_value)
some_logger.error('But error events will be sent to Sentry logs. my_value=%s', my_value)
Spotlight: Sample everything 100% w/ Spotlight & no DSN set (#4207) by @BYK
Dramatiq: use set_transaction_name (#4175) by @timdrijvers
toxgen: Make it clearer which suites can be migrated (#4196) by @sentrivana
Move Litestar under toxgen (#4197) by @sentrivana
Added flake8 plugings to pre-commit call of flake8 (#4190) by @antonpirker
Deprecate Scope.user (#4194) by @sentrivana
Fix hanging when capturing long stacktrace (#4191) by @szokeasaurusrex
Fix GraphQL failures (#4208) by @sentrivana
Fix flaky test (#4198) by @sentrivana
Update Ubuntu in Github test runners (#4204) by @antonpirker
_spotlight_url (#4186) by @BYKparsed_body (#4189) by @orhanhenrikchunk item-type in the envelope (#4178) by @vigliamypy config into pyproject.toml (#4181) by @antonpirkerflake8 config into pyproject.toml (#4185) by @antonpirkerpytest config into pyproject.toml (#4184) by @antonpirkeractions/create-github-app-token from 1.11.6 to 1.11.7 (#4188) by @dependabotCODEOWNERS (#4182) by @sentrivanaInvalidOperation (#4179) by @szokeasaurusrexDedupeIntegration's last-seen if before_send dropped the event (#4142) by @sentrivanaapp.host (#4157) by @sentrivanasample_rand on PropagationContext (#4038) by @szokeasaurusrexinit() parameters to ApiDocs. (#4100) by @antonpirkermutable (#4010) by @szokeasaurusrexcron_jobs is set to None in arq integration (#4115) by @antonpirkerattemptId more defensively (#4130) by @sentrivanaquart_flask_patch (#4132) by @sentrivanaTRANSACTION_SOURCE_* constants to Enum (#3889) by @mgalignianaset_context everywhere (#4123) by @sentrivanaNew integration: Add Statsig integration (#4022) by @aliu39
For more information, see the documentation for the StatsigIntegration.
Profiling: Continuous profiling lifecycle (#4017) by @Zylphrex
Fix: Revert "feat(tracing): Add propagate_traces deprecation warning (#3899)" (#4055) by @cmanallen
Tests: Generate Web 1 group tox entries by toxgen script (#3980) by @sentrivana
Tests: Generate Web 2 group tox entries by toxgen script (#3981) by @sentrivana
Tests: Generate Tasks group tox entries by toxgen script (#3976) by @sentrivana
Tests: Generate AI group tox entries by toxgen script (#3977) by @sentrivana
Tests: Generate DB group tox entries by toxgen script (#3978) by @sentrivana
Tests: Generate Misc group tox entries by toxgen script (#3982) by @sentrivana
Tests: Generate Flags group tox entries by toxgen script (#3974) by @sentrivana
Tests: Generate gRPC tox entries by toxgen script (#3979) by @sentrivana
Tests: Remove toxgen cutoff, add statsig (#4048) by @sentrivana
Tests: Reduce continuous profiling test flakiness (#4052) by @Zylphrex
Tests: Fix Clickhouse test (#4053) by @sentrivana
Tests: Fix flaky HTTPS test (#4057) by @Zylphrex
Update sample rate in DSC (#4018) by @sentrivana
Move the GraphQL group over to the tox gen script (#3975) by @sentrivana
Update changelog with profile_session_sample_rate (#4046) by @sentrivana
Fix incompatibility with new Strawberry version (#4026) by @sentrivana
Add failed_request_status_codes to Litestar (#4021) by @vrslev
See https://docs.sentry.io/platforms/python/integrations/litestar/ for details.
Deprecate enable_tracing option (#3935) by @antonpirker
The enable_tracing option is now deprecated. Please use traces_sample_rate instead. See https://docs.sentry.io/platforms/python/configuration/options/#traces_sample_rate for more information.
Explicitly use None default when checking metadata (#4039) by @mpurnell1
Fix bug where concurrent accesses to the flags property could raise a RuntimeError (#4034) by @cmanallen
Add more min versions of frameworks (#3973) by @sentrivana
Set level based on status code for HTTP client breadcrumbs (#4004) by @sentrivana
Don't set transaction status to error on sys.exit(0) (#4025) by @sentrivana
Continuous profiling sample rate (#4002) by @Zylphrex
Set profile_session_sample_rate=1.0 in your init() to collect continuous profiles for 100% of profile sessions. See https://docs.sentry.io/platforms/python/profiling/#enable-continuous-profiling for more information.
Track and report spans that were dropped (#4005) by @constantinius
Change continuous profile buffer size (#3987) by @Zylphrex
Handle MultiPartParserError to avoid internal sentry crash (#4001) by @orhanhenrik
Handle None lineno in get_source_context (#3925) by @sentrivana
Add support for Python 3.12 and 3.13 to AWS Lambda integration (#3965) by @antonpirker
Add propagate_traces deprecation warning (#3899) by @mgaligniana
Check that __module__ is str (#3942) by @szokeasaurusrex
Add __repr__ to Baggage (#4043) by @szokeasaurusrex
Fix a typo (#3923) by @antonpirker
Fix various CI errors on master (#4009) by @Zylphrex
Split gevent tests off (#3964) by @sentrivana
Add tox generation script, but don't use it yet (#3971) by @sentrivana
Use httpx_mock in test_httpx (#3967) by @sl0thentr0py
Fix typo in test name (#4036) by @szokeasaurusrex
Fix mypy (#4019) by @sentrivana
Test Celery's latest RC (#3938) by @sentrivana
Bump actions/create-github-app-token from 1.11.2 to 1.11.3 (#4023) by @dependabot
Bump actions/create-github-app-token from 1.11.1 to 1.11.2 (#4015) by @dependabot
Bump codecov/codecov-action from 5.1.2 to 5.3.1 (#3995) by @dependabot
New integration: Add Typer integration (#3869) by @patrick91
For more information, see the documentation for the TyperIntegration.
New integration: Add Unleash feature flagging integration (#3888) by @aliu39
For more information, see the documentation for the UnleashIntegration.
Add custom tracking of feature flag evaluations (#3860) by @aliu39
Feature Flags: Register LD hook in setup instead of init, and don't check for initialization (#3890) by @aliu39
Feature Flags: Moved adding of flags context into Scope (#3917) by @antonpirker
Create a separate group for feature flag test suites (#3911) by @sentrivana
Fix flaky LaunchDarkly tests (#3896) by @aliu39
Fix LRU cache copying (#3883) by @ffelixg
Fix cache pollution from mutable reference (#3887) by @cmanallen
Centralize minimum version checking (#3910) by @sentrivana
Support SparkIntegration activation after SparkContext created (#3411) by @seyoon-lim
Preserve ARQ enqueue_job kwdefaults after patching (#3903) by @danmr
Add Github workflow to comment on issues when a fix was released (#3866) by @antonpirker
Update test matrix for Sanic (#3904) by @antonpirker
Rename scripts (#3885) by @sentrivana
Fix CI (#3878) by @sentrivana
Treat potel-base as release branch in CI (#3912) by @sentrivana
build(deps): bump actions/create-github-app-token from 1.11.0 to 1.11.1 (#3893) by @dependabot
build(deps): bump codecov/codecov-action from 5.0.7 to 5.1.1 (#3867) by @dependabot
build(deps): bump codecov/codecov-action from 5.1.1 to 5.1.2 (#3892) by @dependabot
scope.client reference as well (#3857) by @sl0thentr0py5.5.0rc3 (#3842) by @sentrivanacodecov/codecov-action from 5.0.2 to 5.0.7 (#3821) by @dependabotrust_tracing integration. See https://docs.sentry.io/platforms/python/integrations/rust_tracing/ (#3717) by @matt-codecovsentry_sdk.init context manager (#3729) by @szokeasaurusrexstack_info for the LoggingIntegration (#3745) by @gmcrocettiretries_left before capturing exception (#3803) by @malkovrohttp.client span on timeout (#3723) by @Zylphrexh2 existence in HTTP/2 transport (#3690) by @BYKtype() instead when extracting frames (#3716) by @Zylphrexpython_multipart import over multipart (#3710) by @musicinmybrainpytest for tornado-latest tests (#3714) by @szokeasaurusrexpytest-asyncio for redis tests (Python 3.12-13) (#3706) by @szokeasaurusrexpytest for celery tests (#3701) by @szokeasaurusrexpytest on Python 3.8+ gevent tests (#3700) by @szokeasaurusrexpytest for Python 3.8+ common tests (#3697) by @szokeasaurusrexpytest pin in requirements-devenv.txt (#3696) by @szokeasaurusrexensure_integration_enabled_async (#3632) by @sentrivanasphinx (#3650) by @sentrivanaactions/checkout from 4.2.0 to 4.2.1 (#3651) by @dependabotBottle: Add failed_request_status_codes (#3618) by @szokeasaurusrex
You can now define a set of integers that will determine which status codes should be reported to Sentry.
sentry_sdk.init(
integrations=[
BottleIntegration(
failed_request_status_codes={403, *range(500, 600)},
)
]
)
Examples of valid failed_request_status_codes:
{500} will only send events on HTTP 500.{400, *range(500, 600)} will send events on HTTP 400 as well as the 5xx range.{500, 503} will send events on HTTP 500 and 503.set() (the empty set) will not send events for any HTTP status code.The default is {*range(500, 600)}, meaning that all 5xx status codes are reported to Sentry.
Bottle: Delete never-reached code (#3605) by @szokeasaurusrex
Redis: Remove flaky test (#3626) by @sentrivana
Django: Improve getting psycopg3 connection info (#3580) by @nijel
Django: Add SpotlightMiddleware when Spotlight is enabled (#3600) by @BYK
Django: Open relevant error when SpotlightMiddleware is on (#3614) by @BYK
Django: Support http_methods_to_capture in ASGI Django (#3607) by @sentrivana
ASGI Django now also supports the http_methods_to_capture integration option. This is a configurable tuple of HTTP method verbs that should create a transaction in Sentry. The default is ("CONNECT", "DELETE", "GET", "PATCH", "POST", "PUT", "TRACE",). OPTIONS and HEAD are not included by default.
Here's how to use it:
sentry_sdk.init(
integrations=[
DjangoIntegration(
http_methods_to_capture=("GET", "POST"),
),
],
)
sample_rate in DSC (and add explanatory tests) (#3603) by @antonpirkerhttpcore based HTTP2Transport (#3588) by @BYK__notes__ support (#3620) by @szokeasaurusrexcodecov/codecov-action from 4.5.0 to 4.6.0 (#3617) by @dependabotConfigure HTTP methods to capture in ASGI/WSGI middleware and frameworks (#3531) by @antonpirker
We've added a new option to the Django, Flask, Starlette and FastAPI integrations called http_methods_to_capture. This is a configurable tuple of HTTP method verbs that should create a transaction in Sentry. The default is ("CONNECT", "DELETE", "GET", "PATCH", "POST", "PUT", "TRACE",). OPTIONS and HEAD are not included by default.
Here's how to use it (substitute Flask for your framework integration):
sentry_sdk.init(
integrations=[
FlaskIntegration(
http_methods_to_capture=("GET", "POST"),
),
],
)
Django: Allow ASGI to use drf_request in DjangoRequestExtractor (#3572) by @PakawiNz
Django: Don't let RawPostDataException bubble up (#3553) by @sentrivana
Django: Add sync_capable to SentryWrappingMiddleware (#3510) by @szokeasaurusrex
AIOHTTP: Add failed_request_status_codes (#3551) by @szokeasaurusrex
You can now define a set of integers that will determine which status codes should be reported to Sentry.
sentry_sdk.init(
integrations=[
AioHttpIntegration(
failed_request_status_codes={403, *range(500, 600)},
)
]
)
Examples of valid failed_request_status_codes:
{500} will only send events on HTTP 500.{400, *range(500, 600)} will send events on HTTP 400 as well as the 5xx range.{500, 503} will send events on HTTP 500 and 503.set() (the empty set) will not send events for any HTTP status code.The default is {*range(500, 600)}, meaning that all 5xx status codes are reported to Sentry.
AIOHTTP: Delete test which depends on AIOHTTP behavior (#3568) by @szokeasaurusrex
AIOHTTP: Handle invalid responses (#3554) by @szokeasaurusrex
FastAPI/Starlette: Support new failed_request_status_codes (#3563) by @szokeasaurusrex
The format of failed_request_status_codes has changed from a list
of integers and containers to a set:
sentry_sdk.init(
integrations=StarletteIntegration(
failed_request_status_codes={403, *range(500, 600)},
),
)
The old way of defining failed_request_status_codes will continue to work
for the time being. Examples of valid new-style failed_request_status_codes:
{500} will only send events on HTTP 500.{400, *range(500, 600)} will send events on HTTP 400 as well as the 5xx range.{500, 503} will send events on HTTP 500 and 503.set() (the empty set) will not send events for any HTTP status code.The default is {*range(500, 600)}, meaning that all 5xx status codes are reported to Sentry.
FastAPI/Starlette: Fix failed_request_status_codes=[] (#3561) by @szokeasaurusrex
FastAPI/Starlette: Remove invalid failed_request_status_code tests (#3560) by @szokeasaurusrex
FastAPI/Starlette: Refactor shared test parametrization (#3562) by @szokeasaurusrex
sentry_sdk.metrics (#3512) by @szokeasaurusrexname parameter to start_span() and deprecate description parameter (#3524 & #3525) by @antonpirkeradd_query_source with modules outside of project root (#3313) by @rominfget_integration typing (#3550) by @szokeasaurusrexlogger.warn (#3552) by @sentrivanaexplain_plan feature. (#3534) by @antonpirkeractions/upload-artifact to v4 with merge (#3545) by @joshuarliactions/checkout from 4.1.7 to 4.2.0 (#3585) by @dependabotNew SysExitIntegration (#3401) by @szokeasaurusrex
For more information, see the documentation for the SysExitIntegration.
Add SENTRY_SPOTLIGHT env variable support (#3443) by @BYK
Support Strawberry 0.239.2 (#3491) by @szokeasaurusrex
Add separate pii_denylist to EventScrubber and run it always (#3463) by @sl0thentr0py
Celery: Add wrapper for Celery().send_task to support behavior as Task.apply_async (#2377) by @divaltor
Django: SentryWrappingMiddleware.init fails if super() is object (#2466) by @cameron-simpson
Fix data_category for sessions envelope items (#3473) by @sl0thentr0py
Fix non-UTC timestamps (#3461) by @szokeasaurusrex
Remove obsolete object as superclass (#3480) by @sentrivana
Replace custom TYPE_CHECKING with stdlib typing.TYPE_CHECKING (#3447) by @dev-satoshi
Refactor tracing_utils.py (#3452) by @rominf
Explicitly export symbol in subpackages instead of ignoring (#3400) by @hartungstenio
Better test coverage reports (#3498) by @antonpirker
Fixed config for old coverage versions (#3504) by @antonpirker
Fix AWS Lambda tests (#3495) by @antonpirker
Remove broken Bottle tests (#3505) by @sentrivana
New integration: Ray (#2400) (#2444) by @glowskir
Usage: (add the RayIntegration to your sentry_sdk.init() call and make sure it is called in the worker processes)
import ray
import sentry_sdk
from sentry_sdk.integrations.ray import RayIntegration
def init_sentry():
sentry_sdk.init(
dsn="...",
traces_sample_rate=1.0,
integrations=[RayIntegration()],
)
init_sentry()
ray.init(
runtime_env=dict(worker_process_setup_hook=init_sentry),
)
For more information, see the documentation for the Ray integration.
New integration: Litestar (#2413) (#3358) by @KellyWalker
Usage: (add the LitestarIntegration to your sentry_sdk.init())
from litestar import Litestar, get
import sentry_sdk
from sentry_sdk.integrations.litestar import LitestarIntegration
sentry_sdk.init(
dsn="...",
traces_sample_rate=1.0,
integrations=[LitestarIntegration()],
)
@get("/")
async def index() -> str:
return "Hello, world!"
app = Litestar(...)
For more information, see the documentation for the Litestar integration.
New integration: Dramatiq from @jacobsvante (#3397) by @antonpirker
Usage: (add the DramatiqIntegration to your sentry_sdk.init())
import dramatiq
import sentry_sdk
from sentry_sdk.integrations.dramatiq import DramatiqIntegration
sentry_sdk.init(
dsn="...",
traces_sample_rate=1.0,
integrations=[DramatiqIntegration()],
)
@dramatiq.actor(max_retries=0)
def dummy_actor(x, y):
return x / y
dummy_actor.send(12, 0)
For more information, see the documentation for the Dramatiq integration.
New config option: Expose custom_repr function that precedes safe_repr invocation in serializer (#3438) by @sl0thentr0py
See: https://docs.sentry.io/platforms/python/configuration/options/#custom-repr
Profiling: Add client SDK info to profile chunk (#3386) by @Zylphrex
Serialize vars early to avoid living references (#3409) by @sl0thentr0py
Deprecate hub-based sessions.py logic (#3419) by @szokeasaurusrex
Deprecate is_auto_session_tracking_enabled (#3428) by @szokeasaurusrex
Add note to generated yaml files (#3423) by @sentrivana
Slim down PR template (#3382) by @sentrivana
Use new banner in readme (#3390) by @sentrivana
push_scope deprecation warning (#3355) (#3355) by @szokeasaurusrexpush_scope (#3353, #3354) by @szokeasaurusrexconfigure_scope (#3348, #3349, #3350, #3351) by @szokeasaurusrexai_track decorator (#3376) by @czyberadd_attachment type (#3342) by @szokeasaurusrex0feb234 to 6d2c435 (#3369) by @dependabot88273a9 to 0feb234 (#3252) by @dependabotThis is a security backport release.
Don't send full env to subprocess (892dd800) by @kmichel-aiven
See also https://github.com/getsentry/sentry-python/security/advisories/GHSA-g92j-qhmh-64v2
Add disabled_integrations (#3328) by @sentrivana
Disabling individual integrations is now much easier. Instead of disabling all automatically enabled integrations and specifying the ones you want to keep, you can now use the new disabled_integrations config option to provide a list of integrations to disable:
import sentry_sdk
from sentry_sdk.integrations.flask import FlaskIntegration
sentry_sdk.init(
# Do not use the Flask integration even if Flask is installed.
disabled_integrations=[
FlaskIntegration(),
],
)
Use operation name as transaction name in Strawberry (#3294) by @sentrivana
WSGI integrations respect SCRIPT_NAME env variable (#2622) by @sarvaSanjay
Make Django DB spans have origin auto.db.django (#3319) by @antonpirker
Sort breadcrumbs by time before sending (#3307) by @antonpirker
Fix KeyError('sentry-monitor-start-timestamp-s') (#3278) by @Mohsen-Khodabakhshi
Set MongoDB tags directly on span data (#3290) by @0Calories
Lower logger level for some messages (#3305) by @sentrivana and @antonpirker
Emit deprecation warnings from Hub API (#3280) by @szokeasaurusrex
Clarify that instrumenter is internal-only (#3299) by @szokeasaurusrex
Support Django 5.1 (#3207) by @sentrivana
Remove apparently unnecessary if (#3298) by @szokeasaurusrex
Preliminary support for Python 3.13 (#3200) by @sentrivana
Move sentry_sdk.init out of hub.py (#3276) by @szokeasaurusrex
Unhardcode integration list (#3240) by @rominf
Allow passing of PostgreSQL port in tests (#3281) by @rominf
Add tests for @ai_track decorator (#3325) by @colin-sentry
Do not include type checking code in coverage report (#3327) by @antonpirker
Fix test_installed_modules (#3309) by @szokeasaurusrex
Fix typos and grammar in a comment (#3293) by @szokeasaurusrex
Fixed failed tests setup (#3303) by @antonpirker
Only assert warnings we are interested in (#3314) by @szokeasaurusrex