Skip to content

feat(tracing): Promote trace_lifecycle and ignore_spans to top-level options#6821

Open
ericapisani wants to merge 4 commits into
masterfrom
py-2609-trace-lifecycle-top-level
Open

feat(tracing): Promote trace_lifecycle and ignore_spans to top-level options#6821
ericapisani wants to merge 4 commits into
masterfrom
py-2609-trace-lifecycle-top-level

Conversation

@ericapisani

@ericapisani ericapisani commented Jul 13, 2026

Copy link
Copy Markdown
Member

Expose trace_lifecycle and ignore_spans as top-level sentry_sdk.init()
parameters instead of requiring them under _experiments. The
_experiments keys remain supported for backwards compatibility, but the
top-level value now takes precedence: when both sources are set,
has_span_streaming_enabled and is_ignored_span respect the top-level
trace_lifecycle and fall back to _experiments only when it is unset.

Add a validation warning when ignore_spans is set but span streaming is
not enabled, since the option only takes effect in stream mode. Update the
span-streaming docstrings to reference the new top-level configuration.

Fixes PY-2609
Fixes #6820

…options

Expose `trace_lifecycle` and `ignore_spans` as top-level `sentry_sdk.init()`
parameters instead of requiring them under `_experiments`. The
`_experiments` keys remain supported for backwards compatibility, but the
top-level value now takes precedence: when both sources are set,
`has_span_streaming_enabled` and `is_ignored_span` respect the top-level
`trace_lifecycle` and fall back to `_experiments` only when it is unset.

Add a validation warning when `ignore_spans` is set but span streaming is
not enabled, since the option only takes effect in stream mode. Update the
span-streaming docstrings to reference the new top-level configuration.

Fixes PY-2609
Fixes #6820
@linear-code

linear-code Bot commented Jul 13, 2026

Copy link
Copy Markdown

PY-2609

Comment thread tests/tracing/test_span_streaming.py
@ericapisani ericapisani marked this pull request as ready for review July 13, 2026 19:06
@ericapisani ericapisani requested a review from a team as a code owner July 13, 2026 19:06

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Want reviews to match your repository better? Bugbot Learning can learn team-specific rules from PR activity. A team admin can enable Learning in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit b96d65a. Configure here.

Comment thread sentry_sdk/tracing_utils.py Outdated
Comment thread sentry_sdk/client.py
Comment thread sentry_sdk/tracing_utils.py Outdated
@github-actions

github-actions Bot commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Codecov Results 📊

91784 passed | ❌ 1 failed | ⏭️ 6302 skipped | Total: 98087 | Pass Rate: 93.57% | Execution Time: 304m 16s

📊 Comparison with Base Branch

Metric Change
Total Tests 📈 +600
Passed Tests 📈 +599
Failed Tests 📈 +1
Skipped Tests

➕ New Tests (1)

View new tests
  • test_logging_captured_warnings
    • File: tests.integrations.logging.test_logging
    • Status: ❌ Failing

❌ Failed Tests

test_logging_captured_warnings

File: tests.integrations.logging.test_logging
Suite: py3.13-common
Error: assert 2 == 1 + where 2 = len(WarningsRecorder(record=True))

Stack Trace
tests/integrations/logging/test_logging.py:227: in test_logging_captured_warnings
    assert len(recwarn) == 1
E   assert 2 == 1
E    +  where 2 = len(WarningsRecorder(record=True))

✅ Patch coverage is 100.00%. Project has 2433 uncovered lines.
✅ Project coverage is 89.82%. Comparing base (base) to head (head).

Coverage diff
@@            Coverage Diff             @@
##          main       #PR       +/-##
==========================================
+ Coverage    89.80%    89.82%    +0.02%
==========================================
  Files          193       193         —
  Lines        23898     23905        +7
  Branches      8258      8262        +4
==========================================
+ Hits         21461     21472       +11
- Misses        2437      2433        -4
- Partials      1353      1350        -3

Generated by Codecov Action

An explicit top-level ignore_spans=[] was treated as unset, letting
_experiments rules leak through. Use an is-not-None check so top-level
config wins whenever provided, including an empty list meant to disable
ignoring.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Create top-level options for trace_lifecycleand ignore_spans

1 participant