NewYour coding agent can read the release notes before it upgrades.Set up the MCP server →
PyPI · #235 most downloaded on PyPI
Python client for Sentry (https://sentry.io)
Last release 4 days ago
15 Sep 2026
Ships on a steady schedule
a new release about every 2 weeks
Nearly every release is documented
notes for 60 of the last 60 stable releases
2 versions withdrawn
withdrawn after publishing
8 years old
349 releases · first in 2018
The deprecated with_locals configuration option was removed. Use include_local_variables instead. See https://docs.sentry.io/platforms/python/configur…
The Pyramid integration will not capture errors that might happen in authenticated_userid() in a custom AuthenticationPolicy class.
The method need_code_loation of the MetricsAggregator was renamed to need_code_location.
The BackgroundWorker thread used to process events was renamed from raven-sentry.BackgroundWorker to sentry-sdk.BackgroundWorker.
The reraise function was moved from sentry_sdk._compat to sentry_sdk.utils.
The _ScopeManager was moved from sentry_sdk.hub to sentry_sdk.scope.
Moved the contents of tracing_utils_py3.py to tracing_utils.py. The start_child_span_decorator is now in sentry_sdk.tracing_utils.
The actual implementation of get_current_span was moved to sentry_sdk.tracing_utils. sentry_sdk.get_current_span is still accessible as part of the top-level API.
sentry_sdk.tracing_utils.get_current_span() does now take a scope instead of a hub as parameter.
sentry_sdk.utils._get_contextvars does not return a tuple with three values, but a tuple with two values. The copy_context was removed.
If you create a transaction manually and later mutate the transaction in a configure_scope block this does not work anymore. Here is a recipe on how to change your code to make it work:
Your existing implementation:
transaction = sentry_sdk.transaction(...)
# later in the code execution:
with sentry_sdk.configure_scope() as scope:
scope.set_transaction_name("new-transaction-name")
needs to be changed to this:
transaction = sentry_sdk.transaction(...)
# later in the code execution:
scope = sentry_sdk.Scope.get_current_scope()
scope.set_transaction_name("new-transaction-name")
The classes listed in the table below are now abstract base classes. Therefore, they can no longer be instantiated. Subclasses can only be instantiated if they implement all of the abstract methods. <details> <summary><b>Show table</b></summary>
| Class | Abstract methods |
|---|---|
sentry_sdk.integrations.Integration |
setup_once |
sentry_sdk.metrics.Metric |
add, serialize_value, and weight |
sentry_sdk.profiler.Scheduler |
setup and teardown |
sentry_sdk.transport.Transport |
capture_envelope |
</details>
last_event_id() top level API. The last event ID is still returned by capture_event(), capture_exception() and capture_message() but the top level API sentry_sdk.last_event_id() has been removed./store endpoint. Everything is now sent to the /envelope endpoint. If you're on SaaS you don't have to worry about this, but if you're running Sentry yourself you'll need version 20.6.0 or higher of self-hosted Sentry.with_locals configuration option was removed. Use include_local_variables instead. See https://docs.sentry.io/platforms/python/configuration/options/#include-local-variables.request_bodies configuration option was removed. Use max_request_body_size. See https://docs.sentry.io/platforms/python/configuration/options/#max-request-body-size.user.segment. It was also removed from the trace header as well as from the dynamic sampling context.install method for custom integrations. Please use setup_once instead.sentry_sdk.tracing.Span.new_span. Use sentry_sdk.tracing.Span.start_child instead.sentry_sdk.tracing.Transaction.new_span. Use sentry_sdk.tracing.Transaction.start_child instead.sentry_sdk.utils.Auth.store_api_url.sentry_sdk.utils.Auth.get_api_url's now accepts a sentry_sdk.consts.EndpointType enum instead of a string as its only parameter. We recommend omitting this argument when calling the function, since the parameter's default value is the only possible sentry_sdk.consts.EndpointType value. The parameter exists for future compatibility.tracing_utils_py2.py. The start_child_span_decorator is now in sentry_sdk.tracing_utils.sentry_sdk.profiler.Scheduler.stop_profiling method. Any calls to this method can simply be removed, since this was a no-op method.profiler_mode and profiles_sample_rate have been deprecated as _experiments options. Use them as top level options instead:sentry_sdk.init(
...,
profiler_mode="thread",
profiles_sample_rate=1.0,
)
sentry_sdk.transport.Transport.capture_event. Please use sentry_sdk.transport.Transport.capture_envelope, instead.sentry_sdk.init's transport keyword argument has been deprecated. If you wish to provide a custom transport, please pass a sentry_sdk.transport.Transport instance or a subclass.propagate_hub in ThreadingIntegration() was deprecated and renamed to propagate_scope.One column per quarter.
The deprecated with_locals configuration option was removed. Use include_local_variables instead. See https://docs.sentry.io/platforms/python/configur…
The Pyramid integration will not capture errors that might happen in authenticated_userid() in a custom AuthenticationPolicy class.
The method need_code_loation of the MetricsAggregator was renamed to need_code_location.
The BackgroundWorker thread used to process events was renamed from raven-sentry.BackgroundWorker to sentry-sdk.BackgroundWorker.
The reraise function was moved from sentry_sdk._compat to sentry_sdk.utils.
The _ScopeManager was moved from sentry_sdk.hub to sentry_sdk.scope.
Moved the contents of tracing_utils_py3.py to tracing_utils.py. The start_child_span_decorator is now in sentry_sdk.tracing_utils.
The actual implementation of get_current_span was moved to sentry_sdk.tracing_utils. sentry_sdk.get_current_span is still accessible as part of the top-level API.
sentry_sdk.tracing_utils.get_current_span() does now take a scope instead of a hub as parameter.
sentry_sdk.utils._get_contextvars does not return a tuple with three values, but a tuple with two values. The copy_context was removed.
If you create a transaction manually and later mutate the transaction in a configure_scope block this does not work anymore. Here is a recipe on how to change your code to make it work:
Your existing implementation:
transaction = sentry_sdk.transaction(...)
# later in the code execution:
with sentry_sdk.configure_scope() as scope:
scope.set_transaction_name("new-transaction-name")
needs to be changed to this:
transaction = sentry_sdk.transaction(...)
# later in the code execution:
scope = sentry_sdk.Scope.get_current_scope()
scope.set_transaction_name("new-transaction-name")
The classes listed in the table below are now abstract base classes. Therefore, they can no longer be instantiated. Subclasses can only be instantiated if they implement all of the abstract methods. <details> <summary><b>Show table</b></summary>
| Class | Abstract methods |
|---|---|
sentry_sdk.integrations.Integration |
setup_once |
sentry_sdk.metrics.Metric |
add, serialize_value, and weight |
sentry_sdk.profiler.Scheduler |
setup and teardown |
sentry_sdk.transport.Transport |
capture_envelope |
</details>
last_event_id() top level API. The last event ID is still returned by capture_event(), capture_exception() and capture_message() but the top level API sentry_sdk.last_event_id() has been removed./store endpoint. Everything is now sent to the /envelope endpoint. If you're on SaaS you don't have to worry about this, but if you're running Sentry yourself you'll need version 20.6.0 or higher of self-hosted Sentry.with_locals configuration option was removed. Use include_local_variables instead. See https://docs.sentry.io/platforms/python/configuration/options/#include-local-variables.request_bodies configuration option was removed. Use max_request_body_size. See https://docs.sentry.io/platforms/python/configuration/options/#max-request-body-size.user.segment. It was also removed from the trace header as well as from the dynamic sampling context.install method for custom integrations. Please use setup_once instead.sentry_sdk.tracing.Span.new_span. Use sentry_sdk.tracing.Span.start_child instead.sentry_sdk.tracing.Transaction.new_span. Use sentry_sdk.tracing.Transaction.start_child instead.sentry_sdk.utils.Auth.store_api_url.sentry_sdk.utils.Auth.get_api_url's now accepts a sentry_sdk.consts.EndpointType enum instead of a string as its only parameter. We recommend omitting this argument when calling the function, since the parameter's default value is the only possible sentry_sdk.consts.EndpointType value. The parameter exists for future compatibility.tracing_utils_py2.py. The start_child_span_decorator is now in sentry_sdk.tracing_utils.sentry_sdk.profiler.Scheduler.stop_profiling method. Any calls to this method can simply be removed, since this was a no-op method.profiler_mode and profiles_sample_rate have been deprecated as _experiments options. Use them as top level options instead:sentry_sdk.init(
...,
profiler_mode="thread",
profiles_sample_rate=1.0,
)
sentry_sdk.transport.Transport.capture_event. Please use sentry_sdk.transport.Transport.capture_envelope, instead.sentry_sdk.init's transport keyword argument has been deprecated. If you wish to provide a custom transport, please pass a sentry_sdk.transport.Transport instance or a subclass.propagate_hub in ThreadingIntegration() was deprecated and renamed to propagate_scope.The deprecated with_locals configuration option was removed. Use include_local_variables instead. See https://docs.sentry.io/platforms/python/configur…
Sentry SDK 2.0.0a2 is alpha software and not yet ready for production!
Please give it a spin and test it with your project. If you have any questions or feedback please contact us on Discord in the #python channel or create a GitHub Issue or start a GitHub Discussion.
Thanks!
The Pyramid integration will not capture errors that might happen in authenticated_userid() in a custom AuthenticationPolicy class.
The method need_code_loation of the MetricsAggregator was renamed to need_code_location.
The BackgroundWorker thread used to process events was renamed from raven-sentry.BackgroundWorker to sentry-sdk.BackgroundWorker.
The reraise function was moved from sentry_sdk._compat to sentry_sdk.utils.
The _ScopeManager was moved from sentry_sdk.hub to sentry_sdk.scope.
Moved the contents of tracing_utils_py3.py to tracing_utils.py. The start_child_span_decorator is now in sentry_sdk.tracing_utils.
The actual implementation of get_current_span was moved to sentry_sdk.tracing_utils. sentry_sdk.get_current_span is still accessible as part of the top-level API.
sentry_sdk.tracing_utils.get_current_span() does now take a scope instead of a hub as parameter.
sentry_sdk.utils._get_contextvars does not return a tuple with three values, but a tuple with two values. The copy_context was removed.
If you create a transaction manually and later mutate the transaction in a configure_scope block this does not work anymore. Here is a recipe on how to change your code to make it work:
Your existing implementation:
transaction = sentry_sdk.transaction(...)
# later in the code execution:
with sentry_sdk.configure_scope() as scope:
scope.set_transaction_name("new-transaction-name")
needs to be changed to this:
transaction = sentry_sdk.transaction(...)
# later in the code execution:
scope = sentry_sdk.Scope.get_current_scope()
scope.set_transaction_name("new-transaction-name")
The classes listed in the table below are now abstract base classes. Therefore, they can no longer be instantiated. Subclasses can only be instantiated if they implement all of the abstract methods. <details> <summary><b>Show table</b></summary>
| Class | Abstract methods |
|---|---|
sentry_sdk.integrations.Integration |
setup_once |
sentry_sdk.metrics.Metric |
add, serialize_value, and weight |
sentry_sdk.profiler.Scheduler |
setup and teardown |
sentry_sdk.transport.Transport |
capture_envelope |
</details>
last_event_id() top level API. The last event ID is still returned by capture_event(), capture_exception() and capture_message() but the top level API sentry_sdk.last_event_id() has been removed./store endpoint. Everything is now sent to the /envelope endpoint. If you're on SaaS you don't have to worry about this, but if you're running Sentry yourself you'll need version 20.6.0 or higher of self-hosted Sentry.with_locals configuration option was removed. Use include_local_variables instead. See https://docs.sentry.io/platforms/python/configuration/options/#include-local-variables.request_bodies configuration option was removed. Use max_request_body_size. See https://docs.sentry.io/platforms/python/configuration/options/#max-request-body-size.user.segment. It was also removed from the trace header as well as from the dynamic sampling context.install method for custom integrations. Please use setup_once instead.sentry_sdk.tracing.Span.new_span. Use sentry_sdk.tracing.Span.start_child instead.sentry_sdk.tracing.Transaction.new_span. Use sentry_sdk.tracing.Transaction.start_child instead.sentry_sdk.utils.Auth.store_api_url.sentry_sdk.utils.Auth.get_api_url's now accepts a sentry_sdk.consts.EndpointType enum instead of a string as its only parameter. We recommend omitting this argument when calling the function, since the parameter's default value is the only possible sentry_sdk.consts.EndpointType value. The parameter exists for future compatibility.tracing_utils_py2.py. The start_child_span_decorator is now in sentry_sdk.tracing_utils.sentry_sdk.profiler.Scheduler.stop_profiling method. Any calls to this method can simply be removed, since this was a no-op method.profiler_mode and profiles_sample_rate have been deprecated as _experiments options. Use them as top level options instead:sentry_sdk.init(
...,
profiler_mode="thread",
profiles_sample_rate=1.0,
)
sentry_sdk.transport.Transport.capture_event. Please use sentry_sdk.transport.Transport.capture_envelope, instead.sentry_sdk.init's transport keyword argument has been deprecated. If you wish to provide a custom transport, please pass a sentry_sdk.transport.Transport instance or a subclass.propagate_hub in ThreadingIntegration() was deprecated and renamed to propagate_scope.The deprecated with_locals configuration option was removed. Use include_local_variables instead. See https://docs.sentry.io/platforms/python/configur…
Sentry SDK 2.0a1 is alpha software and not yet ready for production!
Please give it a spin and test it with your project. If you have any questions or feedback please contact us on Discord in the #python channel or create a GitHub Issue or start a GitHub Discussion.
Thanks!
The Pyramid integration will not capture errors that might happen in authenticated_userid() in a custom AuthenticationPolicy class.
The method need_code_loation of the MetricsAggregator was renamed to need_code_location.
The BackgroundWorker thread used to process events was renamed from raven-sentry.BackgroundWorker to sentry-sdk.BackgroundWorker.
The reraise function was moved from sentry_sdk._compat to sentry_sdk.utils.
The _ScopeManager was moved from sentry_sdk.hub to sentry_sdk.scope.
Moved the contents of tracing_utils_py3.py to tracing_utils.py. The start_child_span_decorator is now in sentry_sdk.tracing_utils.
The actual implementation of get_current_span was moved to sentry_sdk.tracing_utils. sentry_sdk.get_current_span is still accessible as part of the top-level API.
sentry_sdk.tracing_utils.get_current_span() does now take a scope instead of a hub as parameter.
sentry_sdk.utils._get_contextvars does not return a tuple with three values, but a tuple with two values. The copy_context was removed.
If you create a transaction manually and later mutate the transaction in a configure_scope block this does not work anymore. Here is a recipe on how to change your code to make it work:
Your existing implementation:
transaction = sentry_sdk.transaction(...)
# later in the code execution:
with sentry_sdk.configure_scope() as scope:
scope.set_transaction_name("new-transaction-name")
needs to be changed to this:
transaction = sentry_sdk.transaction(...)
# later in the code execution:
scope = sentry_sdk.Scope.get_current_scope()
scope.set_transaction_name("new-transaction-name")
The classes listed in the table below are now abstract base classes. Therefore, they can no longer be instantiated. Subclasses can only be instantiated if they implement all of the abstract methods. <details> <summary><b>Show table</b></summary>
| Class | Abstract methods |
|---|---|
sentry_sdk.integrations.Integration |
setup_once |
sentry_sdk.metrics.Metric |
add, serialize_value, and weight |
sentry_sdk.profiler.Scheduler |
setup and teardown |
sentry_sdk.transport.Transport |
capture_envelope |
</details>
last_event_id() top level API. The last event ID is still returned by capture_event(), capture_exception() and capture_message() but the top level API sentry_sdk.last_event_id() has been removed./store endpoint. Everything is now sent to the /envelope endpoint. If you're on SaaS you don't have to worry about this, but if you're running Sentry yourself you'll need version 20.6.0 or higher of self-hosted Sentry.with_locals configuration option was removed. Use include_local_variables instead. See https://docs.sentry.io/platforms/python/configuration/options/#include-local-variables.request_bodies configuration option was removed. Use max_request_body_size. See https://docs.sentry.io/platforms/python/configuration/options/#max-request-body-size.user.segment. It was also removed from the trace header as well as from the dynamic sampling context.install method for custom integrations. Please use setup_once instead.sentry_sdk.tracing.Span.new_span. Use sentry_sdk.tracing.Span.start_child instead.sentry_sdk.tracing.Transaction.new_span. Use sentry_sdk.tracing.Transaction.start_child instead.sentry_sdk.utils.Auth.store_api_url.sentry_sdk.utils.Auth.get_api_url's now accepts a sentry_sdk.consts.EndpointType enum instead of a string as its only parameter. We recommend omitting this argument when calling the function, since the parameter's default value is the only possible sentry_sdk.consts.EndpointType value. The parameter exists for future compatibility.tracing_utils_py2.py. The start_child_span_decorator is now in sentry_sdk.tracing_utils.sentry_sdk.profiler.Scheduler.stop_profiling method. Any calls to this method can simply be removed, since this was a no-op method.profiler_mode and profiles_sample_rate have been deprecated as _experiments options. Use them as top level options instead:sentry_sdk.init(
...,
profiler_mode="thread",
profiles_sample_rate=1.0,
)
sentry_sdk.transport.Transport.capture_event. Please use sentry_sdk.transport.Transport.capture_envelope, instead.sentry_sdk.init's transport keyword argument has been deprecated. If you wish to provide a custom transport, please pass a sentry_sdk.transport.Transport instance or a subclass.propagate_hub in ThreadingIntegration() was deprecated and renamed to propagate_scope.This is a security backport release.
This 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
Remove deprecated typing imports in crons (#2945) by @szokeasaurusrex
This is the final 1.x release for the forseeable future. Development will continue on the 2.x release line. The first 2.x version will be available in the next few weeks.
Allow to upsert monitors (#2929) by @sentrivana
It's now possible to provide monitor_config to the monitor decorator/context manager directly:
from sentry_sdk.crons import monitor
# All keys except `schedule` are optional
monitor_config = {
"schedule": {"type": "crontab", "value": "0 0 * * *"},
"timezone": "Europe/Vienna",
"checkin_margin": 10,
"max_runtime": 10,
"failure_issue_threshold": 5,
"recovery_threshold": 5,
}
@monitor(monitor_slug='<monitor-slug>', monitor_config=monitor_config)
def tell_the_world():
print('My scheduled task...')
Check out the cron docs for details.
Add Django signals_denylist to filter signals that are attached to by signals_spans (#2758) by @lieryan
If you want to exclude some Django signals from performance tracking, you can use the new signals_denylist Django option:
import django.db.models.signals
import sentry_sdk
sentry_sdk.init(
...
integrations=[
DjangoIntegration(
...
signals_denylist=[
django.db.models.signals.pre_init,
django.db.models.signals.post_init,
],
),
],
)
increment for metrics (#2588) by @mitsuhiko
increment and incr are equivalent, so you can pick whichever you like more.
Add value, unit to before_emit_metric (#2958) by @sentrivana
If you add a custom before_emit_metric, it'll now accept 4 arguments (the key, value, unit and tags) instead of just key and tags.
def before_emit(key, value, unit, tags):
if key == "removed-metric":
return False
tags["extra"] = "foo"
del tags["release"]
return True
sentry_sdk.init(
...
_experiments={
"before_emit_metric": before_emit,
}
)
Remove experimental metric summary options (#2957) by @sentrivana
The _experiments options metrics_summary_sample_rate and should_summarize_metric have been removed.
New normalization rules for metric keys, names, units, tags (#2946) by @sentrivana
Change data_category from statsd to metric_bucket (#2954) by @cleptric
Accessing __mro__ might throw a ValueError (#2952) by @sentrivana
Suppress prompt spawned by subprocess when using pythonw (#2936) by @collinbanko
Handle None in GraphQL query #2715 (#2762) by @czyber
Do not send "quiet" Sanic exceptions to Sentry (#2821) by @hamedsh
Implement metric_bucket rate limits (#2933) by @cleptric
Fix type hints for monitor decorator (#2944) by @szokeasaurusrex
Remove deprecated typing imports in crons (#2945) by @szokeasaurusrex
Make monitor_config a TypedDict (#2931) by @sentrivana
Add devenv-requirements.txt and update env setup instructions (#2761) by @arr-ee
Bump types-protobuf from 4.24.0.20240311 to 4.24.0.20240408 (#2941) by @dependabot
Disable Codecov check run annotations (#2537) by @eliatcodecov
Make monitor async friendly (#2912) by @sentrivana
Make monitor async friendly (#2912) by @sentrivana
You can now decorate your async functions with the monitor
decorator and they will correctly report their duration
and completion status.
Fixed Event | None runtime TypeError (#2928) by @szokeasaurusrex
ref: Define types at runtime (#2914) by @szokeasaurusrex
Add optional keep_alive (#2842) by @sentrivana
Add optional keep_alive (#2842) by @sentrivana
If you're experiencing frequent network issues between the SDK and Sentry, you can try turning on TCP keep-alive:
import sentry_sdk
sentry_sdk.init(
# ...your usual settings...
keep_alive=True,
)
Add support for Celery Redbeat cron tasks (#2643) by @kwigley
The SDK now supports the Redbeat scheduler in addition to the default Celery Beat scheduler for auto instrumenting crons. See the docs for more information about how to set this up.
aws_event can be an empty list (#2849) by @sentrivana
Re-export Event in types.py (#2829) by @szokeasaurusrex
Small API docs improvement (#2828) by @antonpirker
Fixed OpenAI tests (#2834) by @antonpirker
Bump checkouts/data-schemas from ed078ed to 8232f17 (#2832) by @dependabot
New integration: OpenAI integration (#2791) by @colin-sentry
New integration: OpenAI integration (#2791) by @colin-sentry
We added an integration for OpenAI to capture errors and also performance data when using the OpenAI Python SDK.
Useage:
This integrations is auto-enabling, so if you have the openai package in your project it will be enabled. Just initialize Sentry before you create your OpenAI client.
from openai import OpenAI
import sentry_sdk
sentry_sdk.init(
dsn="___PUBLIC_DSN___",
enable_tracing=True,
traces_sample_rate=1.0,
)
client = OpenAI()
For more information, see the documentation for OpenAI integration.
Discard open OpenTelemetry spans after 10 minutes (#2801) by @antonpirker
Propagate sentry-trace and baggage headers to Huey tasks (#2792) by @cnschn
Added Event type (#2753) by @szokeasaurusrex
Improve scrub_dict typing (#2768) by @szokeasaurusrex
Dependencies: bump types-protobuf from 4.24.0.20240302 to 4.24.0.20240311 (#2797) by @dependabot
Add recursive scrubbing to EventScrubber (#2755) by @Cheapshot003
Add recursive scrubbing to EventScrubber (#2755) by @Cheapshot003
By default, the EventScrubber will not search your events for potential
PII recursively. With this release, you can enable this behavior with:
import sentry_sdk
from sentry_sdk.scrubber import EventScrubber
sentry_sdk.init(
# ...your usual settings...
event_scrubber=EventScrubber(recursive=True),
)
Expose socket_options (#2786) by @sentrivana
If the SDK is experiencing connection issues (connection resets, server
closing connection without response, etc.) while sending events to Sentry,
tweaking the default urllib3 socket options to the following can help:
import socket
from urllib3.connection import HTTPConnection
import sentry_sdk
sentry_sdk.init(
# ...your usual settings...
socket_options=HTTPConnection.default_socket_options + [
(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1),
# note: skip the following line if you're on MacOS since TCP_KEEPIDLE doesn't exist there
(socket.SOL_TCP, socket.TCP_KEEPIDLE, 45),
(socket.SOL_TCP, socket.TCP_KEEPINTVL, 10),
(socket.SOL_TCP, socket.TCP_KEEPCNT, 6),
],
)
Allow to configure merge target for releases (#2777) by @sentrivana
Allow empty character in metric tags values (#2775) by @viglia
Replace invalid tag values with an empty string instead of _ (#2773) by @markushi
Add documentation comment to scrub_list (#2769) by @szokeasaurusrex
Fixed regex to parse version in lambda package file (#2767) by @antonpirker
xfail broken AWS Lambda tests for now (#2794) by @sentrivana
Removed print statements because it messes with the tests (#2789) by @antonpirker
Bump types-protobuf from 4.24.0.20240129 to 4.24.0.20240302 (#2782) by @dependabot
Bump checkouts/data-schemas from eb941c2 to ed078ed (#2781) by @dependabot
Fix compatibility with greenlet/gevent (#2756) by @sentrivana
greenlet/gevent (#2756) by @sentrivanaclickhouse-driver==0.2.7 (#2752) by @sentrivanacheckouts/data-schemas from 6121fd3 to eb941c2 (#2747) by @dependabotDeprecate last_event_id(). (#2749) by @antonpirker
Deprecate last_event_id(). (#2749) by @antonpirker
Warn if uWSGI is set up without proper thread support (#2738) by @sentrivana
uWSGI has to be run in threaded mode for the SDK to run properly. If this is not the case, the consequences could range from features not working unexpectedly to uWSGI workers crashing.
Please make sure to run uWSGI with both --enable-threads and --py-call-uwsgi-fork-hooks.
parsed_url can be None (#2734) by @sentrivana
Python 3.7 is not supported anymore by Lambda, so removed it and added 3.12 (#2729) by @antonpirker
Only start metrics flusher thread on demand (#2727) by @sentrivana
aa7058c to 6121fd3 (#2724) by @dependabotTurn off metrics for uWSGI (#2720) by @sentrivana
test: Fix pytest error (#2712) by @szokeasaurusrex
pytest error (#2712) by @szokeasaurusrexFix uWSGI workers hanging (#2694) by @sentrivana
gevent (#2694) by @sentrivanaengine.url being None (#2708) by @sentrivanasentry_sdk.utils._generate_installed_modules (#2703) by @GlenWalkercodecov/codecov-action from 3 to 4 (#2706) by @dependabotactions/cache from 3 to 4 (#2661) by @dependabotactions/checkout from 3.1.0 to 4.1.1 (#2561) by @dependabotgithub/codeql-action from 2 to 3 (#2603) by @dependabotactions/setup-python from 4 to 5 (#2577) by @dependabotEnable metrics related settings by default (#2685) by @iambriccardo
UnicodeDecodeError on Python 2 (#2657) by @sentrivanablack==24.1.0 (#2680) by @sentrivanasentry_sdk.trace type hints (#2633) by @szokeasaurusrexcheckouts/data-schemas from e9f7d58 to aa7058c (#2639) by @dependabotFix timestamp in transaction created by OTel (#2627) by @antonpirker
TypeError for static and class methods (#2559) by @szokeasaurusrexctx in Arq integration (#2600) by @ivanovartdata_category from check_in to monitor (#2598) by @sentrivanaFix psycopg2 detection in the Django integration (#2593) by @sentrivana
error_sampler function (#2511) by @antonpirkeraiohttp (#2590) by @antonpirkerAdd support for cluster clients from Redis SDK (#2394) by @md384
TypeError with no-argument apply_async (#2575) by @szokeasaurusrexos.path.devnull access issues (#2579) by @sentrivanacode.filepath frame picking logic (#2568) by @sentrivanaOnly add trace context to checkins and do not run event_processors for checkins (#2536) by @antonpirker
event_processors for checkins (#2536) by @antonpirkerjinja2 for generating CI yamls (#2534) by @sentrivanaFix NameError on parse_version with eventlet (#2532) by @sentrivana
NameError on parse_version with eventlet (#2532) by @sentrivana68def1e to e9f7d58 (#2501) by @dependabotMove installed modules code to utils (#2429) by @sentrivana
Move installed modules code to utils (#2429) by @sentrivana
Note: We moved the internal function _get_installed_modules from sentry_sdk.integrations.modules to sentry_sdk.utils.
So if you use this function you have to update your imports
Add code locations for metrics (#2526) by @jan-auer
Add query source to DB spans (#2521) by @antonpirker
Send events to Spotlight sidecar (#2524) by @HazAT
Run integration tests with newest pytest (#2518) by @sentrivana
Bring tests up to date (#2512) by @sentrivana
Fix: Prevent global var from being discarded at shutdown (#2530) by @antonpirker
Fix: Scope transaction source not being updated in scope.span setter (#2519) by @sl0thentr0py
Django: Support Django 5.0 (#2490) by @sentrivana
RedisIntegration is disabled, unless redis is installed (#2504) by @szokeasaurusrexPython 3.12: Replace deprecated datetime functions (#2502) by @sentrivana
Updated gRPC integration: Asyncio interceptors and easier setup (#2369) by @fdellekart
Our gRPC integration now instruments incoming unary-unary grpc requests and outgoing unary-unary, unary-stream grpc requests using grpcio channels. Everything works now for sync and async code.
Before this release you had to add Sentry interceptors by hand to your gRPC code, now the only thing you need to do is adding the GRPCIntegration to you sentry_sdk_init() call. (See documentation for more information):
import sentry_sdk
from sentry_sdk.integrations.grpc import GRPCIntegration
sentry_sdk.init(
dsn="___PUBLIC_DSN___",
enable_tracing=True,
integrations=[
GRPCIntegration(),
],
)
The old way still works, but we strongly encourage you to update your code to the way described above.
Python 3.12: Replace deprecated datetime functions (#2502) by @sentrivana
Metrics: Unify datetime format (#2409) by @mitsuhiko
Celery: Set correct data in check_ins (#2500) by @antonpirker
Celery: Read timezone for Crons monitors from celery_schedule if existing (#2497) by @antonpirker
Django: Removing redundant code in Django tests (#2491) by @vagi8
Django: Make reading the request body work in Django ASGI apps. (#2495) by @antonpirker
FastAPI: Use wraps on fastapi request call wrapper (#2476) by @nkaras
Fix: Probe for psycopg2 and psycopg3 parameters function. (#2492) by @antonpirker
Fix: Remove unnecessary TYPE_CHECKING alias (#2467) by @rafrafek
Added Python 3.12 support (#2471, #2483)
connection_kwargs in patch_redis_client (#2482) by @szokeasaurusrexMake parse_version work in utils.py itself. (#2474) by @antonpirker
New: Added error_sampler option (#2456) by @szokeasaurusrex
error_sampler option (#2456) by @szokeasaurusrexdebug option also configurable via environment (#2450) by @antonpirkerget_dsn_parameters is an actual function (#2441) by @sentrivanaredis database spans (#2398) by @antonpirkerpath patterns (#2452) by @sentrivanaRemove utcnow, utcfromtimestamp deprecated in Python 3.12 (#2415) by @rmad17
New: Error monitoring for some of the most popular Python GraphQL libraries:
Add GQL GraphQL integration (#2368) by @szokeasaurusrex
Usage:
import sentry_sdk
from sentry_sdk.integrations.gql import GQLIntegration
sentry_sdk.init(
dsn='___PUBLIC_DSN___',
integrations=[
GQLIntegration(),
],
)
Add Graphene GraphQL error integration (#2389) by @sentrivana
Usage:
import sentry_sdk
from sentry_sdk.integrations.graphene import GrapheneIntegration
sentry_sdk.init(
dsn='___PUBLIC_DSN___',
integrations=[
GrapheneIntegration(),
],
)
Add Strawberry GraphQL error & tracing integration (#2393) by @sentrivana
Usage:
import sentry_sdk
from sentry_sdk.integrations.strawberry import StrawberryIntegration
sentry_sdk.init(
dsn='___PUBLIC_DSN___',
integrations=[
# make sure to set async_execution to False if you're executing
# GraphQL queries synchronously
StrawberryIntegration(async_execution=True),
],
traces_sample_rate=1.0,
)
Add Ariadne GraphQL error integration (#2387) by @sentrivana
Usage:
import sentry_sdk
from sentry_sdk.integrations.ariadne import AriadneIntegration
sentry_sdk.init(
dsn='___PUBLIC_DSN___',
integrations=[
AriadneIntegration(),
],
)
Capture multiple named groups again (#2432) by @sentrivana
Don't fail when upstream scheme is unusual (#2371) by @vanschelven
Support new RQ version (#2405) by @antonpirker
Remove utcnow, utcfromtimestamp deprecated in Python 3.12 (#2415) by @rmad17
Add trace to __all__ in top-level __init__.py (#2401) by @lobsterkatie
Move minimetrics code to the SDK (#2385) by @mitsuhiko
Add configurable compression levels (#2382) by @mitsuhiko
Shift flushing by up to a rollup window (#2396) by @mitsuhiko
Make a consistent noop flush behavior (#2428) by @mitsuhiko
Stronger recursion protection (#2426) by @mitsuhiko
Remove OpenTelemetryIntegration from __init__.py (#2379) by @sentrivana
Update API docs (#2397) by @antonpirker
Pin some test requirements because new majors break our tests (#2404) by @antonpirker
Run more requests, celery, falcon tests (#2414) by @sentrivana
Move importorskips in tests to __init__.py files (#2412) by @sentrivana
Fix mypy errors (#2433) by @sentrivana
Fix pre-commit issues (#2424) by @bukzor-sentryio
Update CONTRIBUTING.md (#2411) by @sentrivana
Bump sphinx from 7.2.5 to 7.2.6 (#2378) by @dependabot
[Experimental] Add explain plan to DB spans (#2315) by @antonpirker
Fix deprecated version attribute (#2338) by @vagi8
New: Add integration for clickhouse-driver (#2167) by @mimre25
For more information, see the documentation for clickhouse-driver for more information.
Usage:
import sentry_sdk
from sentry_sdk.integrations.clickhouse_driver import ClickhouseDriverIntegration
sentry_sdk.init(
dsn='___PUBLIC_DSN___',
integrations=[
ClickhouseDriverIntegration(),
],
)
New: Add integration for asyncpg (#2314) by @mimre25
For more information, see the documentation for asyncpg for more information.
Usage:
import sentry_sdk
from sentry_sdk.integrations.asyncpg import AsyncPGIntegration
sentry_sdk.init(
dsn='___PUBLIC_DSN___',
integrations=[
AsyncPGIntegration(),
],
)
New: Allow to override propagate_traces in Celery per task (#2331) by @jan-auer
For more information, see the documentation for Celery for more information.
Usage:
import sentry_sdk
from sentry_sdk.integrations.celery import CeleryIntegration
# Enable global distributed traces (this is the default, just to be explicit.)
sentry_sdk.init(
dsn='___PUBLIC_DSN___',
integrations=[
CeleryIntegration(propagate_traces=True),
],
)
...
# This will NOT propagate the trace. (The task will start its own trace):
my_task_b.apply_async(
args=("some_parameter", ),
headers={"sentry-propagate-traces": False},
)
Prevent Falcon integration from breaking ASGI apps (#2359) by @szokeasaurusrex
Backpressure: only downsample a max of 10 times (#2347) by @sl0thentr0py
Made NoOpSpan compatible to Transactions. (#2364) by @antonpirker
Cleanup ASGI integration (#2335) by @antonpirker
Pin anyio in tests (dep of httpx), because new major 4.0.0 breaks tests. (#2336) by @antonpirker
Added link to backpressure section in docs. (#2354) by @antonpirker
Add .vscode to .gitignore (#2317) by @shoaib-mohd
Documenting Spans and Transactions (#2358) by @antonpirker
Fix in profiler: do not call getcwd from module root (#2329) by @Zylphrex
Fix deprecated version attribute (#2338) by @vagi8
Fix transaction name in Starlette and FastAPI (#2341) by @antonpirker
Fix tests using Postgres (#2362) by @antonpirker
build(deps): Updated linting tooling (#2350) by @antonpirker
build(deps): bump sphinx from 7.2.4 to 7.2.5 (#2344) by @dependabot
build(deps): bump actions/checkout from 2 to 4 (#2352) by @dependabot
build(deps): bump checkouts/data-schemas from ebc77d3 to 68def1e (#2351) by @dependabot
Officially support Python 3.11 (#2300) by @sentrivana
Officially support Python 3.11 (#2300) by @sentrivana
Context manager monitor (#2290) by @szokeasaurusrex
Set response status code in transaction response context. (#2312) by @antonpirker
Add missing context kwarg to _sentry_task_factory (#2267) by @JohnnyDeuss
In Postgres take the connection params from the connection (#2308) by @antonpirker
Experimental: Allow using OTel for performance instrumentation (#2272) by @sentrivana
This release includes experimental support for replacing Sentry's default performance monitoring solution with one powered by OpenTelemetry without having to do any manual setup.
Try it out by installing pip install sentry-sdk[opentelemetry-experimental] and
then initializing the SDK with:
sentry_sdk.init(
# ...your usual options...
_experiments={"otel_powered_performance": True},
)
This enables OpenTelemetry performance monitoring support for some of the most popular frameworks and libraries (Flask, Django, FastAPI, requests...).
We're looking forward to your feedback! Please let us know about your experience in this discussion: https://github.com/getsentry/sentry/discussions/55023
Important note: Please note that this feature is experimental and in a proof-of-concept stage and is not meant for production use. It may be changed or removed at any point.
Enable backpressure handling by default (#2298) by @sl0thentr0py
The SDK now dynamically downsamples transactions to reduce backpressure in high
throughput systems. It starts a new Monitor thread to perform some health checks
which decide to downsample (halved each time) in 10 second intervals till the system
is healthy again.
To disable this behavior, use:
sentry_sdk.init(
# ...your usual options...
enable_backpressure_handling=False,
)
If your system serves heavy load, please let us know how this feature works for you! Check out the documentation for more information.
Stop recording spans for internal web requests to Sentry (#2297) by @szokeasaurusrex
Add test for ThreadPoolExecutor (#2259) by @gggritso
Add docstrings for Scope.update_from_* (#2311) by @sentrivana
Moved is_sentry_url to utils (#2304) by @szokeasaurusrex
Fix: arq attribute error on settings, support worker args (#2260) by @rossmacarthur
Fix: Exceptions include detail property for their value (#2193) by @nicolassanmar
build(deps): bump mypy from 1.4.1 to 1.5.1 (#2319) by @dependabot
build(deps): bump sphinx from 7.1.2 to 7.2.4 (#2322) by @dependabot
build(deps): bump sphinx from 7.0.1 to 7.1.2 (#2296) by @dependabot
build(deps): bump checkouts/data-schemas from 1b85152 to ebc77d3 (#2254) by @dependabot
Revert GraphQL integration (#2287) by @sentrivana
Fix GraphQL integration swallowing responses (#2286) by @sentrivana
Capture GraphQL client errors (#2243) by @sentrivana
/graphql endpoint and the response contains an error. You can opt out of this by providing capture_graphql_errors=False to the HTTP client integration.request_bodies to max_request_body_size (#2247) by @mgalignianasample_rate (#2279) by @szokeasaurusrexdb.system to remaining Redis spans (#2271) by @AbhiPrasadRedis: Add support for redis.asyncio (#1933) by @Zhenay
sentry-trace and baggage) to HTTP requests to Sentry (#2240) by @antonpirkersentry-trace header multiple times (#2235) by @antonpirkerAdd support for cron jobs in ARQ integration (#2088) by @lewazo
Add Starlette/FastAPI template tag for adding Sentry tracing information (#2225) by @antonpirker
{{ sentry_trace_meta }} to your Starlette/FastAPI Jinja2 templates we will include Sentry trace information as a meta tag in the rendered HTML to allow your frontend to pick up and continue the trace started in the backend.None for trace_configs in aiohttp (#2230) by @Harmon758Support for SQLAlchemy 2.0 (#2200) by @antonpirker
Support for SQLAlchemy 2.0 (#2200) by @antonpirker
Add instrumentation of aiohttp client requests (#1761) by @md384
Add Django template tag for adding Sentry tracing information (#2222) by @antonpirker
{{ sentry_trace_meta }} to your Django templates we will include Sentry trace information as a meta tag in the rendered HTML to allow your frontend to pick up and continue the trace started in the backend.Update Flask HTML meta helper (#2203) by @antonpirker
Take trace ID always from propagation context (#2209) by @antonpirker
Fix trace context in event payload (#2205) by @antonpirker
Use new top level API in trace_propagation_meta (#2202) by @antonpirker
Do not overwrite existing baggage on outgoing requests (#2191, #2214) by @sentrivana
Set the transaction/span status from an OTel span (#2115) by @daniil-konovalenko
Fix propagation of OTel NonRecordingSpan (#2187) by @hartungstenio
Fix TaskLockedException handling in Huey integration (#2206) by @Zhenay
Add message format configuration arguments to Loguru integration (#2208) by @Gwill
Profiling: Add client reports for profiles (#2207) by @Zylphrex
CI: Fix CI (#2220) by @antonpirker
Dependencies: Bump checkouts/data-schemas from 7fdde87 to 1b85152 (#2218) by @dependabot
Dependencies: Bump mypy from 1.3.0 to 1.4.1 (#2194) by @dependabot
Docs: Change API doc theme (#2210) by @sentrivana
Docs: Allow (some) autocompletion for top-level API (#2213) by @sentrivana
Docs: Revert autocomplete hack (#2224) by @sentrivana
Tracing without performance (#2136) by @antonpirker
parse_url calls in capture_internal_exceptions (#2162) by @sentrivana0ed3357 to 7fdde87 (#2165) by @dependabotCollections of improvements to our Django integration.
Collections of improvements to our Django integration.
By: @mgaligniana (#1773)
Fix parse_url (#2161) by @sentrivana and @antonpirker
Our URL sanitization used in multiple integrations broke with the recent Python security update. If you started seeing ValueErrors with "'Filtered' does not appear to be an IPv4 or IPv6 address", this release fixes that. See the original issue for more context.
Better version parsing in integrations (#2152) by @antonpirker
We now properly support all integration versions that conform to PEP 440. This replaces our naïve version parsing that wouldn't accept versions such as 2.0.0rc1 or 2.0.5.post1.
Align HTTP status code as span data field http.response.status_code (#2113) by @antonpirker
Do not encode cached value to determine size (#2143) by @sentrivana
Fix using unittest.mock whenever available (#1926) by @mgorny
Fix 2.7 common tests (#2145) by @sentrivana
Bump actions/stale from 6 to 8 (#1978) by @dependabot
Bump black from 22.12.0 to 23.3.0 (#1984) by @dependabot
Bump mypy from 1.2.0 to 1.3.0 (#2110) by @dependabot
Bump sphinx from 5.3.0 to 7.0.1 (#2112) by @dependabot
Support urllib3>=2.0.0 (#2148) by @asottile-sentry
Support urllib3>=2.0.0 (#2148) by @asottile-sentry
We're now supporting urllib3's new major version, 2.0.0. If you encounter issues (e.g. some of your dependencies not supporting the new urllib3 version yet) you might consider pinning the urllib3 version to <2.0.0 manually in your project. Check out the the urllib3 migration guide for details.
Auto-retry tests on failure (#2134) by @sentrivana
Correct importlib.metadata check in test_modules (#2149) by @asottile-sentry
Fix distribution name normalization (PEP-0503) (#2144) by @rominf
Fix functions_to_trace typing (#2141) by @rcmarron
New: Celery Beat exclude tasks option (#2130) by @antonpirker
New: Celery Beat exclude tasks option (#2130) by @antonpirker
You can exclude Celery Beat tasks from being auto-instrumented. To do this, add a list of tasks you want to exclude as option exclude_beat_tasks when creating CeleryIntegration. The list can contain simple strings with the full task name, as specified in the Celery Beat schedule, or regular expressions to match multiple tasks.
For more information, see the documentation for Crons for more information.
Usage:
exclude_beat_tasks = [
"some-task-a",
"payment-check-.*",
]
sentry_sdk.init(
dsn='___PUBLIC_DSN___',
integrations=[
CeleryIntegration(
monitor_beat_tasks=True,
exclude_beat_tasks=exclude_beat_tasks,
),
],
)
In this example the task some-task-a and all tasks with a name starting with payment-check- will be ignored.
New: Add support for ExceptionGroups (#2025) by @antonpirker
Note: If running Self-Hosted Sentry, you should wait to adopt this SDK update until after updating to the 23.6.0 (est. June 2023) release of Sentry. Updating early will not break anything, but you will not get the full benefit of the Exception Groups improvements to issue grouping that were added to the Sentry backend.
Prefer importlib.metadata over pkg_resources if available (#2081) by @sentrivana
Work with a copy of request, vars in the event (#2125) by @sentrivana
Pinned version of dependency that broke the build (#2133) by @antonpirker
Disable Django Cache spans by default. (#2120) by @antonpirker
New: Add loguru integration (#1994) by @PerchunPak
New: Add loguru integration (#1994) by @PerchunPak
Check the documentation for more information.
Usage:
from loguru import logger
import sentry_sdk
from sentry_sdk.integrations.loguru import LoguruIntegration
sentry_sdk.init(
dsn="___PUBLIC_DSN___",
integrations=[
LoguruIntegration(),
],
)
logger.debug("I am ignored")
logger.info("I am a breadcrumb")
logger.error("I am an event", extra=dict(bar=43))
logger.exception("An exception happened")
"I am an event" will be created."I am a breadcrumb" will be attached as a breadcrumb to that event.bar will end up in the extra attributes of that event."An exception happened" will send the current exception from sys.exc_info() with the stack trace to Sentry. If there's no exception, the current stack will be attached."I am ignored" will not be captured by Sentry. To capture it, set level to DEBUG or lower in LoguruIntegration.Do not truncate request body if request_bodies is "always" (#2092) by @sentrivana
Fixed Celery headers for Beat auto-instrumentation (#2102) by @antonpirker
Add db.operation to Redis and MongoDB spans (#2089) by @antonpirker
Make sure we're importing redis the library (#2106) by @sentrivana
Add include_source_context option (#2020) by @farhat-nawaz and @sentrivana
Import Markup from markupsafe (#2047) by @rco-ableton
Fix __qualname__ missing attribute in asyncio integration (#2105) by @sl0thentr0py
Remove relay extension from AWS Layer (#2068) by @sl0thentr0py
Add a note about pip freeze to the bug template (#2103) by @sentrivana
Fix: Django caching spans when using keyword arguments (#2086) by @antonpirker
Fix: Handle a list of keys (not just a single key) in Django cache spans (#2082) by @antonpirker
Add cache.hit and cache.item_size to Django (#2057) by @antonpirker
Add cache.hit and cache.item_size to Django (#2057) by @antonpirker
Note: This will add spans for all requests to the caches configured in Django. This will probably add some overhead to your server an also add multiple spans to your performance waterfall diagrams. If you do not want this, you can disable this feature in the DjangoIntegration:
sentry_sdk.init(
dsn="...",
integrations=[
DjangoIntegration(cache_spans=False),
]
)
Use http.method instead of method (#2054) by @AbhiPrasad
Handle non-int exc.status_code in Starlette (#2075) by @sentrivana
Handle SQLAlchemy engine.name being bytes (#2074) by @sentrivana
Fix KeyError in capture_checkin if SDK is not initialized (#2073) by @antonpirker
Use functools.wrap for ThreadingIntegration patches to fix attributes (#2080) by @EpicWink
Pin urllib3 to <2.0.0 for now (#2069) by @sl0thentr0py
Do not send monitor_config when unset (#2058) by @evanpurkhiser
db.system span data (#2040, #2042) by @antonpirkerBetter handling of redis span/breadcrumb data (#2033) by @antonpirker
Better handling of redis span/breadcrumb data (#2033) by @antonpirker
Note: With this release we will limit the description of redis db spans and the data in breadcrumbs represting redis db operations to 1024 characters.
This can can lead to truncated data. If you do not want this there is a new parameter max_data_size in RedisIntegration. You can set this to None for disabling trimming.
Example for disabling trimming of redis commands in spans or breadcrumbs:
sentry_sdk.init(
integrations=[
RedisIntegration(max_data_size=None),
]
)
Example for custom trim size of redis commands in spans or breadcrumbs:
sentry_sdk.init(
integrations=[
RedisIntegration(max_data_size=50),
]
)`
Add db.system to redis and SQLAlchemy db spans (#2037, #2038, #2039) (#2037) by @AbhiPrasad
Upgraded linting tooling (#2026) by @antonpirker
Made code more resilient. (#2031) by @antonpirker
Fix: Using the Codecov uploader instead of deprecated python package (#2011) by @antonpirker
Send all events to /envelope endpoint when tracing is enabled (#2009) by @antonpirker
Note: If you’re self-hosting Sentry 9, you need to stay in the previous version of the SDK or update your self-hosted to at least 20.6.0
Profiling: Remove profile context from SDK (#2013) by @Zylphrex
Profiling: Additionl performance improvements to the profiler (#1991) by @Zylphrex
Fix: Celery Beat monitoring without restarting the Beat process (#2001) by @antonpirker
Fix: Using the Codecov uploader instead of deprecated python package (#2011) by @antonpirker
Fix: Support for Quart (#2003)` (#2003) by @antonpirker
Make auto monitoring beat update support Celery 4 and 5 (#1989) by @antonpirker
New: Celery Beat auto monitoring (#1967) by @antonpirker
New: Celery Beat auto monitoring (#1967) by @antonpirker
The CeleryIntegration can now also monitor your Celery Beat scheduled tasks automatically using the new Crons feature of Sentry.
To learn more see our Celery Beat Auto Discovery documentation.
Usage:
from celery import Celery, signals
from celery.schedules import crontab
import sentry_sdk
from sentry_sdk.integrations.celery import CeleryIntegration
app = Celery('tasks', broker='...')
app.conf.beat_schedule = {
'set-in-beat-schedule': {
'task': 'tasks.some_important_task',
'schedule': crontab(...),
},
}
@signals.celeryd_init.connect
def init_sentry(**kwargs):
sentry_sdk.init(
dsn='...',
integrations=[CeleryIntegration(monitor_beat_tasks=True)], # 👈 here
environment="local.dev.grace",
release="v1.0",
)
This will auto detect all schedules tasks in your beat_schedule and will monitor them with Sentry Crons.
New: gRPC integration (#1911) by @hossein-raeisi
The gRPC integration instruments all incoming requests and outgoing unary-unary, unary-stream grpc requests using grpcio channels.
To learn more see our gRPC Integration documentation.
On the server:
import grpc
from sentry_sdk.integrations.grpc.server import ServerInterceptor
server = grpc.server(
thread_pool=...,
interceptors=[ServerInterceptor()],
)
On the client:
import grpc
from sentry_sdk.integrations.grpc.client import ClientInterceptor
with grpc.insecure_channel("example.com:12345") as channel:
channel = grpc.intercept_channel(channel, *[ClientInterceptor()])
New: socket integration (#1911) by @hossein-raeisi
Use this integration to create spans for DNS resolves (socket.getaddrinfo()) and connection creations (socket.create_connection()).
To learn more see our Socket Integration documentation.
Usage:
import sentry_sdk
from sentry_sdk.integrations.socket import SocketIntegration
sentry_sdk.init(
dsn="___PUBLIC_DSN___",
integrations=[
SocketIntegration(),
],
)
Fix: Do not trim span descriptions. (#1983) by @antonpirker
New: Implement EventScrubber (#1943) by @sl0thentr0py
New: Implement EventScrubber (#1943) by @sl0thentr0py
To learn more see our Scrubbing Sensitive Data documentation.
Add a new EventScrubber class that scrubs certain potentially sensitive interfaces with a DEFAULT_DENYLIST. The default scrubber is automatically run if send_default_pii = False:
import sentry_sdk
from sentry_sdk.scrubber import EventScrubber
sentry_sdk.init(
# ...
send_default_pii=False,
event_scrubber=EventScrubber(), # this is set by default
)
You can also pass in a custom denylist to the EventScrubber class and filter additional fields that you want.
from sentry_sdk.scrubber import EventScrubber, DEFAULT_DENYLIST
# custom denylist
denylist = DEFAULT_DENYLIST + ["my_sensitive_var"]
sentry_sdk.init(
# ...
send_default_pii=False,
event_scrubber=EventScrubber(denylist=denylist),
)
New: Added new functions_to_trace option for central way of performance instrumentation (#1960) by @antonpirker
To learn more see our Tracing Options documentation.
An optional list of functions that should be set up for performance monitoring. For each function in the list, a span will be created when the function is executed.
functions_to_trace = [
{"qualified_name": "tests.test_basics._hello_world_counter"},
{"qualified_name": "time.sleep"},
{"qualified_name": "collections.Counter.most_common"},
]
sentry_sdk.init(
# ...
traces_sample_rate=1.0,
functions_to_trace=functions_to_trace,
)
Updated denylist to include other widely used cookies/headers (#1972) by @antonpirker
Forward all sentry- baggage items (#1970) by @cleptric
Update OSS licensing (#1973) by @antonpirker
Profiling: Handle non frame types in profiler (#1965) by @Zylphrex
Tests: Bad arq dependency in tests (#1966) by @Zylphrex
Better naming (#1962) by @antonpirker
Deprecated with_locals in favor of include_local_variables (#1924) by @antonpirker
New: Monitor Celery Beat tasks with Sentry Cron Monitoring.
With this feature you can make sure that your Celery beat tasks run at the right time and see if they where successful or not.
Warning Cron Monitoring is currently in beta. Beta features are still in-progress and may have bugs. We recognize the irony. If you have any questions or feedback, please email us at crons-feedback@sentry.io, reach out via Discord (#cronjobs), or open an issue.
Usage:
# File: tasks.py
from celery import Celery, signals
from celery.schedules import crontab
import sentry_sdk
from sentry_sdk.crons import monitor
from sentry_sdk.integrations.celery import CeleryIntegration
# 1. Setup your Celery beat configuration
app = Celery('mytasks', broker='redis://localhost:6379/0')
app.conf.beat_schedule = {
'set-in-beat-schedule': {
'task': 'tasks.tell_the_world',
'schedule': crontab(hour='10', minute='15'),
'args': ("in beat_schedule set", ),
},
}
# 2. Initialize Sentry either in `celeryd_init` or `beat_init` signal.
#@signals.celeryd_init.connect
@signals.beat_init.connect
def init_sentry(**kwargs):
sentry_sdk.init(
dsn='...',
integrations=[CeleryIntegration()],
environment="local.dev.grace",
release="v1.0.7-a1",
)
# 3. Link your Celery task to a Sentry Cron Monitor
@app.task
@monitor(monitor_slug='3b861d62-ff82-4aa0-9cd6-b2b6403bd0cf')
def tell_the_world(msg):
print(msg)
New: Add decorator for Sentry tracing (#1089) by @ynouri
This allows you to use a decorator to setup custom performance instrumentation.
To learn more see Custom Instrumentation.
Usage: Just add the new decorator to your function, and a span will be created for it:
import sentry_sdk
@sentry_sdk.trace
def my_complex_function():
# do stuff
...
Make Django signals tracing optional (#1929) by @antonpirker
See the Django Guide to learn more.
Deprecated with_locals in favor of include_local_variables (#1924) by @antonpirker
Added top level API to get current span (#1954) by @antonpirker
Profiling: Add profiler options to init (#1947) by @Zylphrex
Profiling: Set active thread id for quart (#1830) by @Zylphrex
Fix: Update get_json function call for werkzeug 2.1.0+ (#1939) by @michielderoos
Fix: Returning the tasks result. (#1931) by @antonpirker
Fix: Rename MYPY to TYPE_CHECKING (#1934) by @untitaker
Fix: Fix type annotation for ignore_errors in sentry_sdk.init() (#1928) by @tiangolo
Tests: Start a real http server instead of mocking libs (#1938) by @antonpirker
Remove deprecated tracestate (#1907) by @sl0thentr0py
New: Add arq Integration (#1872) by @Zhenay
This integration will create performance spans when arq jobs will be enqueued and when they will be run. It will also capture errors in jobs and will link them to the performance spans.
Usage:
import asyncio
from httpx import AsyncClient
from arq import create_pool
from arq.connections import RedisSettings
import sentry_sdk
from sentry_sdk.integrations.arq import ArqIntegration
from sentry_sdk.tracing import TRANSACTION_SOURCE_COMPONENT
sentry_sdk.init(
dsn="...",
integrations=[ArqIntegration()],
)
async def download_content(ctx, url):
session: AsyncClient = ctx['session']
response = await session.get(url)
print(f'{url}: {response.text:.80}...')
return len(response.text)
async def startup(ctx):
ctx['session'] = AsyncClient()
async def shutdown(ctx):
await ctx['session'].aclose()
async def main():
with sentry_sdk.start_transaction(name="testing_arq_tasks", source=TRANSACTION_SOURCE_COMPONENT):
redis = await create_pool(RedisSettings())
for url in ('https://facebook.com', 'https://microsoft.com', 'https://github.com', "asdf"
):
await redis.enqueue_job('download_content', url)
class WorkerSettings:
functions = [download_content]
on_startup = startup
on_shutdown = shutdown
if __name__ == '__main__':
asyncio.run(main())
Update of Falcon Integration (#1733) by @bartolootrit
Adding Cloud Resource Context integration (#1882) by @antonpirker
Profiling: Use the transaction timestamps to anchor the profile (#1898) by @Zylphrex
Profiling: Add debug logs to profiling (#1883) by @Zylphrex
Profiling: Start profiler thread lazily (#1903) by @Zylphrex
Fixed checks for structured http data (#1905) by @antonpirker
Make set_measurement public api and remove experimental status (#1909) by @sl0thentr0py
Add trace_propagation_targets option (#1916) by @antonpirker
Add enable_tracing to default traces_sample_rate to 1.0 (#1900) by @sl0thentr0py
Remove deprecated tracestate (#1907) by @sl0thentr0py
Sanitize URLs in Span description and breadcrumbs (#1876) by @antonpirker
Mechanism should default to true unless set explicitly (#1889) by @sl0thentr0py
Better setting of in-app in stack frames (#1894) by @antonpirker
Add workflow to test gevent (#1870) by @Zylphrex
Updated outdated HTTPX test matrix (#1917) by @antonpirker
Switch to MIT license (#1908) by @cleptric
New: Add Huey Integration (#1555) by @Zhenay
New: Add Huey Integration (#1555) by @Zhenay
This integration will create performance spans when Huey tasks will be enqueued and when they will be executed.
Usage:
Task definition in demo.py:
import time
from huey import SqliteHuey, crontab
import sentry_sdk
from sentry_sdk.integrations.huey import HueyIntegration
sentry_sdk.init(
dsn="...",
integrations=[
HueyIntegration(),
],
traces_sample_rate=1.0,
)
huey = SqliteHuey(filename='/tmp/demo.db')
@huey.task()
def add_numbers(a, b):
return a + b
Running the tasks in run.py:
from demo import add_numbers, flaky_task, nightly_backup
import sentry_sdk
from sentry_sdk.integrations.huey import HueyIntegration
from sentry_sdk.tracing import TRANSACTION_SOURCE_COMPONENT, Transaction
def main():
sentry_sdk.init(
dsn="...",
integrations=[
HueyIntegration(),
],
traces_sample_rate=1.0,
)
with sentry_sdk.start_transaction(name="testing_huey_tasks", source=TRANSACTION_SOURCE_COMPONENT):
r = add_numbers(1, 2)
if __name__ == "__main__":
main()
Profiling: Do not send single sample profiles (#1879) by @Zylphrex
Profiling: Add additional test coverage for profiler (#1877) by @Zylphrex
Profiling: Always use builtin time.sleep (#1869) by @Zylphrex
Profiling: Defaul in_app decision to None (#1855) by @Zylphrex
Profiling: Remove use of threading.Event (#1864) by @Zylphrex
Profiling: Enable profiling on all transactions (#1797) by @Zylphrex
FastAPI: Fix check for Starlette in FastAPI integration (#1868) by @antonpirker
Flask: Do not overwrite default for username with email address in FlaskIntegration (#1873) by @homeworkprod
Tests: Add py3.11 to test-common (#1871) by @Zylphrex
Fix: Don't log whole event in before_send / event_processor drops (#1863) by @sl0thentr0py
Add before_send_transaction (#1840) by @antonpirker
Add before_send_transaction (#1840) by @antonpirker
Adds a hook (similar to before_send) that is called for all transaction events (performance releated data).
Usage:
import sentry_sdk
def strip_sensitive_data(event, hint):
# modify event here (or return `None` if you want to drop the event entirely)
return event
sentry_sdk.init(
# ...
before_send_transaction=strip_sensitive_data,
)
See also: https://docs.sentry.io/platforms/python/configuration/filtering/#using-platformidentifier-namebefore-send-transaction-
Django: Always remove values of Django session related cookies. (#1842) by @antonpirker
Profiling: Enable profiling for ASGI frameworks (#1824) by @Zylphrex
Profiling: Better gevent support (#1822) by @Zylphrex
Profiling: Add profile context to transaction (#1860) by @Zylphrex
Profiling: Use co_qualname in python 3.11 (#1831) by @Zylphrex
OpenTelemetry: fix Use dict for sentry-trace context instead of tuple (#1847) by @AbhiPrasad
OpenTelemetry: fix extra dependency (#1825) by @bernardotorres
OpenTelemetry: fix NoOpSpan updates scope (#1834) by @Zylphrex
OpenTelemetry: Make sure to noop when there is no DSN (#1852) by @antonpirker
FastAPI: Fix middleware being patched multiple times (#1841) by @JohnnyDeuss
Starlette: Avoid import of pkg_resource with Starlette integration (#1836) by @mgu
Removed code coverage target (#1862) by @antonpirker
Add Starlite integration (#1748) by @gazorby
Add Starlite integration (#1748) by @gazorby
Adding support for the Starlite framework. Unhandled errors are captured. Performance spans for Starlite middleware are also captured. Thanks @gazorby for the great work!
Usage:
from starlite import Starlite, get
import sentry_sdk
from sentry_sdk.integrations.starlite import StarliteIntegration
sentry_sdk.init(
dsn="...",
traces_sample_rate=1.0,
integrations=[
StarliteIntegration(),
],
)
@get("/")
def hello_world() -> dict[str, str]:
"""Keeping the tradition alive with hello world."""
bla = 1/0 # causing an error
return {"hello": "world"}
app = Starlite(route_handlers=[hello_world])
Profiling: Remove sample buffer from profiler (#1791) by @Zylphrex
Profiling: Performance tweaks to profile sampler (#1789) by @Zylphrex
Add span for Django SimpleTemplateResponse rendering (#1818) by @chdsbd
Use @wraps for Django Signal receivers (#1815) by @meanmail
Add enqueued_at and started_at to rq job extra (#1024) by @kruvasyan
Remove sanic v22 pin (#1819) by @sl0thentr0py
Add support for byterray and memoryview built-in types (#1833) by @Tarty
Handle "rc" in SQLAlchemy version. (#1812) by @peterschutt
Doc: Use .venv (not .env) as a virtual env location in CONTRIBUTING.md (#1790) by @tonyo
Auto publish to internal pypi on release (#1823) by @asottile-sentry
Added Python 3.11 to test suite (#1795) by @antonpirker
Update test/linting dependencies (#1801) by @antonpirker
Deps: bump sphinx from 5.2.3 to 5.3.0 (#1686) by @dependabot
Link errors to OTel spans (#1787) by @antonpirker
Your coding agent can read these notes before it upgrades. Set up the MCP server →