sentry-sdk 2.42.0__tar.gz → 2.42.1__tar.gz

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.

Files changed (210) hide show
  1. {sentry_sdk-2.42.0/sentry_sdk.egg-info → sentry_sdk-2.42.1}/PKG-INFO +1 -1
  2. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/sentry_sdk/ai/utils.py +49 -2
  3. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/sentry_sdk/client.py +18 -1
  4. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/sentry_sdk/consts.py +1 -1
  5. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/sentry_sdk/integrations/anthropic.py +8 -5
  6. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/sentry_sdk/integrations/aws_lambda.py +2 -0
  7. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/sentry_sdk/integrations/gcp.py +6 -1
  8. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/sentry_sdk/integrations/langchain.py +41 -21
  9. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/sentry_sdk/integrations/langgraph.py +25 -11
  10. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/sentry_sdk/integrations/litellm.py +6 -2
  11. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/sentry_sdk/integrations/openai.py +33 -9
  12. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/sentry_sdk/integrations/redis/utils.py +4 -4
  13. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/sentry_sdk/scope.py +13 -6
  14. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/sentry_sdk/utils.py +34 -2
  15. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1/sentry_sdk.egg-info}/PKG-INFO +1 -1
  16. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/setup.py +1 -1
  17. sentry_sdk-2.42.1/tests/test_ai_monitoring.py +517 -0
  18. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/tests/test_scope.py +8 -6
  19. sentry_sdk-2.42.0/tests/test_ai_monitoring.py +0 -162
  20. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/LICENSE +0 -0
  21. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/MANIFEST.in +0 -0
  22. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/README.md +0 -0
  23. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/pyproject.toml +0 -0
  24. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/sentry_sdk/__init__.py +0 -0
  25. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/sentry_sdk/_compat.py +0 -0
  26. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/sentry_sdk/_init_implementation.py +0 -0
  27. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/sentry_sdk/_log_batcher.py +0 -0
  28. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/sentry_sdk/_lru_cache.py +0 -0
  29. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/sentry_sdk/_metrics.py +0 -0
  30. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/sentry_sdk/_metrics_batcher.py +0 -0
  31. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/sentry_sdk/_queue.py +0 -0
  32. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/sentry_sdk/_types.py +0 -0
  33. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/sentry_sdk/_werkzeug.py +0 -0
  34. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/sentry_sdk/ai/__init__.py +0 -0
  35. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/sentry_sdk/ai/monitoring.py +0 -0
  36. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/sentry_sdk/api.py +0 -0
  37. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/sentry_sdk/attachments.py +0 -0
  38. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/sentry_sdk/crons/__init__.py +0 -0
  39. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/sentry_sdk/crons/api.py +0 -0
  40. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/sentry_sdk/crons/consts.py +0 -0
  41. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/sentry_sdk/crons/decorator.py +0 -0
  42. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/sentry_sdk/debug.py +0 -0
  43. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/sentry_sdk/envelope.py +0 -0
  44. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/sentry_sdk/feature_flags.py +0 -0
  45. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/sentry_sdk/hub.py +0 -0
  46. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/sentry_sdk/integrations/__init__.py +0 -0
  47. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/sentry_sdk/integrations/_asgi_common.py +0 -0
  48. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/sentry_sdk/integrations/_wsgi_common.py +0 -0
  49. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/sentry_sdk/integrations/aiohttp.py +0 -0
  50. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/sentry_sdk/integrations/argv.py +0 -0
  51. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/sentry_sdk/integrations/ariadne.py +0 -0
  52. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/sentry_sdk/integrations/arq.py +0 -0
  53. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/sentry_sdk/integrations/asgi.py +0 -0
  54. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/sentry_sdk/integrations/asyncio.py +0 -0
  55. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/sentry_sdk/integrations/asyncpg.py +0 -0
  56. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/sentry_sdk/integrations/atexit.py +0 -0
  57. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/sentry_sdk/integrations/beam.py +0 -0
  58. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/sentry_sdk/integrations/boto3.py +0 -0
  59. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/sentry_sdk/integrations/bottle.py +0 -0
  60. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/sentry_sdk/integrations/celery/__init__.py +0 -0
  61. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/sentry_sdk/integrations/celery/beat.py +0 -0
  62. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/sentry_sdk/integrations/celery/utils.py +0 -0
  63. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/sentry_sdk/integrations/chalice.py +0 -0
  64. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/sentry_sdk/integrations/clickhouse_driver.py +0 -0
  65. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/sentry_sdk/integrations/cloud_resource_context.py +0 -0
  66. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/sentry_sdk/integrations/cohere.py +0 -0
  67. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/sentry_sdk/integrations/dedupe.py +0 -0
  68. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/sentry_sdk/integrations/django/__init__.py +0 -0
  69. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/sentry_sdk/integrations/django/asgi.py +0 -0
  70. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/sentry_sdk/integrations/django/caching.py +0 -0
  71. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/sentry_sdk/integrations/django/middleware.py +0 -0
  72. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/sentry_sdk/integrations/django/signals_handlers.py +0 -0
  73. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/sentry_sdk/integrations/django/templates.py +0 -0
  74. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/sentry_sdk/integrations/django/transactions.py +0 -0
  75. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/sentry_sdk/integrations/django/views.py +0 -0
  76. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/sentry_sdk/integrations/dramatiq.py +0 -0
  77. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/sentry_sdk/integrations/excepthook.py +0 -0
  78. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/sentry_sdk/integrations/executing.py +0 -0
  79. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/sentry_sdk/integrations/falcon.py +0 -0
  80. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/sentry_sdk/integrations/fastapi.py +0 -0
  81. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/sentry_sdk/integrations/flask.py +0 -0
  82. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/sentry_sdk/integrations/gnu_backtrace.py +0 -0
  83. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/sentry_sdk/integrations/google_genai/__init__.py +0 -0
  84. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/sentry_sdk/integrations/google_genai/consts.py +0 -0
  85. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/sentry_sdk/integrations/google_genai/streaming.py +0 -0
  86. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/sentry_sdk/integrations/google_genai/utils.py +0 -0
  87. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/sentry_sdk/integrations/gql.py +0 -0
  88. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/sentry_sdk/integrations/graphene.py +0 -0
  89. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/sentry_sdk/integrations/grpc/__init__.py +0 -0
  90. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/sentry_sdk/integrations/grpc/aio/__init__.py +0 -0
  91. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/sentry_sdk/integrations/grpc/aio/client.py +0 -0
  92. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/sentry_sdk/integrations/grpc/aio/server.py +0 -0
  93. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/sentry_sdk/integrations/grpc/client.py +0 -0
  94. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/sentry_sdk/integrations/grpc/consts.py +0 -0
  95. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/sentry_sdk/integrations/grpc/server.py +0 -0
  96. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/sentry_sdk/integrations/httpx.py +0 -0
  97. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/sentry_sdk/integrations/huey.py +0 -0
  98. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/sentry_sdk/integrations/huggingface_hub.py +0 -0
  99. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/sentry_sdk/integrations/launchdarkly.py +0 -0
  100. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/sentry_sdk/integrations/litestar.py +0 -0
  101. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/sentry_sdk/integrations/logging.py +0 -0
  102. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/sentry_sdk/integrations/loguru.py +0 -0
  103. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/sentry_sdk/integrations/modules.py +0 -0
  104. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/sentry_sdk/integrations/openai_agents/__init__.py +0 -0
  105. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/sentry_sdk/integrations/openai_agents/consts.py +0 -0
  106. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/sentry_sdk/integrations/openai_agents/patches/__init__.py +0 -0
  107. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/sentry_sdk/integrations/openai_agents/patches/agent_run.py +0 -0
  108. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/sentry_sdk/integrations/openai_agents/patches/models.py +0 -0
  109. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/sentry_sdk/integrations/openai_agents/patches/runner.py +0 -0
  110. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/sentry_sdk/integrations/openai_agents/patches/tools.py +0 -0
  111. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/sentry_sdk/integrations/openai_agents/spans/__init__.py +0 -0
  112. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/sentry_sdk/integrations/openai_agents/spans/agent_workflow.py +0 -0
  113. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/sentry_sdk/integrations/openai_agents/spans/ai_client.py +0 -0
  114. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/sentry_sdk/integrations/openai_agents/spans/execute_tool.py +0 -0
  115. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/sentry_sdk/integrations/openai_agents/spans/handoff.py +0 -0
  116. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/sentry_sdk/integrations/openai_agents/spans/invoke_agent.py +0 -0
  117. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/sentry_sdk/integrations/openai_agents/utils.py +0 -0
  118. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/sentry_sdk/integrations/openfeature.py +0 -0
  119. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/sentry_sdk/integrations/opentelemetry/__init__.py +0 -0
  120. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/sentry_sdk/integrations/opentelemetry/consts.py +0 -0
  121. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/sentry_sdk/integrations/opentelemetry/integration.py +0 -0
  122. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/sentry_sdk/integrations/opentelemetry/propagator.py +0 -0
  123. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/sentry_sdk/integrations/opentelemetry/span_processor.py +0 -0
  124. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/sentry_sdk/integrations/pure_eval.py +0 -0
  125. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/sentry_sdk/integrations/pymongo.py +0 -0
  126. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/sentry_sdk/integrations/pyramid.py +0 -0
  127. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/sentry_sdk/integrations/quart.py +0 -0
  128. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/sentry_sdk/integrations/ray.py +0 -0
  129. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/sentry_sdk/integrations/redis/__init__.py +0 -0
  130. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/sentry_sdk/integrations/redis/_async_common.py +0 -0
  131. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/sentry_sdk/integrations/redis/_sync_common.py +0 -0
  132. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/sentry_sdk/integrations/redis/consts.py +0 -0
  133. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/sentry_sdk/integrations/redis/modules/__init__.py +0 -0
  134. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/sentry_sdk/integrations/redis/modules/caches.py +0 -0
  135. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/sentry_sdk/integrations/redis/modules/queries.py +0 -0
  136. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/sentry_sdk/integrations/redis/rb.py +0 -0
  137. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/sentry_sdk/integrations/redis/redis.py +0 -0
  138. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/sentry_sdk/integrations/redis/redis_cluster.py +0 -0
  139. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/sentry_sdk/integrations/redis/redis_py_cluster_legacy.py +0 -0
  140. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/sentry_sdk/integrations/rq.py +0 -0
  141. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/sentry_sdk/integrations/rust_tracing.py +0 -0
  142. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/sentry_sdk/integrations/sanic.py +0 -0
  143. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/sentry_sdk/integrations/serverless.py +0 -0
  144. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/sentry_sdk/integrations/socket.py +0 -0
  145. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/sentry_sdk/integrations/spark/__init__.py +0 -0
  146. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/sentry_sdk/integrations/spark/spark_driver.py +0 -0
  147. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/sentry_sdk/integrations/spark/spark_worker.py +0 -0
  148. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/sentry_sdk/integrations/sqlalchemy.py +0 -0
  149. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/sentry_sdk/integrations/starlette.py +0 -0
  150. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/sentry_sdk/integrations/starlite.py +0 -0
  151. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/sentry_sdk/integrations/statsig.py +0 -0
  152. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/sentry_sdk/integrations/stdlib.py +0 -0
  153. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/sentry_sdk/integrations/strawberry.py +0 -0
  154. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/sentry_sdk/integrations/sys_exit.py +0 -0
  155. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/sentry_sdk/integrations/threading.py +0 -0
  156. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/sentry_sdk/integrations/tornado.py +0 -0
  157. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/sentry_sdk/integrations/trytond.py +0 -0
  158. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/sentry_sdk/integrations/typer.py +0 -0
  159. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/sentry_sdk/integrations/unleash.py +0 -0
  160. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/sentry_sdk/integrations/unraisablehook.py +0 -0
  161. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/sentry_sdk/integrations/wsgi.py +0 -0
  162. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/sentry_sdk/logger.py +0 -0
  163. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/sentry_sdk/monitor.py +0 -0
  164. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/sentry_sdk/profiler/__init__.py +0 -0
  165. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/sentry_sdk/profiler/continuous_profiler.py +0 -0
  166. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/sentry_sdk/profiler/transaction_profiler.py +0 -0
  167. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/sentry_sdk/profiler/utils.py +0 -0
  168. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/sentry_sdk/py.typed +0 -0
  169. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/sentry_sdk/scrubber.py +0 -0
  170. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/sentry_sdk/serializer.py +0 -0
  171. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/sentry_sdk/session.py +0 -0
  172. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/sentry_sdk/sessions.py +0 -0
  173. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/sentry_sdk/spotlight.py +0 -0
  174. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/sentry_sdk/tracing.py +0 -0
  175. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/sentry_sdk/tracing_utils.py +0 -0
  176. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/sentry_sdk/transport.py +0 -0
  177. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/sentry_sdk/types.py +0 -0
  178. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/sentry_sdk/worker.py +0 -0
  179. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/sentry_sdk.egg-info/SOURCES.txt +0 -0
  180. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/sentry_sdk.egg-info/dependency_links.txt +0 -0
  181. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/sentry_sdk.egg-info/entry_points.txt +0 -0
  182. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/sentry_sdk.egg-info/not-zip-safe +0 -0
  183. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/sentry_sdk.egg-info/requires.txt +0 -0
  184. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/sentry_sdk.egg-info/top_level.txt +0 -0
  185. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/setup.cfg +0 -0
  186. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/tests/test_api.py +0 -0
  187. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/tests/test_basics.py +0 -0
  188. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/tests/test_client.py +0 -0
  189. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/tests/test_conftest.py +0 -0
  190. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/tests/test_crons.py +0 -0
  191. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/tests/test_dsc.py +0 -0
  192. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/tests/test_envelope.py +0 -0
  193. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/tests/test_exceptiongroup.py +0 -0
  194. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/tests/test_feature_flags.py +0 -0
  195. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/tests/test_full_stack_frames.py +0 -0
  196. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/tests/test_gevent.py +0 -0
  197. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/tests/test_import.py +0 -0
  198. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/tests/test_logs.py +0 -0
  199. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/tests/test_lru_cache.py +0 -0
  200. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/tests/test_metrics.py +0 -0
  201. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/tests/test_monitor.py +0 -0
  202. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/tests/test_propagationcontext.py +0 -0
  203. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/tests/test_scrubber.py +0 -0
  204. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/tests/test_serializer.py +0 -0
  205. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/tests/test_sessions.py +0 -0
  206. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/tests/test_spotlight.py +0 -0
  207. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/tests/test_tracing_utils.py +0 -0
  208. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/tests/test_transport.py +0 -0
  209. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/tests/test_types.py +0 -0
  210. {sentry_sdk-2.42.0 → sentry_sdk-2.42.1}/tests/test_utils.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: sentry-sdk
3
- Version: 2.42.0
3
+ Version: 2.42.1
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,14 +1,18 @@
1
1
  import json
2
-
2
+ from collections import deque
3
3
  from typing import TYPE_CHECKING
4
+ from sys import getsizeof
4
5
 
5
6
  if TYPE_CHECKING:
6
- from typing import Any, Callable
7
+ from typing import Any, Callable, Dict, List, Optional, Tuple
8
+
7
9
  from sentry_sdk.tracing import Span
8
10
 
9
11
  import sentry_sdk
10
12
  from sentry_sdk.utils import logger
11
13
 
14
+ MAX_GEN_AI_MESSAGE_BYTES = 20_000 # 20KB
15
+
12
16
 
13
17
  class GEN_AI_ALLOWED_MESSAGE_ROLES:
14
18
  SYSTEM = "system"
@@ -95,3 +99,46 @@ def get_start_span_function():
95
99
  current_span is not None and current_span.containing_transaction is not None
96
100
  )
97
101
  return sentry_sdk.start_span if transaction_exists else sentry_sdk.start_transaction
102
+
103
+
104
+ def _find_truncation_index(messages, max_bytes):
105
+ # type: (List[Dict[str, Any]], int) -> int
106
+ """
107
+ Find the index of the first message that would exceed the max bytes limit.
108
+ Compute the individual message sizes, and return the index of the first message from the back
109
+ of the list that would exceed the max bytes limit.
110
+ """
111
+ running_sum = 0
112
+ for idx in range(len(messages) - 1, -1, -1):
113
+ size = len(json.dumps(messages[idx], separators=(",", ":")).encode("utf-8"))
114
+ running_sum += size
115
+ if running_sum > max_bytes:
116
+ return idx + 1
117
+
118
+ return 0
119
+
120
+
121
+ def truncate_messages_by_size(messages, max_bytes=MAX_GEN_AI_MESSAGE_BYTES):
122
+ # type: (List[Dict[str, Any]], int) -> Tuple[List[Dict[str, Any]], int]
123
+ serialized_json = json.dumps(messages, separators=(",", ":"))
124
+ current_size = len(serialized_json.encode("utf-8"))
125
+
126
+ if current_size <= max_bytes:
127
+ return messages, 0
128
+
129
+ truncation_index = _find_truncation_index(messages, max_bytes)
130
+ return messages[truncation_index:], truncation_index
131
+
132
+
133
+ def truncate_and_annotate_messages(
134
+ messages, span, scope, max_bytes=MAX_GEN_AI_MESSAGE_BYTES
135
+ ):
136
+ # type: (Optional[List[Dict[str, Any]]], Any, Any, int) -> Optional[List[Dict[str, Any]]]
137
+ if not messages:
138
+ return None
139
+
140
+ truncated_messages, removed_count = truncate_messages_by_size(messages, max_bytes)
141
+ if removed_count > 0:
142
+ scope._gen_ai_original_message_count[span.span_id] = len(messages)
143
+
144
+ return truncated_messages
@@ -598,14 +598,31 @@ class _Client(BaseClient):
598
598
  if event_scrubber:
599
599
  event_scrubber.scrub_event(event)
600
600
 
601
+ if scope is not None and scope._gen_ai_original_message_count:
602
+ spans = event.get("spans", []) # type: List[Dict[str, Any]] | AnnotatedValue
603
+ if isinstance(spans, list):
604
+ for span in spans:
605
+ span_id = span.get("span_id", None)
606
+ span_data = span.get("data", {})
607
+ if (
608
+ span_id
609
+ and span_id in scope._gen_ai_original_message_count
610
+ and SPANDATA.GEN_AI_REQUEST_MESSAGES in span_data
611
+ ):
612
+ span_data[SPANDATA.GEN_AI_REQUEST_MESSAGES] = AnnotatedValue(
613
+ span_data[SPANDATA.GEN_AI_REQUEST_MESSAGES],
614
+ {"len": scope._gen_ai_original_message_count[span_id]},
615
+ )
601
616
  if previous_total_spans is not None:
602
617
  event["spans"] = AnnotatedValue(
603
618
  event.get("spans", []), {"len": previous_total_spans}
604
619
  )
605
620
  if previous_total_breadcrumbs is not None:
606
621
  event["breadcrumbs"] = AnnotatedValue(
607
- event.get("breadcrumbs", []), {"len": previous_total_breadcrumbs}
622
+ event.get("breadcrumbs", {"values": []}),
623
+ {"len": previous_total_breadcrumbs},
608
624
  )
625
+
609
626
  # Postprocess the event here so that annotated types do
610
627
  # generally not surface in before_send
611
628
  if event is not None:
@@ -1348,4 +1348,4 @@ DEFAULT_OPTIONS = _get_default_options()
1348
1348
  del _get_default_options
1349
1349
 
1350
1350
 
1351
- VERSION = "2.42.0"
1351
+ VERSION = "2.42.1"
@@ -6,6 +6,7 @@ from sentry_sdk.ai.monitoring import record_token_usage
6
6
  from sentry_sdk.ai.utils import (
7
7
  set_data_normalized,
8
8
  normalize_message_roles,
9
+ truncate_and_annotate_messages,
9
10
  get_start_span_function,
10
11
  )
11
12
  from sentry_sdk.consts import OP, SPANDATA, SPANSTATUS
@@ -145,12 +146,14 @@ def _set_input_data(span, kwargs, integration):
145
146
  normalized_messages.append(message)
146
147
 
147
148
  role_normalized_messages = normalize_message_roles(normalized_messages)
148
- set_data_normalized(
149
- span,
150
- SPANDATA.GEN_AI_REQUEST_MESSAGES,
151
- role_normalized_messages,
152
- unpack=False,
149
+ scope = sentry_sdk.get_current_scope()
150
+ messages_data = truncate_and_annotate_messages(
151
+ role_normalized_messages, span, scope
153
152
  )
153
+ if messages_data is not None:
154
+ set_data_normalized(
155
+ span, SPANDATA.GEN_AI_REQUEST_MESSAGES, messages_data, unpack=False
156
+ )
154
157
 
155
158
  set_data_normalized(
156
159
  span, SPANDATA.GEN_AI_RESPONSE_STREAMING, kwargs.get("stream", False)
@@ -138,6 +138,8 @@ def _wrap_handler(handler):
138
138
  timeout_thread = TimeoutThread(
139
139
  waiting_time,
140
140
  configured_time / MILLIS_TO_SECONDS,
141
+ isolation_scope=scope,
142
+ current_scope=sentry_sdk.get_current_scope(),
141
143
  )
142
144
 
143
145
  # Starting the thread to raise timeout warning exception
@@ -75,7 +75,12 @@ def _wrap_func(func):
75
75
  ):
76
76
  waiting_time = configured_time - TIMEOUT_WARNING_BUFFER
77
77
 
78
- timeout_thread = TimeoutThread(waiting_time, configured_time)
78
+ timeout_thread = TimeoutThread(
79
+ waiting_time,
80
+ configured_time,
81
+ isolation_scope=scope,
82
+ current_scope=sentry_sdk.get_current_scope(),
83
+ )
79
84
 
80
85
  # Starting the thread to raise timeout warning exception
81
86
  timeout_thread.start()
@@ -9,6 +9,7 @@ from sentry_sdk.ai.utils import (
9
9
  normalize_message_roles,
10
10
  set_data_normalized,
11
11
  get_start_span_function,
12
+ truncate_and_annotate_messages,
12
13
  )
13
14
  from sentry_sdk.consts import OP, SPANDATA
14
15
  from sentry_sdk.integrations import DidNotEnable, Integration
@@ -221,12 +222,17 @@ class SentryLangchainCallback(BaseCallbackHandler): # type: ignore[misc]
221
222
  }
222
223
  for prompt in prompts
223
224
  ]
224
- set_data_normalized(
225
- span,
226
- SPANDATA.GEN_AI_REQUEST_MESSAGES,
227
- normalized_messages,
228
- unpack=False,
225
+ scope = sentry_sdk.get_current_scope()
226
+ messages_data = truncate_and_annotate_messages(
227
+ normalized_messages, span, scope
229
228
  )
229
+ if messages_data is not None:
230
+ set_data_normalized(
231
+ span,
232
+ SPANDATA.GEN_AI_REQUEST_MESSAGES,
233
+ messages_data,
234
+ unpack=False,
235
+ )
230
236
 
231
237
  def on_chat_model_start(self, serialized, messages, *, run_id, **kwargs):
232
238
  # type: (SentryLangchainCallback, Dict[str, Any], List[List[BaseMessage]], UUID, Any) -> Any
@@ -278,13 +284,17 @@ class SentryLangchainCallback(BaseCallbackHandler): # type: ignore[misc]
278
284
  self._normalize_langchain_message(message)
279
285
  )
280
286
  normalized_messages = normalize_message_roles(normalized_messages)
281
-
282
- set_data_normalized(
283
- span,
284
- SPANDATA.GEN_AI_REQUEST_MESSAGES,
285
- normalized_messages,
286
- unpack=False,
287
+ scope = sentry_sdk.get_current_scope()
288
+ messages_data = truncate_and_annotate_messages(
289
+ normalized_messages, span, scope
287
290
  )
291
+ if messages_data is not None:
292
+ set_data_normalized(
293
+ span,
294
+ SPANDATA.GEN_AI_REQUEST_MESSAGES,
295
+ messages_data,
296
+ unpack=False,
297
+ )
288
298
 
289
299
  def on_chat_model_end(self, response, *, run_id, **kwargs):
290
300
  # type: (SentryLangchainCallback, LLMResult, UUID, Any) -> Any
@@ -758,12 +768,17 @@ def _wrap_agent_executor_invoke(f):
758
768
  and integration.include_prompts
759
769
  ):
760
770
  normalized_messages = normalize_message_roles([input])
761
- set_data_normalized(
762
- span,
763
- SPANDATA.GEN_AI_REQUEST_MESSAGES,
764
- normalized_messages,
765
- unpack=False,
771
+ scope = sentry_sdk.get_current_scope()
772
+ messages_data = truncate_and_annotate_messages(
773
+ normalized_messages, span, scope
766
774
  )
775
+ if messages_data is not None:
776
+ set_data_normalized(
777
+ span,
778
+ SPANDATA.GEN_AI_REQUEST_MESSAGES,
779
+ messages_data,
780
+ unpack=False,
781
+ )
767
782
 
768
783
  output = result.get("output")
769
784
  if (
@@ -813,12 +828,17 @@ def _wrap_agent_executor_stream(f):
813
828
  and integration.include_prompts
814
829
  ):
815
830
  normalized_messages = normalize_message_roles([input])
816
- set_data_normalized(
817
- span,
818
- SPANDATA.GEN_AI_REQUEST_MESSAGES,
819
- normalized_messages,
820
- unpack=False,
831
+ scope = sentry_sdk.get_current_scope()
832
+ messages_data = truncate_and_annotate_messages(
833
+ normalized_messages, span, scope
821
834
  )
835
+ if messages_data is not None:
836
+ set_data_normalized(
837
+ span,
838
+ SPANDATA.GEN_AI_REQUEST_MESSAGES,
839
+ messages_data,
840
+ unpack=False,
841
+ )
822
842
 
823
843
  # Run the agent
824
844
  result = f(self, *args, **kwargs)
@@ -2,7 +2,11 @@ from functools import wraps
2
2
  from typing import Any, Callable, List, Optional
3
3
 
4
4
  import sentry_sdk
5
- from sentry_sdk.ai.utils import set_data_normalized, normalize_message_roles
5
+ from sentry_sdk.ai.utils import (
6
+ set_data_normalized,
7
+ normalize_message_roles,
8
+ truncate_and_annotate_messages,
9
+ )
6
10
  from sentry_sdk.consts import OP, SPANDATA
7
11
  from sentry_sdk.integrations import DidNotEnable, Integration
8
12
  from sentry_sdk.scope import should_send_default_pii
@@ -181,12 +185,17 @@ def _wrap_pregel_invoke(f):
181
185
  input_messages = _parse_langgraph_messages(args[0])
182
186
  if input_messages:
183
187
  normalized_input_messages = normalize_message_roles(input_messages)
184
- set_data_normalized(
185
- span,
186
- SPANDATA.GEN_AI_REQUEST_MESSAGES,
187
- normalized_input_messages,
188
- unpack=False,
188
+ scope = sentry_sdk.get_current_scope()
189
+ messages_data = truncate_and_annotate_messages(
190
+ normalized_input_messages, span, scope
189
191
  )
192
+ if messages_data is not None:
193
+ set_data_normalized(
194
+ span,
195
+ SPANDATA.GEN_AI_REQUEST_MESSAGES,
196
+ messages_data,
197
+ unpack=False,
198
+ )
190
199
 
191
200
  result = f(self, *args, **kwargs)
192
201
 
@@ -232,12 +241,17 @@ def _wrap_pregel_ainvoke(f):
232
241
  input_messages = _parse_langgraph_messages(args[0])
233
242
  if input_messages:
234
243
  normalized_input_messages = normalize_message_roles(input_messages)
235
- set_data_normalized(
236
- span,
237
- SPANDATA.GEN_AI_REQUEST_MESSAGES,
238
- normalized_input_messages,
239
- unpack=False,
244
+ scope = sentry_sdk.get_current_scope()
245
+ messages_data = truncate_and_annotate_messages(
246
+ normalized_input_messages, span, scope
240
247
  )
248
+ if messages_data is not None:
249
+ set_data_normalized(
250
+ span,
251
+ SPANDATA.GEN_AI_REQUEST_MESSAGES,
252
+ messages_data,
253
+ unpack=False,
254
+ )
241
255
 
242
256
  result = await f(self, *args, **kwargs)
243
257
 
@@ -48,8 +48,11 @@ def _input_callback(kwargs):
48
48
  model = full_model
49
49
  provider = "unknown"
50
50
 
51
- messages = kwargs.get("messages", [])
52
- operation = "chat" if messages else "embeddings"
51
+ call_type = kwargs.get("call_type", None)
52
+ if call_type == "embedding":
53
+ operation = "embeddings"
54
+ else:
55
+ operation = "chat"
53
56
 
54
57
  # Start a new span/transaction
55
58
  span = get_start_span_function()(
@@ -71,6 +74,7 @@ def _input_callback(kwargs):
71
74
  set_data_normalized(span, SPANDATA.GEN_AI_OPERATION_NAME, operation)
72
75
 
73
76
  # Record messages if allowed
77
+ messages = kwargs.get("messages", [])
74
78
  if messages and should_send_default_pii() and integration.include_prompts:
75
79
  set_data_normalized(
76
80
  span, SPANDATA.GEN_AI_REQUEST_MESSAGES, messages, unpack=False
@@ -3,7 +3,11 @@ from functools import wraps
3
3
  import sentry_sdk
4
4
  from sentry_sdk import consts
5
5
  from sentry_sdk.ai.monitoring import record_token_usage
6
- from sentry_sdk.ai.utils import set_data_normalized, normalize_message_roles
6
+ from sentry_sdk.ai.utils import (
7
+ set_data_normalized,
8
+ normalize_message_roles,
9
+ truncate_and_annotate_messages,
10
+ )
7
11
  from sentry_sdk.consts import SPANDATA
8
12
  from sentry_sdk.integrations import DidNotEnable, Integration
9
13
  from sentry_sdk.scope import should_send_default_pii
@@ -22,9 +26,14 @@ if TYPE_CHECKING:
22
26
 
23
27
  try:
24
28
  try:
25
- from openai import NOT_GIVEN
29
+ from openai import NotGiven
26
30
  except ImportError:
27
- NOT_GIVEN = None
31
+ NotGiven = None
32
+
33
+ try:
34
+ from openai import Omit
35
+ except ImportError:
36
+ Omit = None
28
37
 
29
38
  from openai.resources.chat.completions import Completions, AsyncCompletions
30
39
  from openai.resources import Embeddings, AsyncEmbeddings
@@ -183,9 +192,12 @@ def _set_input_data(span, kwargs, operation, integration):
183
192
  and integration.include_prompts
184
193
  ):
185
194
  normalized_messages = normalize_message_roles(messages)
186
- set_data_normalized(
187
- span, SPANDATA.GEN_AI_REQUEST_MESSAGES, normalized_messages, unpack=False
188
- )
195
+ scope = sentry_sdk.get_current_scope()
196
+ messages_data = truncate_and_annotate_messages(normalized_messages, span, scope)
197
+ if messages_data is not None:
198
+ set_data_normalized(
199
+ span, SPANDATA.GEN_AI_REQUEST_MESSAGES, messages_data, unpack=False
200
+ )
189
201
 
190
202
  # Input attributes: Common
191
203
  set_data_normalized(span, SPANDATA.GEN_AI_SYSTEM, "openai")
@@ -204,12 +216,12 @@ def _set_input_data(span, kwargs, operation, integration):
204
216
  for key, attribute in kwargs_keys_to_attributes.items():
205
217
  value = kwargs.get(key)
206
218
 
207
- if value is not NOT_GIVEN and value is not None:
219
+ if value is not None and _is_given(value):
208
220
  set_data_normalized(span, attribute, value)
209
221
 
210
222
  # Input attributes: Tools
211
223
  tools = kwargs.get("tools")
212
- if tools is not NOT_GIVEN and tools is not None and len(tools) > 0:
224
+ if tools is not None and _is_given(tools) and len(tools) > 0:
213
225
  set_data_normalized(
214
226
  span, SPANDATA.GEN_AI_REQUEST_AVAILABLE_TOOLS, safe_serialize(tools)
215
227
  )
@@ -231,7 +243,7 @@ def _set_output_data(span, response, kwargs, integration, finish_span=True):
231
243
 
232
244
  if hasattr(response, "choices"):
233
245
  if should_send_default_pii() and integration.include_prompts:
234
- response_text = [choice.message.dict() for choice in response.choices]
246
+ response_text = [choice.message.model_dump() for choice in response.choices]
235
247
  if len(response_text) > 0:
236
248
  set_data_normalized(span, SPANDATA.GEN_AI_RESPONSE_TEXT, response_text)
237
249
 
@@ -689,3 +701,15 @@ def _wrap_async_responses_create(f):
689
701
  return await _execute_async(f, *args, **kwargs)
690
702
 
691
703
  return _sentry_patched_responses_async
704
+
705
+
706
+ def _is_given(obj):
707
+ # type: (Any) -> bool
708
+ """
709
+ Check for givenness safely across different openai versions.
710
+ """
711
+ if NotGiven is not None and isinstance(obj, NotGiven):
712
+ return False
713
+ if Omit is not None and isinstance(obj, Omit):
714
+ return False
715
+ return True
@@ -20,12 +20,13 @@ def _get_safe_command(name, args):
20
20
  # type: (str, Sequence[Any]) -> str
21
21
  command_parts = [name]
22
22
 
23
+ name_low = name.lower()
24
+ send_default_pii = should_send_default_pii()
25
+
23
26
  for i, arg in enumerate(args):
24
27
  if i > _MAX_NUM_ARGS:
25
28
  break
26
29
 
27
- name_low = name.lower()
28
-
29
30
  if name_low in _COMMANDS_INCLUDING_SENSITIVE_DATA:
30
31
  command_parts.append(SENSITIVE_DATA_SUBSTITUTE)
31
32
  continue
@@ -33,9 +34,8 @@ def _get_safe_command(name, args):
33
34
  arg_is_the_key = i == 0
34
35
  if arg_is_the_key:
35
36
  command_parts.append(repr(arg))
36
-
37
37
  else:
38
- if should_send_default_pii():
38
+ if send_default_pii:
39
39
  command_parts.append(repr(arg))
40
40
  else:
41
41
  command_parts.append(SENSITIVE_DATA_SUBSTITUTE)
@@ -188,6 +188,7 @@ class Scope:
188
188
  "_extras",
189
189
  "_breadcrumbs",
190
190
  "_n_breadcrumbs_truncated",
191
+ "_gen_ai_original_message_count",
191
192
  "_event_processors",
192
193
  "_error_processors",
193
194
  "_should_capture",
@@ -213,6 +214,7 @@ class Scope:
213
214
  self._name = None # type: Optional[str]
214
215
  self._propagation_context = None # type: Optional[PropagationContext]
215
216
  self._n_breadcrumbs_truncated = 0 # type: int
217
+ self._gen_ai_original_message_count = {} # type: Dict[str, int]
216
218
 
217
219
  self.client = NonRecordingClient() # type: sentry_sdk.client.BaseClient
218
220
 
@@ -247,6 +249,7 @@ class Scope:
247
249
 
248
250
  rv._breadcrumbs = copy(self._breadcrumbs)
249
251
  rv._n_breadcrumbs_truncated = self._n_breadcrumbs_truncated
252
+ rv._gen_ai_original_message_count = self._gen_ai_original_message_count.copy()
250
253
  rv._event_processors = self._event_processors.copy()
251
254
  rv._error_processors = self._error_processors.copy()
252
255
  rv._propagation_context = self._propagation_context
@@ -1583,6 +1586,10 @@ class Scope:
1583
1586
  self._n_breadcrumbs_truncated = (
1584
1587
  self._n_breadcrumbs_truncated + scope._n_breadcrumbs_truncated
1585
1588
  )
1589
+ if scope._gen_ai_original_message_count:
1590
+ self._gen_ai_original_message_count.update(
1591
+ scope._gen_ai_original_message_count
1592
+ )
1586
1593
  if scope._span:
1587
1594
  self._span = scope._span
1588
1595
  if scope._attachments:
@@ -1679,7 +1686,7 @@ def new_scope():
1679
1686
  try:
1680
1687
  # restore original scope
1681
1688
  _current_scope.reset(token)
1682
- except LookupError:
1689
+ except (LookupError, ValueError):
1683
1690
  capture_internal_exception(sys.exc_info())
1684
1691
 
1685
1692
 
@@ -1717,7 +1724,7 @@ def use_scope(scope):
1717
1724
  try:
1718
1725
  # restore original scope
1719
1726
  _current_scope.reset(token)
1720
- except LookupError:
1727
+ except (LookupError, ValueError):
1721
1728
  capture_internal_exception(sys.exc_info())
1722
1729
 
1723
1730
 
@@ -1761,12 +1768,12 @@ def isolation_scope():
1761
1768
  # restore original scopes
1762
1769
  try:
1763
1770
  _current_scope.reset(current_token)
1764
- except LookupError:
1771
+ except (LookupError, ValueError):
1765
1772
  capture_internal_exception(sys.exc_info())
1766
1773
 
1767
1774
  try:
1768
1775
  _isolation_scope.reset(isolation_token)
1769
- except LookupError:
1776
+ except (LookupError, ValueError):
1770
1777
  capture_internal_exception(sys.exc_info())
1771
1778
 
1772
1779
 
@@ -1808,12 +1815,12 @@ def use_isolation_scope(isolation_scope):
1808
1815
  # restore original scopes
1809
1816
  try:
1810
1817
  _current_scope.reset(current_token)
1811
- except LookupError:
1818
+ except (LookupError, ValueError):
1812
1819
  capture_internal_exception(sys.exc_info())
1813
1820
 
1814
1821
  try:
1815
1822
  _isolation_scope.reset(isolation_token)
1816
- except LookupError:
1823
+ except (LookupError, ValueError):
1817
1824
  capture_internal_exception(sys.exc_info())
1818
1825
 
1819
1826
 
@@ -1484,17 +1484,37 @@ class TimeoutThread(threading.Thread):
1484
1484
  waiting_time and raises a custom ServerlessTimeout exception.
1485
1485
  """
1486
1486
 
1487
- def __init__(self, waiting_time, configured_timeout):
1488
- # type: (float, int) -> None
1487
+ def __init__(
1488
+ self, waiting_time, configured_timeout, isolation_scope=None, current_scope=None
1489
+ ):
1490
+ # type: (float, int, Optional[sentry_sdk.Scope], Optional[sentry_sdk.Scope]) -> None
1489
1491
  threading.Thread.__init__(self)
1490
1492
  self.waiting_time = waiting_time
1491
1493
  self.configured_timeout = configured_timeout
1494
+
1495
+ self.isolation_scope = isolation_scope
1496
+ self.current_scope = current_scope
1497
+
1492
1498
  self._stop_event = threading.Event()
1493
1499
 
1494
1500
  def stop(self):
1495
1501
  # type: () -> None
1496
1502
  self._stop_event.set()
1497
1503
 
1504
+ def _capture_exception(self):
1505
+ # type: () -> ExcInfo
1506
+ exc_info = sys.exc_info()
1507
+
1508
+ client = sentry_sdk.get_client()
1509
+ event, hint = event_from_exception(
1510
+ exc_info,
1511
+ client_options=client.options,
1512
+ mechanism={"type": "threading", "handled": False},
1513
+ )
1514
+ sentry_sdk.capture_event(event, hint=hint)
1515
+
1516
+ return exc_info
1517
+
1498
1518
  def run(self):
1499
1519
  # type: () -> None
1500
1520
 
@@ -1510,6 +1530,18 @@ class TimeoutThread(threading.Thread):
1510
1530
  integer_configured_timeout = integer_configured_timeout + 1
1511
1531
 
1512
1532
  # Raising Exception after timeout duration is reached
1533
+ if self.isolation_scope is not None and self.current_scope is not None:
1534
+ with sentry_sdk.scope.use_isolation_scope(self.isolation_scope):
1535
+ with sentry_sdk.scope.use_scope(self.current_scope):
1536
+ try:
1537
+ raise ServerlessTimeoutWarning(
1538
+ "WARNING : Function is expected to get timed out. Configured timeout duration = {} seconds.".format(
1539
+ integer_configured_timeout
1540
+ )
1541
+ )
1542
+ except Exception:
1543
+ reraise(*self._capture_exception())
1544
+
1513
1545
  raise ServerlessTimeoutWarning(
1514
1546
  "WARNING : Function is expected to get timed out. Configured timeout duration = {} seconds.".format(
1515
1547
  integer_configured_timeout
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: sentry-sdk
3
- Version: 2.42.0
3
+ Version: 2.42.1
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
@@ -21,7 +21,7 @@ def get_file_text(file_name):
21
21
 
22
22
  setup(
23
23
  name="sentry-sdk",
24
- version="2.42.0",
24
+ version="2.42.1",
25
25
  author="Sentry Team and Contributors",
26
26
  author_email="hello@sentry.io",
27
27
  url="https://github.com/getsentry/sentry-python",