sentry-sdk 2.35.0__py2.py3-none-any.whl → 2.35.2__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/client.py CHANGED
@@ -516,8 +516,9 @@ class _Client(BaseClient):
516
516
  if event.get("timestamp") is None:
517
517
  event["timestamp"] = datetime.now(timezone.utc)
518
518
 
519
+ is_transaction = event.get("type") == "transaction"
520
+
519
521
  if scope is not None:
520
- is_transaction = event.get("type") == "transaction"
521
522
  spans_before = len(cast(List[Dict[str, object]], event.get("spans", [])))
522
523
  event_ = scope.apply_to_event(event, hint, self.options)
523
524
 
@@ -560,7 +561,8 @@ class _Client(BaseClient):
560
561
  )
561
562
 
562
563
  if (
563
- self.options["attach_stacktrace"]
564
+ not is_transaction
565
+ and self.options["attach_stacktrace"]
564
566
  and "exception" not in event
565
567
  and "stacktrace" not in event
566
568
  and "threads" not in event
sentry_sdk/consts.py CHANGED
@@ -1329,4 +1329,4 @@ DEFAULT_OPTIONS = _get_default_options()
1329
1329
  del _get_default_options
1330
1330
 
1331
1331
 
1332
- VERSION = "2.35.0"
1332
+ VERSION = "2.35.2"
@@ -356,12 +356,14 @@ class SentryLogsHandler(_BaseHandler):
356
356
  record.levelno, SEVERITY_TO_OTEL_SEVERITY
357
357
  )
358
358
  project_root = client.options["project_root"]
359
+
359
360
  attrs = self._extra_from_record(record) # type: Any
360
361
  attrs["sentry.origin"] = "auto.logger.log"
361
- if isinstance(record.msg, str):
362
- attrs["sentry.message.template"] = record.msg
362
+
363
+ parameters_set = False
363
364
  if record.args is not None:
364
365
  if isinstance(record.args, tuple):
366
+ parameters_set = bool(record.args)
365
367
  for i, arg in enumerate(record.args):
366
368
  attrs[f"sentry.message.parameter.{i}"] = (
367
369
  arg
@@ -369,19 +371,28 @@ class SentryLogsHandler(_BaseHandler):
369
371
  else safe_repr(arg)
370
372
  )
371
373
  elif isinstance(record.args, dict):
374
+ parameters_set = bool(record.args)
372
375
  for key, value in record.args.items():
373
376
  attrs[f"sentry.message.parameter.{key}"] = (
374
377
  value
375
378
  if isinstance(value, (str, float, int, bool))
376
379
  else safe_repr(value)
377
380
  )
381
+
382
+ if parameters_set and isinstance(record.msg, str):
383
+ # only include template if there is at least one
384
+ # sentry.message.parameter.X set
385
+ attrs["sentry.message.template"] = record.msg
386
+
378
387
  if record.lineno:
379
388
  attrs["code.line.number"] = record.lineno
389
+
380
390
  if record.pathname:
381
391
  if project_root is not None and record.pathname.startswith(project_root):
382
392
  attrs["code.file.path"] = record.pathname[len(project_root) + 1 :]
383
393
  else:
384
394
  attrs["code.file.path"] = record.pathname
395
+
385
396
  if record.funcName:
386
397
  attrs["code.function.name"] = record.funcName
387
398
 
@@ -1,7 +1,6 @@
1
1
  from functools import wraps
2
2
 
3
3
  from sentry_sdk.integrations import DidNotEnable
4
-
5
4
  from ..spans import invoke_agent_span, update_invoke_agent_span, handoff_span
6
5
 
7
6
  from typing import TYPE_CHECKING
@@ -9,7 +8,6 @@ from typing import TYPE_CHECKING
9
8
  if TYPE_CHECKING:
10
9
  from typing import Any, Optional
11
10
 
12
-
13
11
  try:
14
12
  import agents
15
13
  except ImportError:
@@ -62,7 +60,6 @@ def _patch_agent_run():
62
60
  async def patched_run_single_turn(cls, *args, **kwargs):
63
61
  # type: (agents.Runner, *Any, **Any) -> Any
64
62
  """Patched _run_single_turn that creates agent invocation spans"""
65
-
66
63
  agent = kwargs.get("agent")
67
64
  context_wrapper = kwargs.get("context_wrapper")
68
65
  should_run_agent_start_hooks = kwargs.get("should_run_agent_start_hooks")
@@ -23,20 +23,23 @@ def _create_run_wrapper(original_func):
23
23
  @wraps(original_func)
24
24
  async def wrapper(*args, **kwargs):
25
25
  # type: (*Any, **Any) -> Any
26
- agent = args[0]
27
- with agent_workflow_span(agent):
28
- result = None
29
- try:
30
- result = await original_func(*args, **kwargs)
31
- return result
32
- except Exception as exc:
33
- _capture_exception(exc)
34
-
35
- # It could be that there is a "invoke agent" span still open
36
- current_span = sentry_sdk.get_current_span()
37
- if current_span is not None and current_span.timestamp is None:
38
- current_span.__exit__(None, None, None)
39
-
40
- raise exc from None
26
+ # Isolate each workflow so that when agents are run in asyncio tasks they
27
+ # don't touch each other's scopes
28
+ with sentry_sdk.isolation_scope():
29
+ agent = args[0]
30
+ with agent_workflow_span(agent):
31
+ result = None
32
+ try:
33
+ result = await original_func(*args, **kwargs)
34
+ return result
35
+ except Exception as exc:
36
+ _capture_exception(exc)
37
+
38
+ # It could be that there is a "invoke agent" span still open
39
+ current_span = sentry_sdk.get_current_span()
40
+ if current_span is not None and current_span.timestamp is None:
41
+ current_span.__exit__(None, None, None)
42
+
43
+ raise exc from None
41
44
 
42
45
  return wrapper
sentry_sdk/logger.py CHANGED
@@ -22,13 +22,14 @@ def _capture_log(severity_text, severity_number, template, **kwargs):
22
22
  # type: (str, int, str, **Any) -> None
23
23
  client = get_client()
24
24
 
25
- attrs = {
26
- "sentry.message.template": template,
27
- } # type: dict[str, str | bool | float | int]
25
+ attrs = {} # type: dict[str, str | bool | float | int]
28
26
  if "attributes" in kwargs:
29
27
  attrs.update(kwargs.pop("attributes"))
30
28
  for k, v in kwargs.items():
31
29
  attrs[f"sentry.message.parameter.{k}"] = v
30
+ if kwargs:
31
+ # only attach template if there are parameters
32
+ attrs["sentry.message.template"] = template
32
33
 
33
34
  attrs = {
34
35
  k: (
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: sentry-sdk
3
- Version: 2.35.0
3
+ Version: 2.35.2
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
@@ -8,13 +8,13 @@ sentry_sdk/_types.py,sha256=TMdmMSxc0dYErvRA5ikEnNxH_Iwb2Wiw3ZUMNlp0HCA,10482
8
8
  sentry_sdk/_werkzeug.py,sha256=m3GPf-jHd8v3eVOfBHaKw5f0uHoLkXrSO1EcY-8EisY,3734
9
9
  sentry_sdk/api.py,sha256=OkwQ2tA5YASJ77wLOteUdv_woPF4wL_JTOAMxe9z8k4,15282
10
10
  sentry_sdk/attachments.py,sha256=0Dylhm065O6hNFjB40fWCd5Hg4qWSXndmi1TPWglZkI,3109
11
- sentry_sdk/client.py,sha256=BZvI07seonpiZpbbKBsiXDdMVDh3I42JsIvbgo06oqw,38828
12
- sentry_sdk/consts.py,sha256=eOQlSwtO4x3XGZYxOvOPkeA700mXmomHY1izrlr6j5s,49767
11
+ sentry_sdk/client.py,sha256=oQcolwFdLvuX4huUaCcpgABy3M5Yb4IhzymlzyrqfkE,38860
12
+ sentry_sdk/consts.py,sha256=18Xty_-BsOAFVppLK2qz--7EjhyEp80Lr9d6ZCYJgEw,49767
13
13
  sentry_sdk/debug.py,sha256=ddBehQlAuQC1sg1XO-N4N3diZ0x0iT5RWJwFdrtcsjw,1019
14
14
  sentry_sdk/envelope.py,sha256=Mgcib0uLm_5tSVzOrznRLdK9B3CjQ6TEgM1ZIZIfjWo,10355
15
15
  sentry_sdk/feature_flags.py,sha256=99JRig6TBkrkBzVCKqYcmVgjsuA_Hk-ul7jFHGhJplc,2233
16
16
  sentry_sdk/hub.py,sha256=2QLvEtIYSYV04r8h7VBmQjookILaiBZxZBGTtQKNAWg,25675
17
- sentry_sdk/logger.py,sha256=u_8zS8gjQt7FjYqz_I91sCbdsmBe7IgRqWxMP3vrsq0,2399
17
+ sentry_sdk/logger.py,sha256=HnmkMmOf1hwvxIcPW2qOvIOSnFZ9yRNDBae_eriGsoY,2471
18
18
  sentry_sdk/metrics.py,sha256=3IvBwbHlU-C-JdwDysTeJqOoVyYXsHZ7oEkkU0qTZb4,29913
19
19
  sentry_sdk/monitor.py,sha256=52CG1m2e8okFDVoTpbqfm9zeeaLa0ciC_r9x2RiXuDg,3639
20
20
  sentry_sdk/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -74,7 +74,7 @@ sentry_sdk/integrations/huggingface_hub.py,sha256=ypTn17T0vufQwi7ODXONFkB8fMjUrU
74
74
  sentry_sdk/integrations/langchain.py,sha256=8ht-fXKb9muG3HEnKhuSvna2G8f2_M9BBzm1jXjnqiQ,26413
75
75
  sentry_sdk/integrations/launchdarkly.py,sha256=bvtExuj68xPXZFsQeWTDR-ZBqP087tPuVzP1bNAOZHc,1935
76
76
  sentry_sdk/integrations/litestar.py,sha256=jao0f8v5JQagkBg15dUJTdWGPxpS3LmOV301-lwGkGc,11815
77
- sentry_sdk/integrations/logging.py,sha256=3IvbPmvisv9ZM98SRRYlEH5g1nNVjOZz-204CWRcg-I,13641
77
+ sentry_sdk/integrations/logging.py,sha256=4JC2ehLqd5Tz_rad8YVb9KhZnPcDzLxLh-AjopyNVEc,13905
78
78
  sentry_sdk/integrations/loguru.py,sha256=fgivPdQn3rmsMeInUd2wbNlbXPAH9MKhjaqytRVKnsI,6215
79
79
  sentry_sdk/integrations/modules.py,sha256=vzLx3Erg77Vl4mnUvAgTg_3teAuWy7zylFpAidBI9I0,820
80
80
  sentry_sdk/integrations/openai.py,sha256=N3CSx8OJlcx6cK2bj8GjmtcjBsw4T3fHdqlMKAzXirc,22939
@@ -124,9 +124,9 @@ sentry_sdk/integrations/openai_agents/__init__.py,sha256=-ydqG0sFIrvJlT9JHO58EZp
124
124
  sentry_sdk/integrations/openai_agents/consts.py,sha256=PTb3vlqkuMPktu21ALK72o5WMIX4-cewTEiTRdHKFdQ,38
125
125
  sentry_sdk/integrations/openai_agents/utils.py,sha256=ZtsID9kIF7pUYRqzJcGrtnhJZ838DxO2G7yhPdTHRUc,5499
126
126
  sentry_sdk/integrations/openai_agents/patches/__init__.py,sha256=I7C9JZ70Mf8PV3wPdFsxTqvcYl4TYUgSZYfNU2Spb7Y,231
127
- sentry_sdk/integrations/openai_agents/patches/agent_run.py,sha256=jDYY2jVTcoJLiH-0KOKMryv7IAoDKjWXsMwnxJU8KHM,5736
127
+ sentry_sdk/integrations/openai_agents/patches/agent_run.py,sha256=qPmZ--UMQpExxYGEbaDJ7tY_H9VQ6gv0lpim3_impWk,5733
128
128
  sentry_sdk/integrations/openai_agents/patches/models.py,sha256=DtwqCmSsYFlhRZquKM2jiTOnnAg97eyCTtJYZkWqdww,1405
129
- sentry_sdk/integrations/openai_agents/patches/runner.py,sha256=P1My3zKNlgCtu8cAkA-kEeyjclTi6-qk5jilWYBmfJY,1264
129
+ sentry_sdk/integrations/openai_agents/patches/runner.py,sha256=Fr5tflgadu3fnEThSZauAhrT7BbvemuZelDVGZjleqA,1483
130
130
  sentry_sdk/integrations/openai_agents/patches/tools.py,sha256=uAx1GgsiDJBP7jpYW8r_kOImdgzXlwYqK-uhkyP3icI,3255
131
131
  sentry_sdk/integrations/openai_agents/spans/__init__.py,sha256=RlVi781zGsvCJBciDO_EbBbwkakwbP9DoFQBbo4VAEE,353
132
132
  sentry_sdk/integrations/openai_agents/spans/agent_workflow.py,sha256=GIIeNKQ1rrciqkjwJWK5AMxsjWjWslR3E054jIWDoiw,459
@@ -158,9 +158,9 @@ sentry_sdk/profiler/__init__.py,sha256=3PI3bHk9RSkkOXZKN84DDedk_7M65EiqqaIGo-DYs
158
158
  sentry_sdk/profiler/continuous_profiler.py,sha256=s0DHkj3RZYRg9HnQQC0G44ku6DaFqRy30fZTMtTYvIs,22828
159
159
  sentry_sdk/profiler/transaction_profiler.py,sha256=4Gj6FHLnK1di3GmnI1cCc_DbNcBVMdBjZZFvPvm7C7k,27877
160
160
  sentry_sdk/profiler/utils.py,sha256=G5s4tYai9ATJqcHrQ3bOIxlK6jIaHzELrDtU5k3N4HI,6556
161
- sentry_sdk-2.35.0.dist-info/licenses/LICENSE,sha256=KhQNZg9GKBL6KQvHQNBGMxJsXsRdhLebVp4Sew7t3Qs,1093
162
- sentry_sdk-2.35.0.dist-info/METADATA,sha256=uoH5SQyyqgV4Tym4v4l9Hb21ENS9_wlln2WFYdKz39U,10278
163
- sentry_sdk-2.35.0.dist-info/WHEEL,sha256=JNWh1Fm1UdwIQV075glCn4MVuCRs0sotJIq-J6rbxCU,109
164
- sentry_sdk-2.35.0.dist-info/entry_points.txt,sha256=qacZEz40UspQZD1IukCXykx0JtImqGDOctS5KfOLTko,91
165
- sentry_sdk-2.35.0.dist-info/top_level.txt,sha256=XrQz30XE9FKXSY_yGLrd9bsv2Rk390GTDJOSujYaMxI,11
166
- sentry_sdk-2.35.0.dist-info/RECORD,,
161
+ sentry_sdk-2.35.2.dist-info/licenses/LICENSE,sha256=KhQNZg9GKBL6KQvHQNBGMxJsXsRdhLebVp4Sew7t3Qs,1093
162
+ sentry_sdk-2.35.2.dist-info/METADATA,sha256=FmXFlXAY2ea1whyuYCM_LCZMJIXm7V-2MNMkMxRZgXA,10278
163
+ sentry_sdk-2.35.2.dist-info/WHEEL,sha256=JNWh1Fm1UdwIQV075glCn4MVuCRs0sotJIq-J6rbxCU,109
164
+ sentry_sdk-2.35.2.dist-info/entry_points.txt,sha256=qacZEz40UspQZD1IukCXykx0JtImqGDOctS5KfOLTko,91
165
+ sentry_sdk-2.35.2.dist-info/top_level.txt,sha256=XrQz30XE9FKXSY_yGLrd9bsv2Rk390GTDJOSujYaMxI,11
166
+ sentry_sdk-2.35.2.dist-info/RECORD,,