sentry-sdk 3.0.0a2__py2.py3-none-any.whl → 3.0.0a4__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 +4 -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 +9 -16
- sentry_sdk/_werkzeug.py +5 -7
- sentry_sdk/ai/monitoring.py +45 -33
- sentry_sdk/ai/utils.py +8 -5
- sentry_sdk/api.py +91 -87
- sentry_sdk/attachments.py +10 -12
- sentry_sdk/client.py +119 -159
- sentry_sdk/consts.py +432 -223
- 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 +16 -18
- sentry_sdk/integrations/_wsgi_common.py +22 -33
- sentry_sdk/integrations/aiohttp.py +33 -31
- sentry_sdk/integrations/anthropic.py +43 -38
- sentry_sdk/integrations/argv.py +3 -4
- sentry_sdk/integrations/ariadne.py +16 -18
- sentry_sdk/integrations/arq.py +20 -29
- sentry_sdk/integrations/asgi.py +63 -37
- sentry_sdk/integrations/asyncio.py +15 -17
- sentry_sdk/integrations/asyncpg.py +1 -1
- 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 +20 -18
- sentry_sdk/integrations/bottle.py +25 -34
- sentry_sdk/integrations/celery/__init__.py +40 -59
- sentry_sdk/integrations/celery/beat.py +22 -26
- sentry_sdk/integrations/celery/utils.py +15 -17
- sentry_sdk/integrations/chalice.py +8 -10
- sentry_sdk/integrations/clickhouse_driver.py +22 -32
- sentry_sdk/integrations/cloud_resource_context.py +9 -16
- sentry_sdk/integrations/cohere.py +19 -25
- sentry_sdk/integrations/dedupe.py +5 -8
- sentry_sdk/integrations/django/__init__.py +69 -74
- sentry_sdk/integrations/django/asgi.py +25 -33
- sentry_sdk/integrations/django/caching.py +24 -20
- sentry_sdk/integrations/django/middleware.py +18 -21
- sentry_sdk/integrations/django/signals_handlers.py +12 -11
- sentry_sdk/integrations/django/templates.py +21 -18
- sentry_sdk/integrations/django/transactions.py +16 -11
- sentry_sdk/integrations/django/views.py +8 -12
- 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 +7 -20
- sentry_sdk/integrations/gql.py +16 -17
- sentry_sdk/integrations/graphene.py +14 -13
- sentry_sdk/integrations/grpc/__init__.py +3 -2
- sentry_sdk/integrations/grpc/aio/client.py +2 -2
- sentry_sdk/integrations/grpc/aio/server.py +15 -14
- sentry_sdk/integrations/grpc/client.py +21 -11
- sentry_sdk/integrations/grpc/consts.py +2 -0
- sentry_sdk/integrations/grpc/server.py +12 -8
- sentry_sdk/integrations/httpx.py +11 -14
- sentry_sdk/integrations/huey.py +14 -21
- sentry_sdk/integrations/huggingface_hub.py +17 -17
- sentry_sdk/integrations/langchain.py +204 -114
- sentry_sdk/integrations/launchdarkly.py +13 -10
- sentry_sdk/integrations/litestar.py +40 -38
- sentry_sdk/integrations/logging.py +29 -36
- sentry_sdk/integrations/loguru.py +16 -20
- sentry_sdk/integrations/modules.py +3 -4
- sentry_sdk/integrations/openai.py +421 -204
- 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 +153 -0
- sentry_sdk/integrations/openfeature.py +12 -8
- sentry_sdk/integrations/pure_eval.py +6 -10
- sentry_sdk/integrations/pymongo.py +14 -18
- 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 +18 -12
- sentry_sdk/integrations/redis/_sync_common.py +16 -15
- 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 +10 -8
- sentry_sdk/integrations/redis/redis_py_cluster_legacy.py +3 -2
- sentry_sdk/integrations/redis/utils.py +21 -22
- sentry_sdk/integrations/rq.py +13 -16
- sentry_sdk/integrations/rust_tracing.py +10 -7
- sentry_sdk/integrations/sanic.py +34 -46
- sentry_sdk/integrations/serverless.py +22 -27
- sentry_sdk/integrations/socket.py +29 -17
- 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 +89 -93
- sentry_sdk/integrations/starlite.py +31 -37
- sentry_sdk/integrations/statsig.py +5 -4
- sentry_sdk/integrations/stdlib.py +32 -28
- sentry_sdk/integrations/strawberry.py +63 -50
- sentry_sdk/integrations/sys_exit.py +7 -11
- sentry_sdk/integrations/threading.py +13 -15
- 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 +13 -9
- sentry_sdk/monitor.py +16 -28
- sentry_sdk/opentelemetry/consts.py +11 -4
- sentry_sdk/opentelemetry/contextvars_context.py +17 -15
- sentry_sdk/opentelemetry/propagator.py +38 -21
- sentry_sdk/opentelemetry/sampler.py +51 -34
- sentry_sdk/opentelemetry/scope.py +46 -37
- sentry_sdk/opentelemetry/span_processor.py +43 -59
- sentry_sdk/opentelemetry/tracing.py +32 -12
- sentry_sdk/opentelemetry/utils.py +180 -196
- 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 -264
- sentry_sdk/scrubber.py +22 -26
- sentry_sdk/serializer.py +48 -65
- sentry_sdk/session.py +44 -61
- sentry_sdk/sessions.py +35 -49
- sentry_sdk/spotlight.py +15 -21
- sentry_sdk/tracing.py +118 -184
- sentry_sdk/tracing_utils.py +103 -123
- sentry_sdk/transport.py +131 -157
- sentry_sdk/utils.py +278 -309
- sentry_sdk/worker.py +16 -28
- {sentry_sdk-3.0.0a2.dist-info → sentry_sdk-3.0.0a4.dist-info}/METADATA +1 -1
- sentry_sdk-3.0.0a4.dist-info/RECORD +168 -0
- sentry_sdk-3.0.0a2.dist-info/RECORD +0 -154
- {sentry_sdk-3.0.0a2.dist-info → sentry_sdk-3.0.0a4.dist-info}/WHEEL +0 -0
- {sentry_sdk-3.0.0a2.dist-info → sentry_sdk-3.0.0a4.dist-info}/entry_points.txt +0 -0
- {sentry_sdk-3.0.0a2.dist-info → sentry_sdk-3.0.0a4.dist-info}/licenses/LICENSE +0 -0
- {sentry_sdk-3.0.0a2.dist-info → sentry_sdk-3.0.0a4.dist-info}/top_level.txt +0 -0
sentry_sdk/api.py
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
1
2
|
import inspect
|
|
2
3
|
from contextlib import contextmanager
|
|
3
4
|
|
|
@@ -20,21 +21,23 @@ from sentry_sdk.opentelemetry.scope import (
|
|
|
20
21
|
from typing import TYPE_CHECKING
|
|
21
22
|
|
|
22
23
|
if TYPE_CHECKING:
|
|
23
|
-
from
|
|
24
|
-
|
|
25
|
-
from typing import Any
|
|
26
|
-
from typing import Dict
|
|
27
|
-
from typing import Optional
|
|
28
|
-
from typing import Callable
|
|
29
|
-
from typing import TypeVar
|
|
30
|
-
from typing import Union
|
|
31
|
-
from typing import Generator
|
|
32
|
-
|
|
33
|
-
import sentry_sdk
|
|
24
|
+
from typing import Any, Optional, Callable, TypeVar, Union, Generator
|
|
34
25
|
|
|
35
26
|
T = TypeVar("T")
|
|
36
27
|
F = TypeVar("F", bound=Callable[..., Any])
|
|
37
28
|
|
|
29
|
+
from collections.abc import Mapping
|
|
30
|
+
from sentry_sdk.client import BaseClient
|
|
31
|
+
from sentry_sdk.tracing import Span
|
|
32
|
+
from sentry_sdk._types import (
|
|
33
|
+
Event,
|
|
34
|
+
Hint,
|
|
35
|
+
LogLevelStr,
|
|
36
|
+
ExcInfo,
|
|
37
|
+
BreadcrumbHint,
|
|
38
|
+
Breadcrumb,
|
|
39
|
+
)
|
|
40
|
+
|
|
38
41
|
|
|
39
42
|
# When changing this, update __all__ in __init__.py too
|
|
40
43
|
__all__ = [
|
|
@@ -45,6 +48,7 @@ __all__ = [
|
|
|
45
48
|
"capture_exception",
|
|
46
49
|
"capture_message",
|
|
47
50
|
"continue_trace",
|
|
51
|
+
"new_trace",
|
|
48
52
|
"flush",
|
|
49
53
|
"get_baggage",
|
|
50
54
|
"get_client",
|
|
@@ -69,11 +73,13 @@ __all__ = [
|
|
|
69
73
|
"monitor",
|
|
70
74
|
"use_scope",
|
|
71
75
|
"use_isolation_scope",
|
|
76
|
+
"start_session",
|
|
77
|
+
"end_session",
|
|
78
|
+
"set_transaction_name",
|
|
72
79
|
]
|
|
73
80
|
|
|
74
81
|
|
|
75
|
-
def scopemethod(f):
|
|
76
|
-
# type: (F) -> F
|
|
82
|
+
def scopemethod(f: F) -> F:
|
|
77
83
|
f.__doc__ = "%s\n\n%s" % (
|
|
78
84
|
"Alias for :py:meth:`sentry_sdk.Scope.%s`" % f.__name__,
|
|
79
85
|
inspect.getdoc(getattr(Scope, f.__name__)),
|
|
@@ -81,8 +87,7 @@ def scopemethod(f):
|
|
|
81
87
|
return f
|
|
82
88
|
|
|
83
89
|
|
|
84
|
-
def clientmethod(f):
|
|
85
|
-
# type: (F) -> F
|
|
90
|
+
def clientmethod(f: F) -> F:
|
|
86
91
|
f.__doc__ = "%s\n\n%s" % (
|
|
87
92
|
"Alias for :py:meth:`sentry_sdk.Client.%s`" % f.__name__,
|
|
88
93
|
inspect.getdoc(getattr(Client, f.__name__)),
|
|
@@ -91,13 +96,11 @@ def clientmethod(f):
|
|
|
91
96
|
|
|
92
97
|
|
|
93
98
|
@scopemethod
|
|
94
|
-
def get_client():
|
|
95
|
-
# type: () -> sentry_sdk.client.BaseClient
|
|
99
|
+
def get_client() -> BaseClient:
|
|
96
100
|
return Scope.get_client()
|
|
97
101
|
|
|
98
102
|
|
|
99
|
-
def is_initialized():
|
|
100
|
-
# type: () -> bool
|
|
103
|
+
def is_initialized() -> bool:
|
|
101
104
|
"""
|
|
102
105
|
.. versionadded:: 2.0.0
|
|
103
106
|
|
|
@@ -111,26 +114,22 @@ def is_initialized():
|
|
|
111
114
|
|
|
112
115
|
|
|
113
116
|
@scopemethod
|
|
114
|
-
def get_global_scope():
|
|
115
|
-
# type: () -> BaseScope
|
|
117
|
+
def get_global_scope() -> BaseScope:
|
|
116
118
|
return Scope.get_global_scope()
|
|
117
119
|
|
|
118
120
|
|
|
119
121
|
@scopemethod
|
|
120
|
-
def get_isolation_scope():
|
|
121
|
-
# type: () -> Scope
|
|
122
|
+
def get_isolation_scope() -> Scope:
|
|
122
123
|
return Scope.get_isolation_scope()
|
|
123
124
|
|
|
124
125
|
|
|
125
126
|
@scopemethod
|
|
126
|
-
def get_current_scope():
|
|
127
|
-
# type: () -> Scope
|
|
127
|
+
def get_current_scope() -> Scope:
|
|
128
128
|
return Scope.get_current_scope()
|
|
129
129
|
|
|
130
130
|
|
|
131
131
|
@scopemethod
|
|
132
|
-
def last_event_id():
|
|
133
|
-
# type: () -> Optional[str]
|
|
132
|
+
def last_event_id() -> Optional[str]:
|
|
134
133
|
"""
|
|
135
134
|
See :py:meth:`sentry_sdk.Scope.last_event_id` documentation regarding
|
|
136
135
|
this method's limitations.
|
|
@@ -140,23 +139,21 @@ def last_event_id():
|
|
|
140
139
|
|
|
141
140
|
@scopemethod
|
|
142
141
|
def capture_event(
|
|
143
|
-
event
|
|
144
|
-
hint
|
|
145
|
-
scope
|
|
146
|
-
**scope_kwargs
|
|
147
|
-
):
|
|
148
|
-
# type: (...) -> Optional[str]
|
|
142
|
+
event: Event,
|
|
143
|
+
hint: Optional[Hint] = None,
|
|
144
|
+
scope: Optional[Any] = None,
|
|
145
|
+
**scope_kwargs: Any,
|
|
146
|
+
) -> Optional[str]:
|
|
149
147
|
return get_current_scope().capture_event(event, hint, scope=scope, **scope_kwargs)
|
|
150
148
|
|
|
151
149
|
|
|
152
150
|
@scopemethod
|
|
153
151
|
def capture_message(
|
|
154
|
-
message
|
|
155
|
-
level
|
|
156
|
-
scope
|
|
157
|
-
**scope_kwargs
|
|
158
|
-
):
|
|
159
|
-
# type: (...) -> Optional[str]
|
|
152
|
+
message: str,
|
|
153
|
+
level: Optional[LogLevelStr] = None,
|
|
154
|
+
scope: Optional[Any] = None,
|
|
155
|
+
**scope_kwargs: Any,
|
|
156
|
+
) -> Optional[str]:
|
|
160
157
|
return get_current_scope().capture_message(
|
|
161
158
|
message, level, scope=scope, **scope_kwargs
|
|
162
159
|
)
|
|
@@ -164,23 +161,21 @@ def capture_message(
|
|
|
164
161
|
|
|
165
162
|
@scopemethod
|
|
166
163
|
def capture_exception(
|
|
167
|
-
error
|
|
168
|
-
scope
|
|
169
|
-
**scope_kwargs
|
|
170
|
-
):
|
|
171
|
-
# type: (...) -> Optional[str]
|
|
164
|
+
error: Optional[Union[BaseException, ExcInfo]] = None,
|
|
165
|
+
scope: Optional[Any] = None,
|
|
166
|
+
**scope_kwargs: Any,
|
|
167
|
+
) -> Optional[str]:
|
|
172
168
|
return get_current_scope().capture_exception(error, scope=scope, **scope_kwargs)
|
|
173
169
|
|
|
174
170
|
|
|
175
171
|
@scopemethod
|
|
176
172
|
def add_attachment(
|
|
177
|
-
bytes
|
|
178
|
-
filename
|
|
179
|
-
path
|
|
180
|
-
content_type
|
|
181
|
-
add_to_transactions=False,
|
|
182
|
-
):
|
|
183
|
-
# type: (...) -> None
|
|
173
|
+
bytes: Union[None, bytes, Callable[[], bytes]] = None,
|
|
174
|
+
filename: Optional[str] = None,
|
|
175
|
+
path: Optional[str] = None,
|
|
176
|
+
content_type: Optional[str] = None,
|
|
177
|
+
add_to_transactions: bool = False,
|
|
178
|
+
) -> None:
|
|
184
179
|
return get_isolation_scope().add_attachment(
|
|
185
180
|
bytes, filename, path, content_type, add_to_transactions
|
|
186
181
|
)
|
|
@@ -188,61 +183,52 @@ def add_attachment(
|
|
|
188
183
|
|
|
189
184
|
@scopemethod
|
|
190
185
|
def add_breadcrumb(
|
|
191
|
-
crumb
|
|
192
|
-
hint
|
|
193
|
-
**kwargs
|
|
194
|
-
):
|
|
195
|
-
# type: (...) -> None
|
|
186
|
+
crumb: Optional[Breadcrumb] = None,
|
|
187
|
+
hint: Optional[BreadcrumbHint] = None,
|
|
188
|
+
**kwargs: Any,
|
|
189
|
+
) -> None:
|
|
196
190
|
return get_isolation_scope().add_breadcrumb(crumb, hint, **kwargs)
|
|
197
191
|
|
|
198
192
|
|
|
199
193
|
@scopemethod
|
|
200
|
-
def set_tag(key, value):
|
|
201
|
-
# type: (str, Any) -> None
|
|
194
|
+
def set_tag(key: str, value: Any) -> None:
|
|
202
195
|
return get_isolation_scope().set_tag(key, value)
|
|
203
196
|
|
|
204
197
|
|
|
205
198
|
@scopemethod
|
|
206
|
-
def set_tags(tags):
|
|
207
|
-
# type: (Mapping[str, object]) -> None
|
|
199
|
+
def set_tags(tags: Mapping[str, object]) -> None:
|
|
208
200
|
return get_isolation_scope().set_tags(tags)
|
|
209
201
|
|
|
210
202
|
|
|
211
203
|
@scopemethod
|
|
212
|
-
def set_context(key, value):
|
|
213
|
-
# type: (str, Dict[str, Any]) -> None
|
|
204
|
+
def set_context(key: str, value: dict[str, Any]) -> None:
|
|
214
205
|
return get_isolation_scope().set_context(key, value)
|
|
215
206
|
|
|
216
207
|
|
|
217
208
|
@scopemethod
|
|
218
|
-
def set_extra(key, value):
|
|
219
|
-
# type: (str, Any) -> None
|
|
209
|
+
def set_extra(key: str, value: Any) -> None:
|
|
220
210
|
return get_isolation_scope().set_extra(key, value)
|
|
221
211
|
|
|
222
212
|
|
|
223
213
|
@scopemethod
|
|
224
|
-
def set_user(value):
|
|
225
|
-
# type: (Optional[Dict[str, Any]]) -> None
|
|
214
|
+
def set_user(value: Optional[dict[str, Any]]) -> None:
|
|
226
215
|
return get_isolation_scope().set_user(value)
|
|
227
216
|
|
|
228
217
|
|
|
229
218
|
@scopemethod
|
|
230
|
-
def set_level(value):
|
|
231
|
-
# type: (sentry_sdk._types.LogLevelStr) -> None
|
|
219
|
+
def set_level(value: LogLevelStr) -> None:
|
|
232
220
|
return get_isolation_scope().set_level(value)
|
|
233
221
|
|
|
234
222
|
|
|
235
223
|
@clientmethod
|
|
236
224
|
def flush(
|
|
237
|
-
timeout
|
|
238
|
-
callback
|
|
239
|
-
):
|
|
240
|
-
# type: (...) -> None
|
|
225
|
+
timeout: Optional[float] = None,
|
|
226
|
+
callback: Optional[Callable[[int, float], None]] = None,
|
|
227
|
+
) -> None:
|
|
241
228
|
return get_client().flush(timeout=timeout, callback=callback)
|
|
242
229
|
|
|
243
230
|
|
|
244
|
-
def start_span(**kwargs):
|
|
245
|
-
# type: (Any) -> sentry_sdk.tracing.Span
|
|
231
|
+
def start_span(**kwargs: Any) -> Span:
|
|
246
232
|
"""
|
|
247
233
|
Start and return a span.
|
|
248
234
|
|
|
@@ -258,11 +244,7 @@ def start_span(**kwargs):
|
|
|
258
244
|
return get_current_scope().start_span(**kwargs)
|
|
259
245
|
|
|
260
246
|
|
|
261
|
-
def start_transaction(
|
|
262
|
-
transaction=None, # type: Optional[sentry_sdk.tracing.Span]
|
|
263
|
-
**kwargs, # type: Any
|
|
264
|
-
):
|
|
265
|
-
# type: (...) -> sentry_sdk.tracing.Span
|
|
247
|
+
def start_transaction(transaction: Optional[Span] = None, **kwargs: Any) -> Span:
|
|
266
248
|
"""
|
|
267
249
|
.. deprecated:: 3.0.0
|
|
268
250
|
This function is deprecated and will be removed in a future release.
|
|
@@ -301,24 +283,21 @@ def start_transaction(
|
|
|
301
283
|
)
|
|
302
284
|
|
|
303
285
|
|
|
304
|
-
def get_current_span(scope=None):
|
|
305
|
-
# type: (Optional[Scope]) -> Optional[sentry_sdk.tracing.Span]
|
|
286
|
+
def get_current_span(scope: Optional[Scope] = None) -> Optional[Span]:
|
|
306
287
|
"""
|
|
307
288
|
Returns the currently active span if there is one running, otherwise `None`
|
|
308
289
|
"""
|
|
309
290
|
return tracing_utils.get_current_span(scope)
|
|
310
291
|
|
|
311
292
|
|
|
312
|
-
def get_traceparent():
|
|
313
|
-
# type: () -> Optional[str]
|
|
293
|
+
def get_traceparent() -> Optional[str]:
|
|
314
294
|
"""
|
|
315
295
|
Returns the traceparent either from the active span or from the scope.
|
|
316
296
|
"""
|
|
317
297
|
return get_current_scope().get_traceparent()
|
|
318
298
|
|
|
319
299
|
|
|
320
|
-
def get_baggage():
|
|
321
|
-
# type: () -> Optional[str]
|
|
300
|
+
def get_baggage() -> Optional[str]:
|
|
322
301
|
"""
|
|
323
302
|
Returns Baggage either from the active span or from the scope.
|
|
324
303
|
"""
|
|
@@ -330,10 +309,35 @@ def get_baggage():
|
|
|
330
309
|
|
|
331
310
|
|
|
332
311
|
@contextmanager
|
|
333
|
-
def continue_trace(environ_or_headers):
|
|
334
|
-
# type: (Dict[str, Any]) -> Generator[None, None, None]
|
|
312
|
+
def continue_trace(environ_or_headers: dict[str, Any]) -> Generator[None, None, None]:
|
|
335
313
|
"""
|
|
336
314
|
Sets the propagation context from environment or headers to continue an incoming trace.
|
|
337
315
|
"""
|
|
338
316
|
with get_isolation_scope().continue_trace(environ_or_headers):
|
|
339
317
|
yield
|
|
318
|
+
|
|
319
|
+
|
|
320
|
+
@contextmanager
|
|
321
|
+
def new_trace() -> Generator[None, None, None]:
|
|
322
|
+
"""
|
|
323
|
+
Force creation of a new trace.
|
|
324
|
+
"""
|
|
325
|
+
with get_isolation_scope().new_trace():
|
|
326
|
+
yield
|
|
327
|
+
|
|
328
|
+
|
|
329
|
+
@scopemethod
|
|
330
|
+
def start_session(
|
|
331
|
+
session_mode: str = "application",
|
|
332
|
+
) -> None:
|
|
333
|
+
return get_isolation_scope().start_session(session_mode=session_mode)
|
|
334
|
+
|
|
335
|
+
|
|
336
|
+
@scopemethod
|
|
337
|
+
def end_session() -> None:
|
|
338
|
+
return get_isolation_scope().end_session()
|
|
339
|
+
|
|
340
|
+
|
|
341
|
+
@scopemethod
|
|
342
|
+
def set_transaction_name(name: str, source: Optional[str] = None) -> None:
|
|
343
|
+
return get_current_scope().set_transaction_name(name, source)
|
sentry_sdk/attachments.py
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
1
2
|
import os
|
|
2
3
|
import mimetypes
|
|
3
4
|
|
|
@@ -31,13 +32,12 @@ class Attachment:
|
|
|
31
32
|
|
|
32
33
|
def __init__(
|
|
33
34
|
self,
|
|
34
|
-
bytes
|
|
35
|
-
filename
|
|
36
|
-
path
|
|
37
|
-
content_type
|
|
38
|
-
add_to_transactions=False,
|
|
39
|
-
):
|
|
40
|
-
# type: (...) -> None
|
|
35
|
+
bytes: Union[None, bytes, Callable[[], bytes]] = None,
|
|
36
|
+
filename: Optional[str] = None,
|
|
37
|
+
path: Optional[str] = None,
|
|
38
|
+
content_type: Optional[str] = None,
|
|
39
|
+
add_to_transactions: bool = False,
|
|
40
|
+
) -> None:
|
|
41
41
|
if bytes is None and path is None:
|
|
42
42
|
raise TypeError("path or raw bytes required for attachment")
|
|
43
43
|
if filename is None and path is not None:
|
|
@@ -52,10 +52,9 @@ class Attachment:
|
|
|
52
52
|
self.content_type = content_type
|
|
53
53
|
self.add_to_transactions = add_to_transactions
|
|
54
54
|
|
|
55
|
-
def to_envelope_item(self):
|
|
56
|
-
# type: () -> Item
|
|
55
|
+
def to_envelope_item(self) -> Item:
|
|
57
56
|
"""Returns an envelope item for this attachment."""
|
|
58
|
-
payload
|
|
57
|
+
payload: Union[None, PayloadRef, bytes] = None
|
|
59
58
|
if self.bytes is not None:
|
|
60
59
|
if callable(self.bytes):
|
|
61
60
|
payload = self.bytes()
|
|
@@ -70,6 +69,5 @@ class Attachment:
|
|
|
70
69
|
filename=self.filename,
|
|
71
70
|
)
|
|
72
71
|
|
|
73
|
-
def __repr__(self):
|
|
74
|
-
# type: () -> str
|
|
72
|
+
def __repr__(self) -> str:
|
|
75
73
|
return "<Attachment %r>" % (self.filename,)
|