Skip to content

Commit 91eb352

Browse files
committed
Move hook registration to setup_once
1 parent d9775b8 commit 91eb352

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

sentry_sdk/integrations/launchdarkly.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,7 @@ def __init__(self, client=None):
3535

3636
if not client.is_initialized():
3737
raise DidNotEnable("LaunchDarkly client is not initialized.")
38-
39-
# Register the flag collection hook with the given client.
40-
client.add_hook(LaunchDarklyHook())
38+
self.ld_client = client
4139

4240
@staticmethod
4341
def setup_once():
@@ -51,6 +49,12 @@ def error_processor(event, _exc_info):
5149
scope = sentry_sdk.get_current_scope()
5250
scope.add_error_processor(error_processor)
5351

52+
# Register the flag collection hook with the LD client.
53+
ld_client = (
54+
sentry_sdk.get_client().get_integration(LaunchDarklyIntegration).ld_client
55+
)
56+
ld_client.add_hook(LaunchDarklyHook())
57+
5458

5559
class LaunchDarklyHook(Hook):
5660

0 commit comments

Comments
 (0)