Skip to content

Conversation

@sl0thentr0py
Copy link
Member

@sl0thentr0py sl0thentr0py commented Oct 30, 2025

Description

Currently setup_once is called without any arguments so cannot access either the SDK init options or the integration specific init arguments on the instance. This PR enables a separate backwards compat optional setup_once_with_options as an instance method.

Note that we we will use this rarely but I need it to unblock the OTLPIntegration since I need the DSN there.

Example

before

sentry_sdk.init(dsn="")

class FooIntegration(Integration):
    def __init__(self, bar=42):
        self.bar = bar

    @staticmethod
    def setup_once():
        self.bar # Not available
        options.dsn  # Not available

after

    def setup_once_with_options(self, options=None):
        self.bar
        options.dsn

@sl0thentr0py sl0thentr0py requested a review from a team as a code owner October 30, 2025 12:39
@codecov
Copy link

codecov bot commented Oct 30, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 83.92%. Comparing base (3e86962) to head (d47e965).
⚠️ Report is 1 commits behind head on master.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #5047      +/-   ##
==========================================
- Coverage   83.92%   83.92%   -0.01%     
==========================================
  Files         179      179              
  Lines       17890    17893       +3     
  Branches     3181     3181              
==========================================
+ Hits        15015    15017       +2     
- Misses       1909     1910       +1     
  Partials      966      966              
Files with missing lines Coverage Δ
sentry_sdk/client.py 84.22% <ø> (ø)
sentry_sdk/integrations/__init__.py 87.50% <100.00%> (+0.48%) ⬆️

... and 1 file with indirect coverage changes

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.

I don't love it but probably the least invasive way to go about things atm

Worth exploring migrating everything to the instance method at some point in the future

Co-authored-by: Ivana Kellyer <ivana.kellyer@sentry.io>
@sl0thentr0py sl0thentr0py enabled auto-merge (squash) October 30, 2025 13:17
@sl0thentr0py
Copy link
Member Author

yea its ugly but don't wanna do yet another refactor now

@sl0thentr0py sl0thentr0py merged commit 2d49b74 into master Oct 30, 2025
134 of 136 checks passed
@sl0thentr0py sl0thentr0py deleted the neel/allow-integration-setup-config branch October 30, 2025 13:32
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.

3 participants