|
1 | 1 | from typing import TYPE_CHECKING |
2 | | -import sentry_sdk |
3 | 2 |
|
| 3 | +from sentry_sdk.feature_flags import add_feature_flag |
4 | 4 | from sentry_sdk.integrations import DidNotEnable, Integration |
5 | 5 |
|
6 | 6 | try: |
@@ -29,26 +29,9 @@ class OpenFeatureHook(Hook): |
29 | 29 | def after(self, hook_context, details, hints): |
30 | 30 | # type: (HookContext, FlagEvaluationDetails[bool], HookHints) -> None |
31 | 31 | if isinstance(details.value, bool): |
32 | | - # Errors support. |
33 | | - flags = sentry_sdk.get_current_scope().flags |
34 | | - flags.set(details.flag_key, details.value) |
35 | | - |
36 | | - # Spans support. |
37 | | - span = sentry_sdk.get_current_span() |
38 | | - if span: |
39 | | - span.set_data(f"flag.evaluation.{details.flag_key}", details.value) |
| 32 | + add_feature_flag(details.flag_key, details.value) |
40 | 33 |
|
41 | 34 | def error(self, hook_context, exception, hints): |
42 | 35 | # type: (HookContext, Exception, HookHints) -> None |
43 | 36 | if isinstance(hook_context.default_value, bool): |
44 | | - # Errors support. |
45 | | - flags = sentry_sdk.get_current_scope().flags |
46 | | - flags.set(hook_context.flag_key, hook_context.default_value) |
47 | | - |
48 | | - # Spans support. |
49 | | - span = sentry_sdk.get_current_span() |
50 | | - if span: |
51 | | - span.set_data( |
52 | | - f"flag.evaluation.{hook_context.flag_key}", |
53 | | - hook_context.default_value, |
54 | | - ) |
| 37 | + add_feature_flag(hook_context.flag_key, hook_context.default_value) |
0 commit comments