Skip to content

Commit 514f69f

Browse files
committed
Use setup_once
1 parent 92b0721 commit 514f69f

File tree

1 file changed

+8
-12
lines changed

1 file changed

+8
-12
lines changed

sentry_sdk/integrations/openfeature.py

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,23 +21,19 @@ class OpenFeatureIntegration(Integration):
2121
thread-local state to be serialized and sent off in the error payload.
2222
"""
2323

24-
def __init__(self):
25-
# type: (int) -> None
26-
# Store the error processor on the current scope. If its forked
27-
# (i.e. threads are spawned) the callback will be copied to the
28-
# new Scope.
24+
@staticmethod
25+
def setup_once():
26+
def error_processor(event, exc_info):
27+
scope = sentry_sdk.get_current_scope()
28+
event["contexts"]["flags"] = {"values": scope.flags.get()}
29+
return event
30+
2931
scope = sentry_sdk.get_current_scope()
30-
scope.add_error_processor(self.error_processor)
32+
scope.add_error_processor(error_processor)
3133

3234
# Register the hook within the global openfeature hooks list.
3335
api.add_hooks(hooks=[OpenFeatureHook()])
3436

35-
def error_processor(self, event, exc_info):
36-
event["contexts"]["flags"] = {
37-
"values": sentry_sdk.get_current_scope().flags.get()
38-
}
39-
return event
40-
4137

4238
class OpenFeatureHook(Hook):
4339

0 commit comments

Comments
 (0)