sentry-sdk 3.0.0a1__py2.py3-none-any.whl → 3.0.0a3__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.
- sentry_sdk/__init__.py +2 -0
- sentry_sdk/_compat.py +5 -12
- sentry_sdk/_init_implementation.py +7 -7
- sentry_sdk/_log_batcher.py +17 -29
- sentry_sdk/_lru_cache.py +7 -9
- sentry_sdk/_queue.py +2 -4
- sentry_sdk/_types.py +11 -18
- sentry_sdk/_werkzeug.py +5 -7
- sentry_sdk/ai/monitoring.py +44 -31
- sentry_sdk/ai/utils.py +3 -4
- sentry_sdk/api.py +75 -87
- sentry_sdk/attachments.py +10 -12
- sentry_sdk/client.py +137 -155
- sentry_sdk/consts.py +430 -174
- sentry_sdk/crons/api.py +16 -17
- sentry_sdk/crons/decorator.py +25 -27
- sentry_sdk/debug.py +4 -6
- sentry_sdk/envelope.py +46 -112
- sentry_sdk/feature_flags.py +9 -15
- sentry_sdk/integrations/__init__.py +24 -19
- sentry_sdk/integrations/_asgi_common.py +15 -18
- sentry_sdk/integrations/_wsgi_common.py +22 -33
- sentry_sdk/integrations/aiohttp.py +32 -30
- sentry_sdk/integrations/anthropic.py +42 -37
- sentry_sdk/integrations/argv.py +3 -4
- sentry_sdk/integrations/ariadne.py +16 -18
- sentry_sdk/integrations/arq.py +21 -29
- sentry_sdk/integrations/asgi.py +63 -37
- sentry_sdk/integrations/asyncio.py +14 -16
- sentry_sdk/integrations/atexit.py +6 -10
- sentry_sdk/integrations/aws_lambda.py +26 -36
- sentry_sdk/integrations/beam.py +10 -18
- sentry_sdk/integrations/boto3.py +18 -16
- sentry_sdk/integrations/bottle.py +25 -34
- sentry_sdk/integrations/celery/__init__.py +41 -61
- sentry_sdk/integrations/celery/beat.py +23 -27
- sentry_sdk/integrations/celery/utils.py +15 -17
- sentry_sdk/integrations/chalice.py +8 -10
- sentry_sdk/integrations/clickhouse_driver.py +21 -31
- sentry_sdk/integrations/cloud_resource_context.py +9 -16
- sentry_sdk/integrations/cohere.py +27 -33
- sentry_sdk/integrations/dedupe.py +5 -8
- sentry_sdk/integrations/django/__init__.py +57 -72
- sentry_sdk/integrations/django/asgi.py +26 -34
- sentry_sdk/integrations/django/caching.py +23 -19
- sentry_sdk/integrations/django/middleware.py +17 -20
- sentry_sdk/integrations/django/signals_handlers.py +11 -10
- sentry_sdk/integrations/django/templates.py +19 -16
- sentry_sdk/integrations/django/transactions.py +16 -11
- sentry_sdk/integrations/django/views.py +6 -10
- sentry_sdk/integrations/dramatiq.py +21 -21
- sentry_sdk/integrations/excepthook.py +10 -10
- sentry_sdk/integrations/executing.py +3 -4
- sentry_sdk/integrations/falcon.py +27 -42
- sentry_sdk/integrations/fastapi.py +13 -16
- sentry_sdk/integrations/flask.py +31 -38
- sentry_sdk/integrations/gcp.py +13 -16
- sentry_sdk/integrations/gnu_backtrace.py +4 -6
- sentry_sdk/integrations/gql.py +16 -17
- sentry_sdk/integrations/graphene.py +13 -12
- sentry_sdk/integrations/grpc/__init__.py +19 -1
- sentry_sdk/integrations/grpc/aio/server.py +15 -14
- sentry_sdk/integrations/grpc/client.py +19 -9
- sentry_sdk/integrations/grpc/consts.py +2 -0
- sentry_sdk/integrations/grpc/server.py +12 -8
- sentry_sdk/integrations/httpx.py +9 -12
- sentry_sdk/integrations/huey.py +13 -20
- sentry_sdk/integrations/huggingface_hub.py +18 -18
- sentry_sdk/integrations/langchain.py +203 -113
- sentry_sdk/integrations/launchdarkly.py +13 -10
- sentry_sdk/integrations/litestar.py +37 -35
- sentry_sdk/integrations/logging.py +52 -65
- sentry_sdk/integrations/loguru.py +127 -57
- sentry_sdk/integrations/modules.py +3 -4
- sentry_sdk/integrations/openai.py +100 -88
- sentry_sdk/integrations/openai_agents/__init__.py +49 -0
- sentry_sdk/integrations/openai_agents/consts.py +1 -0
- sentry_sdk/integrations/openai_agents/patches/__init__.py +4 -0
- sentry_sdk/integrations/openai_agents/patches/agent_run.py +152 -0
- sentry_sdk/integrations/openai_agents/patches/models.py +52 -0
- sentry_sdk/integrations/openai_agents/patches/runner.py +42 -0
- sentry_sdk/integrations/openai_agents/patches/tools.py +84 -0
- sentry_sdk/integrations/openai_agents/spans/__init__.py +5 -0
- sentry_sdk/integrations/openai_agents/spans/agent_workflow.py +20 -0
- sentry_sdk/integrations/openai_agents/spans/ai_client.py +46 -0
- sentry_sdk/integrations/openai_agents/spans/execute_tool.py +47 -0
- sentry_sdk/integrations/openai_agents/spans/handoff.py +24 -0
- sentry_sdk/integrations/openai_agents/spans/invoke_agent.py +41 -0
- sentry_sdk/integrations/openai_agents/utils.py +201 -0
- sentry_sdk/integrations/openfeature.py +11 -6
- sentry_sdk/integrations/pure_eval.py +6 -10
- sentry_sdk/integrations/pymongo.py +13 -17
- sentry_sdk/integrations/pyramid.py +31 -36
- sentry_sdk/integrations/quart.py +23 -28
- sentry_sdk/integrations/ray.py +73 -64
- sentry_sdk/integrations/redis/__init__.py +7 -4
- sentry_sdk/integrations/redis/_async_common.py +25 -12
- sentry_sdk/integrations/redis/_sync_common.py +19 -13
- sentry_sdk/integrations/redis/modules/caches.py +17 -8
- sentry_sdk/integrations/redis/modules/queries.py +9 -8
- sentry_sdk/integrations/redis/rb.py +3 -2
- sentry_sdk/integrations/redis/redis.py +4 -4
- sentry_sdk/integrations/redis/redis_cluster.py +21 -13
- sentry_sdk/integrations/redis/redis_py_cluster_legacy.py +3 -2
- sentry_sdk/integrations/redis/utils.py +23 -24
- sentry_sdk/integrations/rq.py +13 -16
- sentry_sdk/integrations/rust_tracing.py +9 -6
- sentry_sdk/integrations/sanic.py +34 -46
- sentry_sdk/integrations/serverless.py +22 -27
- sentry_sdk/integrations/socket.py +27 -15
- sentry_sdk/integrations/spark/__init__.py +1 -0
- sentry_sdk/integrations/spark/spark_driver.py +45 -83
- sentry_sdk/integrations/spark/spark_worker.py +7 -11
- sentry_sdk/integrations/sqlalchemy.py +22 -19
- sentry_sdk/integrations/starlette.py +86 -90
- sentry_sdk/integrations/starlite.py +28 -34
- sentry_sdk/integrations/statsig.py +5 -4
- sentry_sdk/integrations/stdlib.py +28 -24
- sentry_sdk/integrations/strawberry.py +62 -49
- sentry_sdk/integrations/sys_exit.py +7 -11
- sentry_sdk/integrations/threading.py +12 -14
- sentry_sdk/integrations/tornado.py +28 -32
- sentry_sdk/integrations/trytond.py +4 -3
- sentry_sdk/integrations/typer.py +8 -6
- sentry_sdk/integrations/unleash.py +5 -4
- sentry_sdk/integrations/wsgi.py +47 -46
- sentry_sdk/logger.py +41 -10
- sentry_sdk/monitor.py +16 -28
- sentry_sdk/opentelemetry/consts.py +11 -4
- sentry_sdk/opentelemetry/contextvars_context.py +26 -16
- sentry_sdk/opentelemetry/propagator.py +38 -21
- sentry_sdk/opentelemetry/sampler.py +51 -34
- sentry_sdk/opentelemetry/scope.py +36 -37
- sentry_sdk/opentelemetry/span_processor.py +48 -58
- sentry_sdk/opentelemetry/tracing.py +58 -14
- sentry_sdk/opentelemetry/utils.py +186 -194
- sentry_sdk/profiler/continuous_profiler.py +108 -97
- sentry_sdk/profiler/transaction_profiler.py +70 -97
- sentry_sdk/profiler/utils.py +11 -15
- sentry_sdk/scope.py +251 -273
- sentry_sdk/scrubber.py +22 -26
- sentry_sdk/serializer.py +40 -54
- sentry_sdk/session.py +44 -61
- sentry_sdk/sessions.py +35 -49
- sentry_sdk/spotlight.py +15 -21
- sentry_sdk/tracing.py +121 -187
- sentry_sdk/tracing_utils.py +104 -122
- sentry_sdk/transport.py +131 -157
- sentry_sdk/utils.py +232 -309
- sentry_sdk/worker.py +16 -28
- {sentry_sdk-3.0.0a1.dist-info → sentry_sdk-3.0.0a3.dist-info}/METADATA +3 -3
- sentry_sdk-3.0.0a3.dist-info/RECORD +168 -0
- {sentry_sdk-3.0.0a1.dist-info → sentry_sdk-3.0.0a3.dist-info}/WHEEL +1 -1
- sentry_sdk-3.0.0a1.dist-info/RECORD +0 -154
- {sentry_sdk-3.0.0a1.dist-info → sentry_sdk-3.0.0a3.dist-info}/entry_points.txt +0 -0
- {sentry_sdk-3.0.0a1.dist-info → sentry_sdk-3.0.0a3.dist-info}/licenses/LICENSE +0 -0
- {sentry_sdk-3.0.0a1.dist-info → sentry_sdk-3.0.0a3.dist-info}/top_level.txt +0 -0
sentry_sdk/integrations/httpx.py
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
1
2
|
import sentry_sdk
|
|
2
3
|
from sentry_sdk.consts import OP, SPANDATA, BAGGAGE_HEADER_NAME
|
|
3
4
|
from sentry_sdk.integrations import Integration, DidNotEnable
|
|
@@ -32,8 +33,7 @@ class HttpxIntegration(Integration):
|
|
|
32
33
|
origin = f"auto.http.{identifier}"
|
|
33
34
|
|
|
34
35
|
@staticmethod
|
|
35
|
-
def setup_once():
|
|
36
|
-
# type: () -> None
|
|
36
|
+
def setup_once() -> None:
|
|
37
37
|
"""
|
|
38
38
|
httpx has its own transport layer and can be customized when needed,
|
|
39
39
|
so patch Client.send and AsyncClient.send to support both synchronous and async interfaces.
|
|
@@ -42,13 +42,11 @@ class HttpxIntegration(Integration):
|
|
|
42
42
|
_install_httpx_async_client()
|
|
43
43
|
|
|
44
44
|
|
|
45
|
-
def _install_httpx_client():
|
|
46
|
-
# type: () -> None
|
|
45
|
+
def _install_httpx_client() -> None:
|
|
47
46
|
real_send = Client.send
|
|
48
47
|
|
|
49
48
|
@ensure_integration_enabled(HttpxIntegration, real_send)
|
|
50
|
-
def send(self, request, **kwargs):
|
|
51
|
-
# type: (Client, Request, **Any) -> Response
|
|
49
|
+
def send(self: Client, request: Request, **kwargs: Any) -> Response:
|
|
52
50
|
parsed_url = None
|
|
53
51
|
with capture_internal_exceptions():
|
|
54
52
|
parsed_url = parse_url(str(request.url), sanitize=False)
|
|
@@ -112,12 +110,10 @@ def _install_httpx_client():
|
|
|
112
110
|
Client.send = send
|
|
113
111
|
|
|
114
112
|
|
|
115
|
-
def _install_httpx_async_client():
|
|
116
|
-
# type: () -> None
|
|
113
|
+
def _install_httpx_async_client() -> None:
|
|
117
114
|
real_send = AsyncClient.send
|
|
118
115
|
|
|
119
|
-
async def send(self, request, **kwargs):
|
|
120
|
-
# type: (AsyncClient, Request, **Any) -> Response
|
|
116
|
+
async def send(self: AsyncClient, request: Request, **kwargs: Any) -> Response:
|
|
121
117
|
if sentry_sdk.get_client().get_integration(HttpxIntegration) is None:
|
|
122
118
|
return await real_send(self, request, **kwargs)
|
|
123
119
|
|
|
@@ -184,8 +180,9 @@ def _install_httpx_async_client():
|
|
|
184
180
|
AsyncClient.send = send
|
|
185
181
|
|
|
186
182
|
|
|
187
|
-
def _add_sentry_baggage_to_headers(
|
|
188
|
-
|
|
183
|
+
def _add_sentry_baggage_to_headers(
|
|
184
|
+
headers: MutableMapping[str, str], sentry_baggage: str
|
|
185
|
+
) -> None:
|
|
189
186
|
"""Add the Sentry baggage to the headers.
|
|
190
187
|
|
|
191
188
|
This function directly mutates the provided headers. The provided sentry_baggage
|
sentry_sdk/integrations/huey.py
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
1
2
|
import sys
|
|
2
3
|
from datetime import datetime
|
|
3
4
|
|
|
@@ -45,19 +46,16 @@ class HueyIntegration(Integration):
|
|
|
45
46
|
origin = f"auto.queue.{identifier}"
|
|
46
47
|
|
|
47
48
|
@staticmethod
|
|
48
|
-
def setup_once():
|
|
49
|
-
# type: () -> None
|
|
49
|
+
def setup_once() -> None:
|
|
50
50
|
patch_enqueue()
|
|
51
51
|
patch_execute()
|
|
52
52
|
|
|
53
53
|
|
|
54
|
-
def patch_enqueue():
|
|
55
|
-
# type: () -> None
|
|
54
|
+
def patch_enqueue() -> None:
|
|
56
55
|
old_enqueue = Huey.enqueue
|
|
57
56
|
|
|
58
57
|
@ensure_integration_enabled(HueyIntegration, old_enqueue)
|
|
59
|
-
def _sentry_enqueue(self, task):
|
|
60
|
-
# type: (Huey, Task) -> Optional[Union[Result, ResultGroup]]
|
|
58
|
+
def _sentry_enqueue(self: Huey, task: Task) -> Optional[Union[Result, ResultGroup]]:
|
|
61
59
|
with sentry_sdk.start_span(
|
|
62
60
|
op=OP.QUEUE_SUBMIT_HUEY,
|
|
63
61
|
name=task.name,
|
|
@@ -77,10 +75,8 @@ def patch_enqueue():
|
|
|
77
75
|
Huey.enqueue = _sentry_enqueue
|
|
78
76
|
|
|
79
77
|
|
|
80
|
-
def _make_event_processor(task):
|
|
81
|
-
|
|
82
|
-
def event_processor(event, hint):
|
|
83
|
-
# type: (Event, Hint) -> Optional[Event]
|
|
78
|
+
def _make_event_processor(task: Any) -> EventProcessor:
|
|
79
|
+
def event_processor(event: Event, hint: Hint) -> Optional[Event]:
|
|
84
80
|
|
|
85
81
|
with capture_internal_exceptions():
|
|
86
82
|
tags = event.setdefault("tags", {})
|
|
@@ -107,8 +103,7 @@ def _make_event_processor(task):
|
|
|
107
103
|
return event_processor
|
|
108
104
|
|
|
109
105
|
|
|
110
|
-
def _capture_exception(exc_info):
|
|
111
|
-
# type: (ExcInfo) -> None
|
|
106
|
+
def _capture_exception(exc_info: ExcInfo) -> None:
|
|
112
107
|
scope = sentry_sdk.get_current_scope()
|
|
113
108
|
|
|
114
109
|
if scope.root_span is not None:
|
|
@@ -126,12 +121,10 @@ def _capture_exception(exc_info):
|
|
|
126
121
|
scope.capture_event(event, hint=hint)
|
|
127
122
|
|
|
128
123
|
|
|
129
|
-
def _wrap_task_execute(func):
|
|
130
|
-
# type: (F) -> F
|
|
124
|
+
def _wrap_task_execute(func: F) -> F:
|
|
131
125
|
|
|
132
126
|
@ensure_integration_enabled(HueyIntegration, func)
|
|
133
|
-
def _sentry_execute(*args, **kwargs):
|
|
134
|
-
# type: (*Any, **Any) -> Any
|
|
127
|
+
def _sentry_execute(*args: Any, **kwargs: Any) -> Any:
|
|
135
128
|
try:
|
|
136
129
|
result = func(*args, **kwargs)
|
|
137
130
|
except Exception:
|
|
@@ -148,13 +141,13 @@ def _wrap_task_execute(func):
|
|
|
148
141
|
return _sentry_execute # type: ignore
|
|
149
142
|
|
|
150
143
|
|
|
151
|
-
def patch_execute():
|
|
152
|
-
# type: () -> None
|
|
144
|
+
def patch_execute() -> None:
|
|
153
145
|
old_execute = Huey._execute
|
|
154
146
|
|
|
155
147
|
@ensure_integration_enabled(HueyIntegration, old_execute)
|
|
156
|
-
def _sentry_execute(
|
|
157
|
-
|
|
148
|
+
def _sentry_execute(
|
|
149
|
+
self: Huey, task: Task, timestamp: Optional[datetime] = None
|
|
150
|
+
) -> Any:
|
|
158
151
|
with sentry_sdk.isolation_scope() as scope:
|
|
159
152
|
with capture_internal_exceptions():
|
|
160
153
|
scope._name = "huey"
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
1
2
|
from functools import wraps
|
|
2
3
|
|
|
3
4
|
from sentry_sdk import consts
|
|
@@ -27,13 +28,11 @@ class HuggingfaceHubIntegration(Integration):
|
|
|
27
28
|
identifier = "huggingface_hub"
|
|
28
29
|
origin = f"auto.ai.{identifier}"
|
|
29
30
|
|
|
30
|
-
def __init__(self, include_prompts=True):
|
|
31
|
-
# type: (HuggingfaceHubIntegration, bool) -> None
|
|
31
|
+
def __init__(self: HuggingfaceHubIntegration, include_prompts: bool = True) -> None:
|
|
32
32
|
self.include_prompts = include_prompts
|
|
33
33
|
|
|
34
34
|
@staticmethod
|
|
35
|
-
def setup_once():
|
|
36
|
-
# type: () -> None
|
|
35
|
+
def setup_once() -> None:
|
|
37
36
|
huggingface_hub.inference._client.InferenceClient.text_generation = (
|
|
38
37
|
_wrap_text_generation(
|
|
39
38
|
huggingface_hub.inference._client.InferenceClient.text_generation
|
|
@@ -41,8 +40,7 @@ class HuggingfaceHubIntegration(Integration):
|
|
|
41
40
|
)
|
|
42
41
|
|
|
43
42
|
|
|
44
|
-
def _capture_exception(exc):
|
|
45
|
-
# type: (Any) -> None
|
|
43
|
+
def _capture_exception(exc: Any) -> None:
|
|
46
44
|
event, hint = event_from_exception(
|
|
47
45
|
exc,
|
|
48
46
|
client_options=sentry_sdk.get_client().options,
|
|
@@ -51,11 +49,9 @@ def _capture_exception(exc):
|
|
|
51
49
|
sentry_sdk.capture_event(event, hint=hint)
|
|
52
50
|
|
|
53
51
|
|
|
54
|
-
def _wrap_text_generation(f):
|
|
55
|
-
# type: (Callable[..., Any]) -> Callable[..., Any]
|
|
52
|
+
def _wrap_text_generation(f: Callable[..., Any]) -> Callable[..., Any]:
|
|
56
53
|
@wraps(f)
|
|
57
|
-
def new_text_generation(*args, **kwargs):
|
|
58
|
-
# type: (*Any, **Any) -> Any
|
|
54
|
+
def new_text_generation(*args: Any, **kwargs: Any) -> Any:
|
|
59
55
|
integration = sentry_sdk.get_client().get_integration(HuggingfaceHubIntegration)
|
|
60
56
|
if integration is None:
|
|
61
57
|
return f(*args, **kwargs)
|
|
@@ -98,7 +94,7 @@ def _wrap_text_generation(f):
|
|
|
98
94
|
if should_send_default_pii() and integration.include_prompts:
|
|
99
95
|
set_data_normalized(
|
|
100
96
|
span,
|
|
101
|
-
|
|
97
|
+
SPANDATA.AI_RESPONSES,
|
|
102
98
|
[res],
|
|
103
99
|
)
|
|
104
100
|
span.__exit__(None, None, None)
|
|
@@ -108,11 +104,14 @@ def _wrap_text_generation(f):
|
|
|
108
104
|
if should_send_default_pii() and integration.include_prompts:
|
|
109
105
|
set_data_normalized(
|
|
110
106
|
span,
|
|
111
|
-
|
|
107
|
+
SPANDATA.AI_RESPONSES,
|
|
112
108
|
[res.generated_text],
|
|
113
109
|
)
|
|
114
110
|
if res.details is not None and res.details.generated_tokens > 0:
|
|
115
|
-
record_token_usage(
|
|
111
|
+
record_token_usage(
|
|
112
|
+
span,
|
|
113
|
+
total_tokens=res.details.generated_tokens,
|
|
114
|
+
)
|
|
116
115
|
span.__exit__(None, None, None)
|
|
117
116
|
return res
|
|
118
117
|
|
|
@@ -124,8 +123,7 @@ def _wrap_text_generation(f):
|
|
|
124
123
|
|
|
125
124
|
if kwargs.get("details", False):
|
|
126
125
|
# res is Iterable[TextGenerationStreamOutput]
|
|
127
|
-
def new_details_iterator():
|
|
128
|
-
# type: () -> Iterable[ChatCompletionStreamOutput]
|
|
126
|
+
def new_details_iterator() -> Iterable[ChatCompletionStreamOutput]:
|
|
129
127
|
with capture_internal_exceptions():
|
|
130
128
|
tokens_used = 0
|
|
131
129
|
data_buf: list[str] = []
|
|
@@ -146,15 +144,17 @@ def _wrap_text_generation(f):
|
|
|
146
144
|
span, SPANDATA.AI_RESPONSES, "".join(data_buf)
|
|
147
145
|
)
|
|
148
146
|
if tokens_used > 0:
|
|
149
|
-
record_token_usage(
|
|
147
|
+
record_token_usage(
|
|
148
|
+
span,
|
|
149
|
+
total_tokens=tokens_used,
|
|
150
|
+
)
|
|
150
151
|
span.__exit__(None, None, None)
|
|
151
152
|
|
|
152
153
|
return new_details_iterator()
|
|
153
154
|
else:
|
|
154
155
|
# res is Iterable[str]
|
|
155
156
|
|
|
156
|
-
def new_iterator():
|
|
157
|
-
# type: () -> Iterable[str]
|
|
157
|
+
def new_iterator() -> Iterable[str]:
|
|
158
158
|
data_buf: list[str] = []
|
|
159
159
|
with capture_internal_exceptions():
|
|
160
160
|
for s in res:
|