sentry-sdk 3.0.0a6__py2.py3-none-any.whl → 3.0.0a7__py2.py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of sentry-sdk might be problematic. Click here for more details.

@@ -1,4 +1,5 @@
1
1
  from __future__ import annotations
2
+ import warnings
2
3
 
3
4
  from typing import TYPE_CHECKING
4
5
 
@@ -25,6 +26,10 @@ def _init(*args: Optional[str], **kwargs: Any) -> None:
25
26
  setup_scope_context_management()
26
27
  client = sentry_sdk.Client(*args, **kwargs)
27
28
  sentry_sdk.get_global_scope().set_client(client)
29
+ warnings.warn(
30
+ "We won't be continuing development on SDK 3.0. Please use the last stable version of the SDK to get access to the newest features and fixes. See https://github.com/getsentry/sentry-python/discussions/4955",
31
+ stacklevel=2,
32
+ )
28
33
  _check_python_deprecations()
29
34
 
30
35
 
sentry_sdk/consts.py CHANGED
@@ -77,7 +77,6 @@ if TYPE_CHECKING:
77
77
  "transport_compression_level": Optional[int],
78
78
  "transport_compression_algo": Optional[CompressionAlgo],
79
79
  "transport_num_pools": Optional[int],
80
- "transport_http2": Optional[bool],
81
80
  "transport_async": Optional[bool],
82
81
  },
83
82
  total=False,
@@ -971,6 +970,7 @@ class ClientConstructor:
971
970
  max_stack_frames: Optional[int] = DEFAULT_MAX_STACK_FRAMES,
972
971
  enable_logs: bool = False,
973
972
  before_send_log: Optional[Callable[[Log, Hint], Optional[Log]]] = None,
973
+ http2: Optional[bool] = None,
974
974
  ) -> None:
975
975
  """Initialize the Sentry SDK with the given parameters. All parameters described here can be used in a call to `sentry_sdk.init()`.
976
976
 
@@ -1343,6 +1343,8 @@ class ClientConstructor:
1343
1343
  This is relative to the tracing sample rate - e.g. `0.5` means 50% of sampled transactions will be
1344
1344
  profiled.
1345
1345
 
1346
+ :param http2: Defaults to `True`, enables HTTP/2 support for the SDK.
1347
+
1346
1348
  :param profiles_sampler:
1347
1349
 
1348
1350
  :param profiler_mode:
@@ -1389,4 +1391,4 @@ DEFAULT_OPTIONS = _get_default_options()
1389
1391
  del _get_default_options
1390
1392
 
1391
1393
 
1392
- VERSION = "3.0.0a6"
1394
+ VERSION = "3.0.0a7"
@@ -38,7 +38,7 @@ class ThreadingIntegration(Integration):
38
38
 
39
39
  try:
40
40
  from django import VERSION as django_version # noqa: N811
41
- import channels # type: ignore[import-not-found]
41
+ import channels # type: ignore
42
42
 
43
43
  channels_version = channels.__version__
44
44
  except ImportError:
sentry_sdk/spotlight.py CHANGED
@@ -1,24 +1,16 @@
1
1
  from __future__ import annotations
2
2
  import io
3
3
  import logging
4
- import os
5
- import urllib.parse
6
- import urllib.request
7
- import urllib.error
8
4
  import urllib3
9
5
  import sys
10
6
 
11
- from itertools import chain, product
12
-
13
7
  from typing import TYPE_CHECKING
14
8
 
15
9
  if TYPE_CHECKING:
16
- from typing import Any, Callable, Dict, Optional
10
+ from typing import Any, Dict, Optional
17
11
 
18
12
  from sentry_sdk.utils import (
19
13
  logger as sentry_logger,
20
- env_to_bool,
21
- capture_internal_exceptions,
22
14
  )
23
15
  from sentry_sdk.envelope import Envelope
24
16
 
@@ -63,145 +55,6 @@ class SpotlightClient:
63
55
  # to avoid overflowing the variable if Spotlight never becomes reachable
64
56
 
65
57
 
66
- try:
67
- from django.utils.deprecation import MiddlewareMixin
68
- from django.http import HttpResponseServerError, HttpResponse, HttpRequest
69
- from django.conf import settings
70
-
71
- SPOTLIGHT_JS_ENTRY_PATH = "/assets/main.js"
72
- SPOTLIGHT_JS_SNIPPET_PATTERN = (
73
- "<script>window.__spotlight = {{ initOptions: {{ sidecarUrl: '{spotlight_url}', fullPage: false }} }};</script>\n"
74
- '<script type="module" crossorigin src="{spotlight_js_url}"></script>\n'
75
- )
76
- SPOTLIGHT_ERROR_PAGE_SNIPPET = (
77
- '<html><base href="{spotlight_url}">\n'
78
- '<script>window.__spotlight = {{ initOptions: {{ fullPage: true, startFrom: "/errors/{event_id}" }}}};</script>\n'
79
- )
80
- CHARSET_PREFIX = "charset="
81
- BODY_TAG_NAME = "body"
82
- BODY_CLOSE_TAG_POSSIBILITIES = tuple(
83
- "</{}>".format("".join(chars))
84
- for chars in product(*zip(BODY_TAG_NAME.upper(), BODY_TAG_NAME.lower()))
85
- )
86
-
87
- class SpotlightMiddleware(MiddlewareMixin): # type: ignore[misc]
88
- _spotlight_script: Optional[str] = None
89
- _spotlight_url: Optional[str] = None
90
-
91
- def __init__(self, get_response: Callable[..., HttpResponse]) -> None:
92
- super().__init__(get_response)
93
-
94
- import sentry_sdk.api
95
-
96
- self.sentry_sdk = sentry_sdk.api
97
-
98
- spotlight_client = self.sentry_sdk.get_client().spotlight
99
- if spotlight_client is None:
100
- sentry_logger.warning(
101
- "Cannot find Spotlight client from SpotlightMiddleware, disabling the middleware."
102
- )
103
- return None
104
- # Spotlight URL has a trailing `/stream` part at the end so split it off
105
- self._spotlight_url = urllib.parse.urljoin(spotlight_client.url, "../")
106
-
107
- @property
108
- def spotlight_script(self) -> Optional[str]:
109
- if self._spotlight_url is not None and self._spotlight_script is None:
110
- try:
111
- spotlight_js_url = urllib.parse.urljoin(
112
- self._spotlight_url, SPOTLIGHT_JS_ENTRY_PATH
113
- )
114
- req = urllib.request.Request(
115
- spotlight_js_url,
116
- method="HEAD",
117
- )
118
- urllib.request.urlopen(req)
119
- self._spotlight_script = SPOTLIGHT_JS_SNIPPET_PATTERN.format(
120
- spotlight_url=self._spotlight_url,
121
- spotlight_js_url=spotlight_js_url,
122
- )
123
- except urllib.error.URLError as err:
124
- sentry_logger.debug(
125
- "Cannot get Spotlight JS to inject at %s. SpotlightMiddleware will not be very useful.",
126
- spotlight_js_url,
127
- exc_info=err,
128
- )
129
-
130
- return self._spotlight_script
131
-
132
- def process_response(
133
- self, _request: HttpRequest, response: HttpResponse
134
- ) -> Optional[HttpResponse]:
135
- content_type_header = tuple(
136
- p.strip()
137
- for p in response.headers.get("Content-Type", "").lower().split(";")
138
- )
139
- content_type = content_type_header[0]
140
- if len(content_type_header) > 1 and content_type_header[1].startswith(
141
- CHARSET_PREFIX
142
- ):
143
- encoding = content_type_header[1][len(CHARSET_PREFIX) :]
144
- else:
145
- encoding = "utf-8"
146
-
147
- if (
148
- self.spotlight_script is not None
149
- and not response.streaming
150
- and content_type == "text/html"
151
- ):
152
- content_length = len(response.content)
153
- injection = self.spotlight_script.encode(encoding)
154
- injection_site = next(
155
- (
156
- idx
157
- for idx in (
158
- response.content.rfind(body_variant.encode(encoding))
159
- for body_variant in BODY_CLOSE_TAG_POSSIBILITIES
160
- )
161
- if idx > -1
162
- ),
163
- content_length,
164
- )
165
-
166
- # This approach works even when we don't have a `</body>` tag
167
- response.content = (
168
- response.content[:injection_site]
169
- + injection
170
- + response.content[injection_site:]
171
- )
172
-
173
- if response.has_header("Content-Length"):
174
- response.headers["Content-Length"] = content_length + len(injection)
175
-
176
- return response
177
-
178
- def process_exception(
179
- self, _request: HttpRequest, exception: Exception
180
- ) -> Optional[HttpResponseServerError]:
181
- if not settings.DEBUG or not self._spotlight_url:
182
- return None
183
-
184
- try:
185
- spotlight = (
186
- urllib.request.urlopen(self._spotlight_url).read().decode("utf-8")
187
- )
188
- except urllib.error.URLError:
189
- return None
190
- else:
191
- event_id = self.sentry_sdk.capture_exception(exception)
192
- return HttpResponseServerError(
193
- spotlight.replace(
194
- "<html>",
195
- SPOTLIGHT_ERROR_PAGE_SNIPPET.format(
196
- spotlight_url=self._spotlight_url, event_id=event_id
197
- ),
198
- )
199
- )
200
-
201
- except ImportError:
202
- settings = None
203
-
204
-
205
58
  def setup_spotlight(options: Dict[str, Any]) -> Optional[SpotlightClient]:
206
59
  _handler = logging.StreamHandler(sys.stderr)
207
60
  _handler.setFormatter(logging.Formatter(" [spotlight] %(levelname)s: %(message)s"))
@@ -216,20 +69,6 @@ def setup_spotlight(options: Dict[str, Any]) -> Optional[SpotlightClient]:
216
69
  if not isinstance(url, str):
217
70
  return None
218
71
 
219
- with capture_internal_exceptions():
220
- if (
221
- settings is not None
222
- and settings.DEBUG
223
- and env_to_bool(os.environ.get("SENTRY_SPOTLIGHT_ON_ERROR", "1"))
224
- and env_to_bool(os.environ.get("SENTRY_SPOTLIGHT_MIDDLEWARE", "1"))
225
- ):
226
- middleware = settings.MIDDLEWARE
227
- if DJANGO_SPOTLIGHT_MIDDLEWARE_PATH not in middleware:
228
- settings.MIDDLEWARE = type(middleware)(
229
- chain(middleware, (DJANGO_SPOTLIGHT_MIDDLEWARE_PATH,))
230
- )
231
- logger.info("Enabled Spotlight integration for Django")
232
-
233
72
  client = SpotlightClient(url)
234
73
  logger.info("Enabled Spotlight using sidecar at %s", url)
235
74
 
sentry_sdk/transport.py CHANGED
@@ -1051,7 +1051,12 @@ else:
1051
1051
  def make_transport(options: Dict[str, Any]) -> Optional[Transport]:
1052
1052
  ref_transport = options["transport"]
1053
1053
 
1054
- use_http2_transport = options.get("_experiments", {}).get("transport_http2", False)
1054
+ # We default to using HTTP2 transport if the user also has the required h2
1055
+ # library installed (through the subclass check). The reason is h2 not being
1056
+ # available on py3.7 which we still support.
1057
+ use_http2_transport = options.get("http2") is not False and not issubclass(
1058
+ Http2Transport, HttpTransport
1059
+ )
1055
1060
  use_async_transport = options.get("_experiments", {}).get("transport_async", False)
1056
1061
  async_integration = any(
1057
1062
  integration.__class__.__name__ == "AsyncioIntegration"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: sentry-sdk
3
- Version: 3.0.0a6
3
+ Version: 3.0.0a7
4
4
  Summary: Python client for Sentry (https://sentry.io)
5
5
  Home-page: https://github.com/getsentry/sentry-python
6
6
  Author: Sentry Team and Contributors
@@ -1,6 +1,6 @@
1
1
  sentry_sdk/__init__.py,sha256=C3U0psDzNPIoYrHqjV1w5TXU6xJWUGHe1e0y58ODF3c,1309
2
2
  sentry_sdk/_compat.py,sha256=wP2ZOiqdpaVaC2IPh3O-GwDK1H-3-momIn5bmMNrCGY,2969
3
- sentry_sdk/_init_implementation.py,sha256=PJrU7NZTWOE7hH2n_odcs1E3Nc_2TK2ilLwn5trJXns,1521
3
+ sentry_sdk/_init_implementation.py,sha256=FEwbffFJU3hpmtEwifg75CQNCEbeq77eQVyijYnvVec,1800
4
4
  sentry_sdk/_log_batcher.py,sha256=Ugg89Q1hnNgNfBV2-SUl_8qJN9Qy-Ux8qWw7VQR0KXo,4840
5
5
  sentry_sdk/_lru_cache.py,sha256=H_BCecDD-7qSmcI0c6Q8i1nzBJMRBLFqXuax-ofh6wg,1189
6
6
  sentry_sdk/_queue.py,sha256=AWE9LpaPhNm4VEUiY3TJWIXfAw44D-dgFXuhZdBHF-k,11119
@@ -9,7 +9,7 @@ sentry_sdk/_werkzeug.py,sha256=qEPz7ZYBeBkILq3snw0GnaZQbt5mItMQO9JQ3YDCCgg,3702
9
9
  sentry_sdk/api.py,sha256=QUgXqmXX0e8bRWc04gDUPpcsr-Upa_aAgdU0mS8RAXA,11058
10
10
  sentry_sdk/attachments.py,sha256=la0cbz1yc8cV4PQyM3kgArvWjGWtjxq945wgiKdaoCs,3046
11
11
  sentry_sdk/client.py,sha256=jMRJJ6AwNseGMiP5KbionL6H6mVh5R8ofYDiKrZb8gc,38425
12
- sentry_sdk/consts.py,sha256=5frscnj4vzLXHE2QaZoATsmC40NLmejJw5aDzdbIy4M,51036
12
+ sentry_sdk/consts.py,sha256=Ge9cKn3g1Bcv8UiXHW9HblEJpMBnfIvsAtdJpTmm4rg,51106
13
13
  sentry_sdk/debug.py,sha256=ac50G-ZSRUTLhu6VVaJnc4sGsQM1lIN6qWR1AS4oTH4,773
14
14
  sentry_sdk/envelope.py,sha256=2Bmjlm7bctrtkYeWVPNGBHBAL6pMFtULUXCONeq6QY8,9118
15
15
  sentry_sdk/feature_flags.py,sha256=uLIi4SjN1EuFP59AduFS5dIzqUYOidPZUCZjuqrAbhg,2144
@@ -21,10 +21,10 @@ sentry_sdk/scrubber.py,sha256=NYMTKALIIHCu1aZaTThR3qsmcvCA4hcKpzWUacEbWpg,6006
21
21
  sentry_sdk/serializer.py,sha256=twylwvlYrP67Mq4AXVQEuNeeOVAkyIdnyvBj8yLwq7U,12360
22
22
  sentry_sdk/session.py,sha256=UunkzHmyV7rZu2a6kWMB5BZNJnQc9WiEkJnPu5aHjto,5097
23
23
  sentry_sdk/sessions.py,sha256=0puTgebSwYPNH6zq004QLe1q4VM7XOK8iCzsFfcGLzs,6069
24
- sentry_sdk/spotlight.py,sha256=mHFbVED17LBAaVdRJbNfE9c9NmknWTZ4Y3lkYkJkJuI,8492
24
+ sentry_sdk/spotlight.py,sha256=QgA4HEiTzUsPK5bgjonOPZoIwJUBiTK40tR1Wk4ZA8U,2153
25
25
  sentry_sdk/tracing.py,sha256=cr-cp07kb0wnilK1dErihKFo4kwqegpTAYY2Q_EktMY,20864
26
26
  sentry_sdk/tracing_utils.py,sha256=o9fFdHQXgZED639k45XyiamWTYoggvYJoaCgEGxa93c,37143
27
- sentry_sdk/transport.py,sha256=xhlXeVWYIcDHTDSxUSiCz7XX0DG0ajs-csiYqGJXMuQ,39754
27
+ sentry_sdk/transport.py,sha256=YQN-MNw_p-a-b1D7WwPH4x8sclNrbDXWmGnpzUuSIbQ,39999
28
28
  sentry_sdk/types.py,sha256=NLbnRzww2K3_oGz2GzcC8TdX5L2DXYso1-H1uCv2Hwc,1222
29
29
  sentry_sdk/utils.py,sha256=2t0Xyepb2ddmd6ssUhjDPE9YZddBVal3KUFEjpZrMgQ,60547
30
30
  sentry_sdk/worker.py,sha256=w-oRJoqM9mfOFabBfoqFb63LZ-9ch-3PngWs-Q_88X4,11345
@@ -94,7 +94,7 @@ sentry_sdk/integrations/statsig.py,sha256=3Abtq8S5EqHUYVaMf61_MiIx5oZfLz09d61Cz9
94
94
  sentry_sdk/integrations/stdlib.py,sha256=HNc2haRxGZHU9ObFvknBdYGhoAeylIG_XfYY1lMUDPM,10345
95
95
  sentry_sdk/integrations/strawberry.py,sha256=fwolVXMtauXXzqzcYtKw34tixsw-I_KlBPWZIU0lmLs,13506
96
96
  sentry_sdk/integrations/sys_exit.py,sha256=Ke4DuytNWJgmAIiA7DppkSYRiKREkiKQuh5QOHf763g,2435
97
- sentry_sdk/integrations/threading.py,sha256=m2mJneJ7EwCD8Os2yr5g5UiAe3oH1giG9nkmLsWx3Qk,4647
97
+ sentry_sdk/integrations/threading.py,sha256=rSBSjxHA2NBnQaNguqIGHsC6ZPx6_Kdu8irmfaCj6Ok,4629
98
98
  sentry_sdk/integrations/tornado.py,sha256=QFNTjteEJlP4cIc-7MRl5y3ePdOdjf3CrjxPS1l5s3g,8459
99
99
  sentry_sdk/integrations/trytond.py,sha256=D2UTrVyLn4uCgnFb68-CnZGkNCa0gBjiQL8bjQ5w-ts,1816
100
100
  sentry_sdk/integrations/typer.py,sha256=X-VvPfMn9mOrgt-Pf5uZZyescnFsLXFce83cURy7URo,1832
@@ -160,9 +160,9 @@ sentry_sdk/profiler/__init__.py,sha256=bYeDkmLQliS2KkNSOGa8Sx4zN3pjTc3WmYIvbkcGk
160
160
  sentry_sdk/profiler/continuous_profiler.py,sha256=AXwhI-NI6hx82EnKEy_oNQPPl9nwLQJKcj_QRX6KKAg,21574
161
161
  sentry_sdk/profiler/transaction_profiler.py,sha256=gbe9RedrGqPakPi3uY9fUDXp0IcM9djHuVcYUcbDRfg,25381
162
162
  sentry_sdk/profiler/utils.py,sha256=cdjpSQ9IAchtMPLWNFGDjZHIXArTbcPtFPEngB9Tb9c,6475
163
- sentry_sdk-3.0.0a6.dist-info/licenses/LICENSE,sha256=KhQNZg9GKBL6KQvHQNBGMxJsXsRdhLebVp4Sew7t3Qs,1093
164
- sentry_sdk-3.0.0a6.dist-info/METADATA,sha256=vy2Okj-SATP_HFIcncvnODT2XP7hQFQG1HnoTJMCXjw,10233
165
- sentry_sdk-3.0.0a6.dist-info/WHEEL,sha256=JNWh1Fm1UdwIQV075glCn4MVuCRs0sotJIq-J6rbxCU,109
166
- sentry_sdk-3.0.0a6.dist-info/entry_points.txt,sha256=-FP10-IbDq7-9RSn7JcaVV6-nDwVN2kwvA46zNTNwtk,78
167
- sentry_sdk-3.0.0a6.dist-info/top_level.txt,sha256=XrQz30XE9FKXSY_yGLrd9bsv2Rk390GTDJOSujYaMxI,11
168
- sentry_sdk-3.0.0a6.dist-info/RECORD,,
163
+ sentry_sdk-3.0.0a7.dist-info/licenses/LICENSE,sha256=KhQNZg9GKBL6KQvHQNBGMxJsXsRdhLebVp4Sew7t3Qs,1093
164
+ sentry_sdk-3.0.0a7.dist-info/METADATA,sha256=_jn2IUTzIMYYmVKPCbZlF-Xgvxd4XRB7rvcSwmtQE1U,10233
165
+ sentry_sdk-3.0.0a7.dist-info/WHEEL,sha256=JNWh1Fm1UdwIQV075glCn4MVuCRs0sotJIq-J6rbxCU,109
166
+ sentry_sdk-3.0.0a7.dist-info/entry_points.txt,sha256=-FP10-IbDq7-9RSn7JcaVV6-nDwVN2kwvA46zNTNwtk,78
167
+ sentry_sdk-3.0.0a7.dist-info/top_level.txt,sha256=XrQz30XE9FKXSY_yGLrd9bsv2Rk390GTDJOSujYaMxI,11
168
+ sentry_sdk-3.0.0a7.dist-info/RECORD,,