sentry-sdk 2.32.0__py2.py3-none-any.whl → 2.33.0__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/ai/monitoring.py +7 -3
- sentry_sdk/consts.py +1 -1
- sentry_sdk/integrations/langchain.py +38 -19
- sentry_sdk/integrations/openai_agents/spans/ai_client.py +2 -1
- sentry_sdk/integrations/openai_agents/utils.py +2 -1
- sentry_sdk/sessions.py +8 -9
- {sentry_sdk-2.32.0.dist-info → sentry_sdk-2.33.0.dist-info}/METADATA +1 -1
- {sentry_sdk-2.32.0.dist-info → sentry_sdk-2.33.0.dist-info}/RECORD +12 -12
- {sentry_sdk-2.32.0.dist-info → sentry_sdk-2.33.0.dist-info}/WHEEL +0 -0
- {sentry_sdk-2.32.0.dist-info → sentry_sdk-2.33.0.dist-info}/entry_points.txt +0 -0
- {sentry_sdk-2.32.0.dist-info → sentry_sdk-2.33.0.dist-info}/licenses/LICENSE +0 -0
- {sentry_sdk-2.32.0.dist-info → sentry_sdk-2.33.0.dist-info}/top_level.txt +0 -0
sentry_sdk/ai/monitoring.py
CHANGED
|
@@ -102,15 +102,19 @@ def record_token_usage(
|
|
|
102
102
|
ai_pipeline_name = get_ai_pipeline_name()
|
|
103
103
|
if ai_pipeline_name:
|
|
104
104
|
span.set_data(SPANDATA.AI_PIPELINE_NAME, ai_pipeline_name)
|
|
105
|
+
|
|
105
106
|
if prompt_tokens is not None:
|
|
106
|
-
span.
|
|
107
|
+
span.set_data(SPANDATA.GEN_AI_USAGE_INPUT_TOKENS, prompt_tokens)
|
|
108
|
+
|
|
107
109
|
if completion_tokens is not None:
|
|
108
|
-
span.
|
|
110
|
+
span.set_data(SPANDATA.GEN_AI_USAGE_OUTPUT_TOKENS, completion_tokens)
|
|
111
|
+
|
|
109
112
|
if (
|
|
110
113
|
total_tokens is None
|
|
111
114
|
and prompt_tokens is not None
|
|
112
115
|
and completion_tokens is not None
|
|
113
116
|
):
|
|
114
117
|
total_tokens = prompt_tokens + completion_tokens
|
|
118
|
+
|
|
115
119
|
if total_tokens is not None:
|
|
116
|
-
span.
|
|
120
|
+
span.set_data(SPANDATA.GEN_AI_USAGE_TOTAL_TOKENS, total_tokens)
|
sentry_sdk/consts.py
CHANGED
|
@@ -23,6 +23,7 @@ try:
|
|
|
23
23
|
from langchain_core.callbacks import (
|
|
24
24
|
manager,
|
|
25
25
|
BaseCallbackHandler,
|
|
26
|
+
BaseCallbackManager,
|
|
26
27
|
Callbacks,
|
|
27
28
|
)
|
|
28
29
|
from langchain_core.agents import AgentAction, AgentFinish
|
|
@@ -434,12 +435,20 @@ def _wrap_configure(f):
|
|
|
434
435
|
**kwargs,
|
|
435
436
|
)
|
|
436
437
|
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
438
|
+
local_callbacks = local_callbacks or []
|
|
439
|
+
|
|
440
|
+
# Handle each possible type of local_callbacks. For each type, we
|
|
441
|
+
# extract the list of callbacks to check for SentryLangchainCallback,
|
|
442
|
+
# and define a function that would add the SentryLangchainCallback
|
|
443
|
+
# to the existing callbacks list.
|
|
444
|
+
if isinstance(local_callbacks, BaseCallbackManager):
|
|
445
|
+
callbacks_list = local_callbacks.handlers
|
|
446
|
+
elif isinstance(local_callbacks, BaseCallbackHandler):
|
|
447
|
+
callbacks_list = [local_callbacks]
|
|
448
|
+
elif isinstance(local_callbacks, list):
|
|
449
|
+
callbacks_list = local_callbacks
|
|
450
|
+
else:
|
|
451
|
+
logger.debug("Unknown callback type: %s", local_callbacks)
|
|
443
452
|
# Just proceed with original function call
|
|
444
453
|
return f(
|
|
445
454
|
callback_manager_cls,
|
|
@@ -449,28 +458,38 @@ def _wrap_configure(f):
|
|
|
449
458
|
**kwargs,
|
|
450
459
|
)
|
|
451
460
|
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
461
|
+
# Handle each possible type of inheritable_callbacks.
|
|
462
|
+
if isinstance(inheritable_callbacks, BaseCallbackManager):
|
|
463
|
+
inheritable_callbacks_list = inheritable_callbacks.handlers
|
|
464
|
+
elif isinstance(inheritable_callbacks, list):
|
|
465
|
+
inheritable_callbacks_list = inheritable_callbacks
|
|
466
|
+
else:
|
|
467
|
+
inheritable_callbacks_list = []
|
|
455
468
|
|
|
456
469
|
if not any(
|
|
457
470
|
isinstance(cb, SentryLangchainCallback)
|
|
458
471
|
for cb in itertools.chain(callbacks_list, inheritable_callbacks_list)
|
|
459
472
|
):
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
473
|
+
sentry_handler = SentryLangchainCallback(
|
|
474
|
+
integration.max_spans,
|
|
475
|
+
integration.include_prompts,
|
|
476
|
+
integration.tiktoken_encoding_name,
|
|
477
|
+
)
|
|
478
|
+
if isinstance(local_callbacks, BaseCallbackManager):
|
|
479
|
+
local_callbacks = local_callbacks.copy()
|
|
480
|
+
local_callbacks.handlers = [
|
|
481
|
+
*local_callbacks.handlers,
|
|
482
|
+
sentry_handler,
|
|
483
|
+
]
|
|
484
|
+
elif isinstance(local_callbacks, BaseCallbackHandler):
|
|
485
|
+
local_callbacks = [local_callbacks, sentry_handler]
|
|
486
|
+
else: # local_callbacks is a list
|
|
487
|
+
local_callbacks = [*local_callbacks, sentry_handler]
|
|
469
488
|
|
|
470
489
|
return f(
|
|
471
490
|
callback_manager_cls,
|
|
472
491
|
inheritable_callbacks,
|
|
473
|
-
|
|
492
|
+
local_callbacks,
|
|
474
493
|
*args,
|
|
475
494
|
**kwargs,
|
|
476
495
|
)
|
|
@@ -19,9 +19,10 @@ if TYPE_CHECKING:
|
|
|
19
19
|
def ai_client_span(agent, get_response_kwargs):
|
|
20
20
|
# type: (Agent, dict[str, Any]) -> sentry_sdk.tracing.Span
|
|
21
21
|
# TODO-anton: implement other types of operations. Now "chat" is hardcoded.
|
|
22
|
+
model_name = agent.model.model if hasattr(agent.model, "model") else agent.model
|
|
22
23
|
span = sentry_sdk.start_span(
|
|
23
24
|
op=OP.GEN_AI_CHAT,
|
|
24
|
-
description=f"chat {
|
|
25
|
+
description=f"chat {model_name}",
|
|
25
26
|
origin=SPAN_ORIGIN,
|
|
26
27
|
)
|
|
27
28
|
# TODO-anton: remove hardcoded stuff and replace something that also works for embedding and so on
|
|
@@ -53,7 +53,8 @@ def _set_agent_data(span, agent):
|
|
|
53
53
|
)
|
|
54
54
|
|
|
55
55
|
if agent.model:
|
|
56
|
-
|
|
56
|
+
model_name = agent.model.model if hasattr(agent.model, "model") else agent.model
|
|
57
|
+
span.set_data(SPANDATA.GEN_AI_REQUEST_MODEL, model_name)
|
|
57
58
|
|
|
58
59
|
if agent.model_settings.presence_penalty:
|
|
59
60
|
span.set_data(
|
sentry_sdk/sessions.py
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import os
|
|
2
|
-
import time
|
|
3
2
|
import warnings
|
|
4
|
-
from threading import Thread, Lock
|
|
3
|
+
from threading import Thread, Lock, Event
|
|
5
4
|
from contextlib import contextmanager
|
|
6
5
|
|
|
7
6
|
import sentry_sdk
|
|
@@ -162,7 +161,7 @@ class SessionFlusher:
|
|
|
162
161
|
self._thread_lock = Lock()
|
|
163
162
|
self._aggregate_lock = Lock()
|
|
164
163
|
self._thread_for_pid = None # type: Optional[int]
|
|
165
|
-
self.
|
|
164
|
+
self.__shutdown_requested = Event()
|
|
166
165
|
|
|
167
166
|
def flush(self):
|
|
168
167
|
# type: (...) -> None
|
|
@@ -208,10 +207,10 @@ class SessionFlusher:
|
|
|
208
207
|
|
|
209
208
|
def _thread():
|
|
210
209
|
# type: (...) -> None
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
210
|
+
running = True
|
|
211
|
+
while running:
|
|
212
|
+
running = not self.__shutdown_requested.wait(self.flush_interval)
|
|
213
|
+
self.flush()
|
|
215
214
|
|
|
216
215
|
thread = Thread(target=_thread)
|
|
217
216
|
thread.daemon = True
|
|
@@ -220,7 +219,7 @@ class SessionFlusher:
|
|
|
220
219
|
except RuntimeError:
|
|
221
220
|
# Unfortunately at this point the interpreter is in a state that no
|
|
222
221
|
# longer allows us to spawn a thread and we have to bail.
|
|
223
|
-
self.
|
|
222
|
+
self.__shutdown_requested.set()
|
|
224
223
|
return None
|
|
225
224
|
|
|
226
225
|
self._thread = thread
|
|
@@ -271,7 +270,7 @@ class SessionFlusher:
|
|
|
271
270
|
|
|
272
271
|
def kill(self):
|
|
273
272
|
# type: (...) -> None
|
|
274
|
-
self.
|
|
273
|
+
self.__shutdown_requested.set()
|
|
275
274
|
|
|
276
275
|
def __del__(self):
|
|
277
276
|
# type: (...) -> None
|
|
@@ -9,7 +9,7 @@ sentry_sdk/_werkzeug.py,sha256=m3GPf-jHd8v3eVOfBHaKw5f0uHoLkXrSO1EcY-8EisY,3734
|
|
|
9
9
|
sentry_sdk/api.py,sha256=mdw2-KPGLrYwN7QPRbk2TL4gDfOV56fIO8fAdafMcFo,12192
|
|
10
10
|
sentry_sdk/attachments.py,sha256=0Dylhm065O6hNFjB40fWCd5Hg4qWSXndmi1TPWglZkI,3109
|
|
11
11
|
sentry_sdk/client.py,sha256=7G9qH7YsBhl2ga9BZgmW0ESuXl4Z8pQZz2M8GC3aIV4,38668
|
|
12
|
-
sentry_sdk/consts.py,sha256=
|
|
12
|
+
sentry_sdk/consts.py,sha256=PE5l_ESiXr5Gy1z2IPuKyCQPvVjuxjDdrkuS6DFGhSE,45069
|
|
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
|
|
@@ -22,7 +22,7 @@ sentry_sdk/scope.py,sha256=fl6Hm7BD-1HlzghOHkWY_zQY3FkakrNrqdjebfJ0LbY,63942
|
|
|
22
22
|
sentry_sdk/scrubber.py,sha256=rENmQ35buugDl269bRZuIAtgr27B9SzisJYUF-691pc,6064
|
|
23
23
|
sentry_sdk/serializer.py,sha256=iXiRwTuRj0gcKyHRO0GNTZB1Hmk0LMDiBt6Be7RpGt8,13087
|
|
24
24
|
sentry_sdk/session.py,sha256=TqDVmRKKHUDSmZb4jQR-s8wDt7Fwb6QaG21hawUGWEs,5571
|
|
25
|
-
sentry_sdk/sessions.py,sha256=
|
|
25
|
+
sentry_sdk/sessions.py,sha256=gQxwVBVqGhLp4a6xwrUe3JdaCSVbitZRxTdqScOSjj4,9228
|
|
26
26
|
sentry_sdk/spotlight.py,sha256=93kdd8KxdLfcPaxFnFuqHgYAAL4FCfpK1hiiPoD7Ac4,8678
|
|
27
27
|
sentry_sdk/tracing.py,sha256=dEyLZn0JSj5WMjVJEQUxRud5NewBRau9dkuDrrzJ_Xw,48114
|
|
28
28
|
sentry_sdk/tracing_utils.py,sha256=J_eY_0XuyydslEmcFZcrv8dt2ItpW7uWwe6CoXxoK5Q,28820
|
|
@@ -31,7 +31,7 @@ sentry_sdk/types.py,sha256=NLbnRzww2K3_oGz2GzcC8TdX5L2DXYso1-H1uCv2Hwc,1222
|
|
|
31
31
|
sentry_sdk/utils.py,sha256=jRoLuDOYyZXn2Ks7BP4WUOTkutJnofKBZoJ9s7Dha5k,59368
|
|
32
32
|
sentry_sdk/worker.py,sha256=VSMaigRMbInVyupSFpBC42bft2oIViea-0C_d9ThnIo,4464
|
|
33
33
|
sentry_sdk/ai/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
34
|
-
sentry_sdk/ai/monitoring.py,sha256=
|
|
34
|
+
sentry_sdk/ai/monitoring.py,sha256=hDaLjTcI_CMUpy_wyYD5WNts07I07BZDleItu0Djv_w,4508
|
|
35
35
|
sentry_sdk/ai/utils.py,sha256=QCwhHoptrdXyYroJqzCKxqi0cmrlD9IDDWUcBk6yWZc,950
|
|
36
36
|
sentry_sdk/crons/__init__.py,sha256=3Zt6g1-pZZ12uRKKsC8QLm3XgJ4K1VYxgVpNNUygOZY,221
|
|
37
37
|
sentry_sdk/crons/api.py,sha256=s3x6SG-jqIdWS-Kj0sAxJv0nz2A3stdGE1UCtQyRUy4,1559
|
|
@@ -71,7 +71,7 @@ sentry_sdk/integrations/graphene.py,sha256=I6ZJ8Apd9dO9XPVvZY7I46-v1eXOW1C1rAkWw
|
|
|
71
71
|
sentry_sdk/integrations/httpx.py,sha256=WwUulqzBLoGGqWUUdQg_MThwQUKzBXnA-m3g_1GOpCE,5866
|
|
72
72
|
sentry_sdk/integrations/huey.py,sha256=wlyxjeWqqJp1X5S3neD5FiZjXcyznm1dl8_u1wIo76U,5443
|
|
73
73
|
sentry_sdk/integrations/huggingface_hub.py,sha256=pbtcwBtB0Nz09nNVxKMDs_GYm9XGmQVj1xgSsFSLdLI,6551
|
|
74
|
-
sentry_sdk/integrations/langchain.py,sha256=
|
|
74
|
+
sentry_sdk/integrations/langchain.py,sha256=Zxc0Xf7Y5Nv7_r-awlfXtvloGwma2B2onm-ylrQWvLU,18993
|
|
75
75
|
sentry_sdk/integrations/launchdarkly.py,sha256=bvtExuj68xPXZFsQeWTDR-ZBqP087tPuVzP1bNAOZHc,1935
|
|
76
76
|
sentry_sdk/integrations/litestar.py,sha256=ui52AfgyyAO4aQ9XSkqJZNcPduX0BccCYUkQA9nIJ_E,11891
|
|
77
77
|
sentry_sdk/integrations/logging.py,sha256=-0o9HTFo5RpHkCpxfZvpiBj5VWpH4aIJmH-HNQzj3Ec,13643
|
|
@@ -122,7 +122,7 @@ sentry_sdk/integrations/grpc/aio/client.py,sha256=csOwlJb7fg9fBnzeNHxr-qpZEmU97I
|
|
|
122
122
|
sentry_sdk/integrations/grpc/aio/server.py,sha256=SCkdikPZRdWyrlnZewsSGpPk4v6AsdSApVAbO-lf_Lk,4019
|
|
123
123
|
sentry_sdk/integrations/openai_agents/__init__.py,sha256=-ydqG0sFIrvJlT9JHO58EZpCAzyy9J59Av8dxn0fHuw,1424
|
|
124
124
|
sentry_sdk/integrations/openai_agents/consts.py,sha256=PTb3vlqkuMPktu21ALK72o5WMIX4-cewTEiTRdHKFdQ,38
|
|
125
|
-
sentry_sdk/integrations/openai_agents/utils.py,sha256=
|
|
125
|
+
sentry_sdk/integrations/openai_agents/utils.py,sha256=fZ00TW7eUBH3e0BSBp0QnXJioYQgGh32S-mptJz96-4,7099
|
|
126
126
|
sentry_sdk/integrations/openai_agents/patches/__init__.py,sha256=I7C9JZ70Mf8PV3wPdFsxTqvcYl4TYUgSZYfNU2Spb7Y,231
|
|
127
127
|
sentry_sdk/integrations/openai_agents/patches/agent_run.py,sha256=jDYY2jVTcoJLiH-0KOKMryv7IAoDKjWXsMwnxJU8KHM,5736
|
|
128
128
|
sentry_sdk/integrations/openai_agents/patches/models.py,sha256=DtwqCmSsYFlhRZquKM2jiTOnnAg97eyCTtJYZkWqdww,1405
|
|
@@ -130,7 +130,7 @@ sentry_sdk/integrations/openai_agents/patches/runner.py,sha256=P1My3zKNlgCtu8cAk
|
|
|
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
|
|
133
|
-
sentry_sdk/integrations/openai_agents/spans/ai_client.py,sha256=
|
|
133
|
+
sentry_sdk/integrations/openai_agents/spans/ai_client.py,sha256=0HG5pT8a06Zgc5JUmRx8p_6bPoQFQLjDrMY_QSQd0_E,1206
|
|
134
134
|
sentry_sdk/integrations/openai_agents/spans/execute_tool.py,sha256=w3QWWS4wbpteFTz4JjMCXdDpR6JVKcUVREQ-lvJOQTY,1420
|
|
135
135
|
sentry_sdk/integrations/openai_agents/spans/handoff.py,sha256=MBhzy7MpvPGwQTPT5TFcOnmSPiSH_uadQ5wvksueIik,525
|
|
136
136
|
sentry_sdk/integrations/openai_agents/spans/invoke_agent.py,sha256=WU7E7DoO1IXZKjXuZ1BTPqfWnm3mNl6Ao8duUGoRA9w,875
|
|
@@ -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.
|
|
162
|
-
sentry_sdk-2.
|
|
163
|
-
sentry_sdk-2.
|
|
164
|
-
sentry_sdk-2.
|
|
165
|
-
sentry_sdk-2.
|
|
166
|
-
sentry_sdk-2.
|
|
161
|
+
sentry_sdk-2.33.0.dist-info/licenses/LICENSE,sha256=KhQNZg9GKBL6KQvHQNBGMxJsXsRdhLebVp4Sew7t3Qs,1093
|
|
162
|
+
sentry_sdk-2.33.0.dist-info/METADATA,sha256=dMkhuet0J0rBMeXCztJyYwoQwKvKC5gwByORWmpygJg,10278
|
|
163
|
+
sentry_sdk-2.33.0.dist-info/WHEEL,sha256=JNWh1Fm1UdwIQV075glCn4MVuCRs0sotJIq-J6rbxCU,109
|
|
164
|
+
sentry_sdk-2.33.0.dist-info/entry_points.txt,sha256=qacZEz40UspQZD1IukCXykx0JtImqGDOctS5KfOLTko,91
|
|
165
|
+
sentry_sdk-2.33.0.dist-info/top_level.txt,sha256=XrQz30XE9FKXSY_yGLrd9bsv2Rk390GTDJOSujYaMxI,11
|
|
166
|
+
sentry_sdk-2.33.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|