|
17 | 17 | from sentry_sdk.transport import make_transport |
18 | 18 | from sentry_sdk.consts import DEFAULT_OPTIONS, SDK_INFO |
19 | 19 | from sentry_sdk.integrations import setup_integrations |
| 20 | +from sentry_sdk.utils import ContextVar |
| 21 | + |
| 22 | + |
| 23 | +_client_init_debug = ContextVar("client_init_debug") |
20 | 24 |
|
21 | 25 |
|
22 | 26 | def get_options(*args, **kwargs): |
@@ -50,20 +54,25 @@ class Client(object): |
50 | 54 | """ |
51 | 55 |
|
52 | 56 | def __init__(self, *args, **kwargs): |
53 | | - self.options = options = get_options(*args, **kwargs) |
54 | | - self.transport = make_transport(options) |
55 | | - |
56 | | - request_bodies = ("always", "never", "small", "medium") |
57 | | - if options["request_bodies"] not in request_bodies: |
58 | | - raise ValueError( |
59 | | - "Invalid value for request_bodies. Must be one of {}".format( |
60 | | - request_bodies |
| 57 | + old_debug = _client_init_debug.get(False) |
| 58 | + try: |
| 59 | + self.options = options = get_options(*args, **kwargs) |
| 60 | + _client_init_debug.set(options["debug"]) |
| 61 | + self.transport = make_transport(options) |
| 62 | + |
| 63 | + request_bodies = ("always", "never", "small", "medium") |
| 64 | + if options["request_bodies"] not in request_bodies: |
| 65 | + raise ValueError( |
| 66 | + "Invalid value for request_bodies. Must be one of {}".format( |
| 67 | + request_bodies |
| 68 | + ) |
61 | 69 | ) |
62 | | - ) |
63 | 70 |
|
64 | | - self.integrations = setup_integrations( |
65 | | - options["integrations"], with_defaults=options["default_integrations"] |
66 | | - ) |
| 71 | + self.integrations = setup_integrations( |
| 72 | + options["integrations"], with_defaults=options["default_integrations"] |
| 73 | + ) |
| 74 | + finally: |
| 75 | + _client_init_debug.set(old_debug) |
67 | 76 |
|
68 | 77 | @property |
69 | 78 | def dsn(self): |
|
0 commit comments