Releases: getsentry/sentry-python
Release list
2.70.0
New Features β¨
-
New integration: Mistral AI (#4733) by @alexander-alderman-webb
Add the Mistral integration to your
sentry_sdk.initcall:
import sentry_sdk
from sentry_sdk.integrations.mistral import MistralIntegration
sentry_sdk.init(
dsn="...",
traces_sample_rate=1.0,
integrations=[
MistralIntegration(),
]
)-
New option: A fine-grained way to configure what data should be sent from the SDK.
Offers much more flexibility than
send_default_pii, allowing you to specify what
data should be collected. Ifdata_collectionis defined, it takes precedence over
send_default_pii.See https://docs.sentry.io/platforms/python/configuration/options/#data_collection
for the available configuration options.
import sentry_sdk
sentry_sdk.init(
data_collection={
"user_info": False,
"gen_ai": {"inputs": False, "outputs": False},
"graphql": {"document": False, "variables": False},
"database_query_data": False,
"queues": False,
"http_bodies": [],
"cookies": {
"mode": "denylist",
"terms": ["forwarded", "-ip", "remote-", "via", "-user"],
},
"http_headers": {
"request": {
"mode": "denylist",
"terms": ["forwarded", "-ip", "remote-", "via", "-user"],
},
},
"url_query_params": {
"mode": "denylist",
"terms": ["forwarded", "-ip", "remote-", "via", "-user"],
},
}
)Mistral
- Record
gen_ai.output.messagesby @alexander-alderman-webb in #7549 - Record
gen_ai.input.messagesby @alexander-alderman-webb in #7548 - Record
gen_ai.system_instructionsby @alexander-alderman-webb in #7547 - Record request parameters by @alexander-alderman-webb in #7531
- Record token usage by @alexander-alderman-webb in #7529
- Add integration with
Chat.completeandChat.complete_asyncpatches by @alexander-alderman-webb in #7528
Internal Changes π§
- (data-collection) Promote
data_collectionfrom_experimentso top-level by @ericapisani in #7560 - Close client on teardown by @alexander-alderman-webb in #7562
- π€ Update test matrix with new releases (09/21) by @github-actions in #7546
- Remove
getsentry/testing-ai-sdk-integrationsby @alexander-alderman-webb in #7526
2.69.2
Bug Fixes π
- (aws-lambda) Attach user info when streaming spans by @sentrivana in #7429
- (bottle) Avoid infinite serializing loop by @sentrivana in #7511
- (clickhouse_driver) Only set
db.resultin breadcrumb with sensitive data opt-in by @alexander-alderman-webb in #7432 - (google-genai) Tolerate
Nonecandidates by @alexander-alderman-webb in #7519 - (pydantic-ai) Stop capturing tool execution spans when validation fails by @alexander-alderman-webb in #7448
- (serializer) Add type annotations to databag limits by @8rulerstar in #7505
- (tracing) Make
functions_to_tracework when streaming spans by @sentrivana in #7430 - (typing) Fix
disabled_integrationstype by @sentrivana in #7506 - Don't attach stacktrace to check-ins by @sentrivana in #7497
Documentation π
- Update span streaming docstrings by @sentrivana in #7463
Internal Changes π§
Huggingface Hub
- Parametrize tests on the streaming trace lifecycle by @alexander-alderman-webb in #7436
- Only check relevant data with
ApproxDictby @alexander-alderman-webb in #7434
Pydantic Ai
- Remove vacuous
_set_model_data()tests by @alexander-alderman-webb in #7453 - Remove vacuous
_set_agent_data()tests by @alexander-alderman-webb in #7450
Other
- (deps) Lock file maintenance by @renovate in #7302
- (django) Fix flaky cache tests by using uuid for cache LOCATION by @sentry-junior in #7444
- (pymongo) Raise
maxWireVersionby @alexander-alderman-webb in #7473 - Remove unused base64 utils by @sentrivana in #7495
- π€ Update test matrix with new releases (09/14) by @github-actions in #7486
- π€ Update test matrix with new releases (09/07) by @github-actions in #7399
Other
- Skip formatting log records when Sentry logs are off by @gyanu2507 in #7422
2.69.1
New Features β¨
- (django) Add
http.routeattribute by @alexander-alderman-webb in #7428
Bug Fixes π
- (aiohttp) Preserve SigV4-signed propagation headers by @Robinbinu in #7427
Internal Changes π§
Mcp
- Parametrize tests on the streaming trace lifecycle by @alexander-alderman-webb in #7424
- Remove vacuous tests by @alexander-alderman-webb in #7420
Other
- (cohere) Parametrize tests on the streaming trace lifecycle by @alexander-alderman-webb in #7419
- (openai-agents) Parametrize tests on
stream_gen_ai_spansand the streaming trace lifecycle by @alexander-alderman-webb in #7405
2.69.0
New Features β¨
Other
- (aiohttp) Add
http.routeattribute by @alexander-alderman-webb in #7341 - (bottle) Add
http.routeattribute by @alexander-alderman-webb in #7343 - (clickhouse_driver) Set breadcrumbs in the streaming trace lifecycle by @alexander-alderman-webb in #7325
- (docs) Add Plausible analytics to Sphinx docs by @ericapisani in #7319
- (falcon) Add
http.routeattribute by @alexander-alderman-webb in #7340 - (fastapi) Add
http.routeattribute by @alexander-alderman-webb in #7322 - (flask) Add
http.routeattribute by @alexander-alderman-webb in #7344 - (pyramid) Add
http.routeattribute by @alexander-alderman-webb in #7347 - (quart) Add
http.routeattribute by @alexander-alderman-webb in #7348 - (sqlalchemy) Add more db system names for span data by @ericapisani in #7329
- (starlette) Add
http.routeattribute by @alexander-alderman-webb in #7338 - (types) Export SpanJSON type by @ericapisani in #7331
- Add Python 3.15 to test matrix by @sentrivana in #7326
Bug Fixes π
Mcp
- Handle
Nonearguments in tool and prompt handlers by @alexander-alderman-webb in #7387 - Don't report stateless StreamableHTTP servers as stdio by @Snaylaker in #7224
Openai
- Read
input_textparts for the Responses API by @alexander-alderman-webb in #7333 - Check
Response.outputis alistbefore iterating by @alexander-alderman-webb in #7238
Starlette
- Use
urltransaction source for host routing by @mjq in #7266 - Set transaction name on current scope in sync handler by @mjq in #7201
Other
- (batcher) Do not let a failed flush kill the flusher thread (#7138) by @zkasuran in #7186
- (boto3) Fix botocore SigV4 failures caused by post-sign trace propagation by @pabloDeputter in #7050
- (httpx,httpx2) Always capture breadcrumb by @sentrivana in #7351
- (mcp,langchain) Add mechanism to captured exceptions by @gmassello in #7226
- (openai-agents) Use
isinstanceto determine tool type by @alexander-alderman-webb in #7412 - (quart) Skip quart-flask-patch and adjust error test for quart>=0.23 by @ericapisani in #7320
- Allow to correctly compare parsed versions by @sentrivana in #7184
Internal Changes π§
Openai Agents
- Capture spans instead of reading from span recorder by @alexander-alderman-webb in #7404
- Pin
openaiversion when incompatible by @alexander-alderman-webb in #7236
Pydantic Ai
- Replace individual hooks with
hooks.on.model_requestby @alexander-alderman-webb in #7327 - Fix instructions test for pydantic-ai >=2.36.0 by @ericapisani in #7321
Other
- (aiohttp) Remove dead segment name code by @mjq in #7284
- (anthropic) Include
StreamedSpanin type annotations by @alexander-alderman-webb in #7373 - (mcp) Inline
_extract_handler_data_from_args()by @alexander-alderman-webb in #7386 - (quart) Fix flake caused by flushing spans on segment end by @alexander-alderman-webb in #7240
- (stdlib) Remove urllib3 workaround by @pabloDeputter in #7283
- Add
openai-agentsto uv typing group by @alexander-alderman-webb in #7415 - Add
aiohttpto uv typing group by @alexander-alderman-webb in #7395 - Isolate
httpxtest suite fromhttpx2by @ZaafirRizwan in #7398 - Remove
test_langchain_embeddings_error_handling()by @alexander-alderman-webb in #7389 - Add
tiktokento uv typing group by @alexander-alderman-webb in #7394 - Reference renamed coverage action by @MathurAditya724 in #7371
- Remove flaky detector by @sl0thentr0py in #7363
- Add
openaito uv typing group by @alexander-alderman-webb in #7334 - π€ Update test matrix with new releases (08/31) by @github-actions in #7303
- Add
anthropicto uv typing group by @alexander-alderman-webb in #7324 - Add
google-genaito uv typing group by @alexander-alderman-webb in #7323 - Use tagged versions for
getsentry/codecov-actionby @alexander-alderman-webb in #7241 - Update test matrix with new releases (08/24) by @alexander-alderman-webb in #7228
- Add
httpxdependency to tests relying onget_model_response()by @alexander-alderman-webb in #7235 - Access the 'type' in an event using
.getby @ericapisani in #7239
2.68.1
enable_logs
-
(logs) Don't stop sending auto-collected logs when
enable_logs=Trueby @sentrivana in #7237If you have
enable_logsset toTrue, our logging integrations for the standard library logging module as well as Loguru will auto-collect logs and send them to Sentry as Sentry logs by default, preserving old behavior. Turning automatic collection off for a specific integration can still be achieved using thecapture_sentry_logsintegration option.import sentry_sdk from sentry_sdk.integrations.logging import LoggingIntegration from sentry_sdk.integrations.loguru import LoguruIntegration sentry_sdk.init( enable_logs=True, integrations=[ LoggingIntegration(capture_sentry_logs=True), LoguruIntegration(capture_sentry_logs=False), ], )
Please note that the
enable_logsoption is deprecated and will be removed in the next major release. Thesentry_sdk.logger.XAPI now works regardless of it, and auto-collection can be opted into via thecapture_sentry_logsintegration-level options, which areFalseby default, unless you haveenable_logs=True. We've added this compatibility layer to make the transition to aenable_logs-free world easier.
Bug Fixes π
- (django) Add
failed_request_status_codesby @mgaligniana in #7140 - (anthropic) Gate
gen_ai.response.tool_callson outputs, not inputs by @ericapisani in #7207 - (google_genai) Gate streaming
gen_ai.response.tool_callson outputs, not inputs by @ericapisani in #7210 - (langchain) Use
gen_ai.tool.definitionsattribute when data collection is enabled by @ericapisani in #7204 - (langgraph,huggingface_hub) Gate
gen_ai.response.tool_callson outputs, not inputs by @ericapisani in #7208 - (openai) Gate
gen_ai.response.tool_callson outputs, not inputs by @ericapisani in #7205 - (openai_agents) Gate
gen_ai.response.tool_callson outputs, not inputs by @ericapisani in #7209
2.68.0
Important
-
We're making
enable_logsandenable_metricsno-op with this release (#7177), and they'll be dropped in the next major.Previously,
enable_logsalso controlled automatic logs collection from the logging and Loguru integrations. These integrations now get an integration-levelcapture_sentry_logsboolean option to allow for more control over the auto-collection. These options areFalseby default, i.e., nothing is auto-collected without your explicit opt-in.Action Needed
If you had
enable_logsset toTrue:- If you were using the
sentry_sdk.logger.XAPI, no action necessary, the API will just work. - If you were auto-collecting logs from either
LoggingIntegrationorLoguruIntegration, the auto-collection will be turned off in this release. You can switch auto-collection on explicitly with:
import sentry_sdk from sentry_sdk.integrations.logging import LoggingIntegration from sentry_sdk.integrations.loguru import LoguruIntegration sentry_sdk.init( integrations=[ LoggingIntegration(capture_sentry_logs=True), LoguruIntegration(capture_sentry_logs=True), ], )
If you had
enable_logsset toFalse:- If you were using it to gate usages of the
sentry_sdk.logger.XAPI, you'll need to remove the calls entirely or define abefore_send_logcallback to filter out unwanted logs.
If you has
enable_metricsset toFalse:- Any metrics emitted using the metrics API will be emitted. You'll need to drop them in a
before_send_metricor remove the calls to the API.
Why We're Doing This
We recognize this is a disruptive change for some folks and want to make it clear this is a one-off. We're removing the options because they were an unnecessary hurdle that one had to jump through to be able to use logs and metrics, and it was confusing why the logging API would not just work on its own. On the other hand, we wanted to give you more fine-grained control over automatic collection.
- If you were using the
New Features β¨
Other
- Set the segment source on the scope for
NoOpStreamedSpanby @alexander-alderman-webb in #7163 - Remove early return for
NoOpStreamedSpaninset_transaction_name()by @alexander-alderman-webb in #7164 - Set the segment name on the scope with
NoOpStreamedSpanby @alexander-alderman-webb in #7162
Bug Fixes π
- (batcher) Add global flush trigger based on the span number by @alexander-alderman-webb in #7150
Internal Changes π§
HTTPX, HTTPX2
- Move crumbs to integrations by @sentrivana in #7149
- Split into sync/async tests by @sentrivana in #7152
Other
- (aiohttp) Move crumbs to integration by @sentrivana in #7135
- (boto3) Move crumbs to integration by @sentrivana in #7165
- (django) Remove dead code and stale markers from the Django test suite by @ericapisani in #7156
- (pyreqwest) Move crumbs to integration by @sentrivana in #7148
- (stdlib) Move crumbs to integration by @sentrivana in #7161
- Flush trace buckets when segment spans finish by @alexander-alderman-webb in #7170
- Revert global span batcher limits by @alexander-alderman-webb in #7168
2.67.1
Bug Fixes π
- (batcher) Add global flush trigger based on the span number by @alexander-alderman-webb in #7150
2.67.0
New Features β¨
Batcher
- Add global flush trigger based on summed size estimates by @alexander-alderman-webb in #7144
- Add hard span limit by @alexander-alderman-webb in #7143
Integrations
- Add span for DRF authentication by @mgaligniana in #6984
Langchain
- Record reasoning token usage attribute by @alexander-alderman-webb in #7136
- Record cached token usage attributes by @alexander-alderman-webb in #7132
Openai
- Set
gen_ai.tool.definitionsfor the Responses API by @alexander-alderman-webb in #6951 - Set
gen_ai.tool.definitionsfor the Chat Completions API by @alexander-alderman-webb in #6950 - Add
gen_ai.request.reasoning.levelto OpenAI spans by @pabloDeputter in #6892
Streaming
- Support ai_track decorator by @sentrivana in #6895
- Promote
before_send_spanto top-level option by @sentrivana in #6885 - Make
set_conversation_idAPI work by @sentrivana in #6866
Other
- (api) Add top-level
set_attributesAPI by @sentrivana in #6897 - (aws-lambda) Enable Python 3.14 support to the Lambda layer by @pabloDeputter in #6916
- (openai-agents) Set the
gen_ai.tool.definitionsattribute by @alexander-alderman-webb in #6956 - (pydantic-ai) Record
gen_ai.output.messagesincludingThinkingPartby @alexander-alderman-webb in #7037 - Add possibility to allowlist integrations in toxgen by @sentrivana in #6996
Bug Fixes π
Openai Agents
- Patch correct
run_single_turn_streamedreference by @alexander-alderman-webb in #7032 - Stop destructively wrapping tools by @alexander-alderman-webb in #6961
Tests
- Adapt to new exception propagation behavior in Quart by @sentrivana in #6995
- Remove redundant type filters after
capture_itemswith args by @sentrivana in #6867
Other
- (aws-lambda) Fix flake in aws lambda tests by @pabloDeputter in #6937
- (langchain) Stop double-counting usage in multi-candidate responses by @alexander-alderman-webb in #7064
- (mcp) Stop adding the prompt name to arguments by @alexander-alderman-webb in #6765
- (pydantic-ai) Stop recording duplicate spans by @alexander-alderman-webb in #7056
- (sampling)
sentry-traceshould take precedence over baggage by @sentrivana in #6863 - (streaming) Set segment source if unset by @sentrivana in #6791
- Do not let exceptions in before_breadcrumb bubble up by @sentrivana in #7133
- Correct typo in test function name by @TheGreatApollyon in #6967
- Include query string and fragment in
url.fullspan attribute by @sentrivana in #6861
Documentation π
- Remove AI commit attribution requirement from AGENTS.md by @ericapisani in #6828
Internal Changes π§
Fastmcp
- Skip SSE test for
fastmcp>=4by @alexander-alderman-webb in #6923 - Remove assertions on
RootModelinstances by @alexander-alderman-webb in #6909 - Replace broad
try...exceptwithskipifby @alexander-alderman-webb in #6922
Mcp
- Replace instance patches with middleware by @alexander-alderman-webb in #6764
- Remove redundant
mcp.tool.result.is_errorby @alexander-alderman-webb in #6915 - Use
mcp_typespackage by @alexander-alderman-webb in #6763 - Inline
_set_span_output_data()by @alexander-alderman-webb in #6762 - Inline
_get_span_config()by @alexander-alderman-webb in #6761 - Inline
_prepare_handler_data()by @alexander-alderman-webb in #6758 - Separate tool, prompt and resource patches by @alexander-alderman-webb in #6726
Openai Agents
- Stop setting
gen_ai.response.modelon Invoke Agent spans by @alexander-alderman-webb in #7028 - Use first class tool hooks when available by @alexander-alderman-webb in #6994
- Assert subset of expected dictionary is in
gen_ai.response.tool_callsby @alexander-alderman-webb in #6973 - Stop setting
gen_ai.request.available_toolson Invoke Agent spans by @alexander-alderman-webb in #6955 - Stop setting
gen_ai.request.available_toolson Execute Tool spans by @alexander-alderman-webb in #6954
Other
- (ai) Route AI integration tests through OpenRouter by @sentry-junior in #6979
- (arq) Avoid race between the exception and transaction events by @alexander-alderman-webb in #7052
- (aws_lambda) Add ARM64 architecture support for local Lambda testing by @ericapisani in #7053
- (deps) Lock file maintenance by @renovate in #6734
- (django) Use
iscoroutinefunctionshim inpatch_views()by @alexander-alderman-webb in #7024 - (httpx) Replace deprecated
asyncio.iscoroutinefunctionby @alexander-alderman-webb in #7023 - (huggingface-hub) Fix chat completion stream type by @alexander-alderman-webb in #7070
- (langchain) Remove
on_agent_finish()hook by @alexander-alderman-webb in #7059 - (pydantic-ai) Use
FunctionModelfor testing output data transformations by @alexander-alderman-webb in #7036 - (serializer) Avoid copying the whole Mapping before trimming to
MAX_DATABAG_BREADTHby @Malkiz223 in #6783 - (tests) Replace _transport_works_cases loop with explicit case list by @ericapisani in #6978
- π€ Update test matrix with new releases (08/10) by @github-actions in #7142
- Pin
litellm<=1.96for generating test suites by @alexander-alderman-webb in #7147 - Unpin Django version for generating test suites by @alexander-alderman-webb in #7146
- Move Redis breadcrumbs to integration by @sentrivana in #7129
- Move subprocess breadcrumbs to integration by @sentrivana in #7128
- Avoid scanning installed packages when MCP SDK is not installed by @mangodxd in #6865
- Remove
test-lambda-locallyby @alexander-alderman-webb in #7069 - Add
pydantic-ai-slimto uv typing group by @alexander-alderman-webb in #7025 - Add
langchain-baseto uv typing group by @alexander-alderman-webb in #7016 - π€ Update test matrix with new releases (08/03) by @github-actions in #6985
- Mock attributes in redis cluster tests by @sentrivana in #7022
- Deprecate
ai_track()by @alexander-alderman-webb in #7005 - Reduce common test suite while not reducing coverage by @ericapisani in #6972
- Use top-level options if available by @sentrivana in #6959
- Restore wrapped functions in
functions_to_tracetes...
2.66.1
Bug Fixes π
Tracing
- Handle exceptions raised within traces_sampler and other callbacks by @ericapisani in #6853
Internal Changes π§
- Fix flaky decorator test by @sl0thentr0py in #6830
2.66.0
New Features β¨
- (tracing) Promote trace_lifecycle and ignore_spans to top-level options by @ericapisani in #6821
Bug Fixes π
Tracing
- Skip child span creation in streaming path when no current span (HTTP clients) by @sentrivana in #6811
- Skip child span creation in streaming path when no current span (task queues) by @sentrivana in #6814
- Skip child span creation in streaming path when no current span (misc) by @sentrivana in #6815
- Skip child span creation in streaming path when no current span (databases) by @sentrivana in #6808
- Skip child span creation in streaming path when no current span (web frameworks) by @sentrivana in #6810
- Skip child span creation in streaming path when no current span (django) by @sentrivana in #6809
Internal Changes π§
- (logging) Fix flaky test_logging_captured_warnings by @ericapisani in #6824
- Remove flaky no cyclic garbage test by @alexander-alderman-webb in #6817
- Remove Claude permission settings by @cleptric in #6806
- Move
nullcontexttosentry_sdk.utilsby @sentrivana in #6805