Skip to content

Conversation

@BYK
Copy link
Member

@BYK BYK commented Nov 27, 2025

Align the Spotlight implementation with the official spec at
https://develop.sentry.dev/sdk/expected-features/spotlight/

Changes:

  1. Fix precedence rules:

    • When spotlight=True and SENTRY_SPOTLIGHT env var is a URL, use the
      env var URL (per spec requirement)
    • Log warning when config URL overrides env var URL
    • Log warning when spotlight=False explicitly disables despite env
      var being set
  2. Route all envelopes to Spotlight:

    • Sessions, logs, and metrics now also get sent to Spotlight via the
      _capture_envelope callback
    • Move Spotlight initialization before batchers are created
  3. Add exponential backoff retry logic:

    • SpotlightClient now implements proper exponential backoff when the
      Spotlight server is unreachable
    • Skips sending during backoff period to avoid blocking
    • Logs errors only once per backoff cycle
  4. Update tests:

    • Fix test expectation for spotlight=True + env URL case
    • Add tests for warning scenarios
    • Add test for session envelope routing to Spotlight

Align the Spotlight implementation with the official spec at
https://develop.sentry.dev/sdk/expected-features/spotlight/

Changes:

1. Fix precedence rules:
   - When spotlight=True and SENTRY_SPOTLIGHT env var is a URL, use the
     env var URL (per spec requirement)
   - Log warning when config URL overrides env var URL
   - Log warning when spotlight=False explicitly disables despite env
     var being set

2. Route all envelopes to Spotlight:
   - Sessions, logs, and metrics now also get sent to Spotlight via the
     _capture_envelope callback
   - Move Spotlight initialization before batchers are created

3. Add exponential backoff retry logic:
   - SpotlightClient now implements proper exponential backoff when the
     Spotlight server is unreachable
   - Skips sending during backoff period to avoid blocking
   - Logs errors only once per backoff cycle

4. Update tests:
   - Fix test expectation for spotlight=True + env URL case
   - Add tests for warning scenarios
   - Add test for session envelope routing to Spotlight
@BYK BYK marked this pull request as ready for review November 27, 2025 23:23
@BYK BYK requested a review from a team as a code owner November 27, 2025 23:23
@BYK BYK force-pushed the fix/spotlight-spec-alignment branch from 6e8b34a to 5168606 Compare December 1, 2025 15:05
@codecov
Copy link

codecov bot commented Dec 1, 2025

Codecov Report

❌ Patch coverage is 87.50000% with 7 lines in your changes missing coverage. Please review.
✅ Project coverage is 83.93%. Comparing base (5fc28a1) to head (3703b3c).
⚠️ Report is 10 commits behind head on master.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
sentry_sdk/spotlight.py 84.78% 5 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #5169      +/-   ##
==========================================
+ Coverage   83.89%   83.93%   +0.03%     
==========================================
  Files         181      181              
  Lines       18343    18369      +26     
  Branches     3261     3269       +8     
==========================================
+ Hits        15389    15418      +29     
+ Misses       1946     1944       -2     
+ Partials     1008     1007       -1     
Files with missing lines Coverage Δ
sentry_sdk/client.py 83.58% <100.00%> (-0.13%) ⬇️
sentry_sdk/spotlight.py 67.36% <84.78%> (+9.70%) ⬆️

... and 3 files with indirect coverage changes

@BYK BYK requested a review from sentrivana December 1, 2025 15:17
Copy link
Contributor

@sentrivana sentrivana left a comment

Choose a reason for hiding this comment

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

🙏🏻

Align the Spotlight implementation with the official spec at
https://develop.sentry.dev/sdk/expected-features/spotlight/

Changes:

1. Fix precedence rules:
   - When spotlight=True and SENTRY_SPOTLIGHT env var is a URL, use the
     env var URL (per spec requirement)
   - Log warning when config URL overrides env var URL
   - Log warning when spotlight=False explicitly disables despite env
     var being set

2. Route all envelopes to Spotlight:
   - Sessions, logs, and metrics now also get sent to Spotlight via the
     _capture_envelope callback
   - Move Spotlight initialization before batchers are created

3. Add exponential backoff retry logic:
   - SpotlightClient now implements proper exponential backoff when the
     Spotlight server is unreachable
   - Skips sending during backoff period to avoid blocking
   - Logs errors only once per backoff cycle

4. Update tests:
   - Fix test expectation for spotlight=True + env URL case
   - Add tests for warning scenarios
   - Add test for session envelope routing to Spotlight
@BYK BYK force-pushed the fix/spotlight-spec-alignment branch from 5168606 to 3703b3c Compare December 1, 2025 15:28
@BYK BYK merged commit 6c6705a into master Dec 1, 2025
155 checks passed
@BYK BYK deleted the fix/spotlight-spec-alignment branch December 1, 2025 17:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants