langtrace-python-sdk 2.3.10__py3-none-any.whl → 2.3.11__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.
@@ -1 +1,2 @@
1
1
  LANGTRACE_SDK_NAME = "langtrace-python-sdk"
2
+ SENTRY_DSN = "https://7f8eed3a1237fb2efef0f5e96ab407af@o1419498.ingest.us.sentry.io/4507929133056000"
@@ -19,6 +19,7 @@ import sys
19
19
  from typing import Optional
20
20
  import importlib.util
21
21
  from colorama import Fore
22
+ from langtrace_python_sdk.constants import LANGTRACE_SDK_NAME, SENTRY_DSN
22
23
  from opentelemetry import trace
23
24
  from opentelemetry.instrumentation.sqlalchemy import SQLAlchemyInstrumentor
24
25
  from opentelemetry.sdk.resources import SERVICE_NAME, Resource
@@ -60,8 +61,9 @@ from langtrace_python_sdk.types import (
60
61
  InstrumentationMethods,
61
62
  InstrumentationType,
62
63
  )
63
- from langtrace_python_sdk.utils import check_if_sdk_is_outdated
64
+ from langtrace_python_sdk.utils import check_if_sdk_is_outdated, get_sdk_version
64
65
  from langtrace_python_sdk.utils.langtrace_sampler import LangtraceSampler
66
+ import sentry_sdk
65
67
 
66
68
 
67
69
  def init(
@@ -164,6 +166,27 @@ def init(
164
166
  provider.add_span_processor(batch_processor_remote)
165
167
 
166
168
  sys.stdout = sys.__stdout__
169
+ if os.environ.get("LANGTRACE_ERROR_REPORTING", "True") == "True":
170
+ sentry_sdk.init(
171
+ dsn=SENTRY_DSN,
172
+ traces_sample_rate=1.0,
173
+ profiles_sample_rate=1.0,
174
+ )
175
+ sdk_options = {
176
+ "service_name": os.environ.get("OTEL_SERVICE_NAME")
177
+ or service_name
178
+ or sys.argv[0],
179
+ "disable_logging": disable_logging,
180
+ "disable_instrumentations": disable_instrumentations,
181
+ "disable_tracing_for_functions": disable_tracing_for_functions,
182
+ "batch": batch,
183
+ "write_spans_to_console": write_spans_to_console,
184
+ "custom_remote_exporter": custom_remote_exporter,
185
+ "sdk_name": LANGTRACE_SDK_NAME,
186
+ "sdk_version": get_sdk_version(),
187
+ "api_host": host,
188
+ }
189
+ sentry_sdk.set_context("sdk_init_options", sdk_options)
167
190
 
168
191
 
169
192
  def init_instrumentations(
@@ -233,4 +256,7 @@ def validate_instrumentations(disable_instrumentations):
233
256
 
234
257
 
235
258
  def is_package_installed(package_name):
236
- return importlib.util.find_spec(package_name) is not None
259
+ import pkg_resources
260
+
261
+ installed_packages = {p.key for p in pkg_resources.working_set}
262
+ return package_name in installed_packages
@@ -31,3 +31,7 @@ def set_event_prompt(span: Span, prompt):
31
31
  def check_if_sdk_is_outdated():
32
32
  SDKVersionChecker().check()
33
33
  return
34
+
35
+
36
+ def get_sdk_version():
37
+ return SDKVersionChecker().get_sdk_version()
@@ -44,6 +44,9 @@ class SDKVersionChecker:
44
44
  return self._current_version < latest_version
45
45
  return False
46
46
 
47
+ def get_sdk_version(self):
48
+ return self._current_version
49
+
47
50
  def check(self):
48
51
  if self.is_outdated():
49
52
  print(
@@ -1 +1 @@
1
- __version__ = "2.3.10"
1
+ __version__ = "2.3.11"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: langtrace-python-sdk
3
- Version: 2.3.10
3
+ Version: 2.3.11
4
4
  Summary: Python SDK for LangTrace
5
5
  Project-URL: Homepage, https://github.com/Scale3-Labs/langtrace-python-sdk
6
6
  Author-email: Scale3 Labs <engineering@scale3labs.com>
@@ -18,6 +18,7 @@ Requires-Dist: opentelemetry-exporter-otlp-proto-http>=1.25.0
18
18
  Requires-Dist: opentelemetry-instrumentation-sqlalchemy>=0.46b0
19
19
  Requires-Dist: opentelemetry-instrumentation>=0.47b0
20
20
  Requires-Dist: opentelemetry-sdk>=1.25.0
21
+ Requires-Dist: sentry-sdk>=2.14.0
21
22
  Requires-Dist: sqlalchemy
22
23
  Requires-Dist: tiktoken>=0.1.1
23
24
  Requires-Dist: trace-attributes==7.0.4
@@ -196,6 +197,10 @@ langtrace.init(custom_remote_exporter=<your_exporter>, batch=<True or False>)
196
197
  | `api_host` | `Optional[str]` | `https://langtrace.ai/` | The API host for the remote exporter. |
197
198
  | `disable_instrumentations` | `Optional[DisableInstrumentations]` | `None` | You can pass an object to disable instrumentation for specific vendors ex: `{'only': ['openai']}` or `{'all_except': ['openai']}` |
198
199
 
200
+ ### Error Reporting to Langtrace
201
+
202
+ By default all sdk errors are reported to langtrace via Sentry. This can be disabled by setting the following enviroment variable to `False` like so `LANGTRACE_ERROR_REPORTING=False`
203
+
199
204
  ### Additional Customization
200
205
 
201
206
  - `@with_langtrace_root_span` - this decorator is designed to organize and relate different spans, in a hierarchical manner. When you're performing multiple operations that you want to monitor together as a unit, this function helps by establishing a "parent" (`LangtraceRootSpan` or whatever is passed to `name`) span. Then, any calls to the LLM APIs made within the given function (fn) will be considered "children" of this parent span. This setup is especially useful for tracking the performance or behavior of a group of operations collectively, rather than individually.
@@ -277,6 +282,7 @@ prompt = get_prompt_from_registry(<Registry ID>, options={"prompt_version": 1, "
277
282
  ```
278
283
 
279
284
  ### Opt out of tracing prompt and completion data
285
+
280
286
  By default, prompt and completion data are captured. If you would like to opt out of it, set the following env var,
281
287
 
282
288
  `TRACE_PROMPT_COMPLETION_DATA=false`
@@ -88,9 +88,9 @@ examples/vertexai_example/main.py,sha256=gndId5X5ksD-ycxnAWMdEqIDbLc3kz5Vt8vm4YP
88
88
  examples/weaviate_example/__init__.py,sha256=8JMDBsRSEV10HfTd-YC7xb4txBjD3la56snk-Bbg2Kw,618
89
89
  examples/weaviate_example/query_text.py,sha256=wPHQTc_58kPoKTZMygVjTj-2ZcdrIuaausJfMxNQnQc,127162
90
90
  langtrace_python_sdk/__init__.py,sha256=VZM6i71NR7pBQK6XvJWRelknuTYUhqwqE7PlicKa5Wg,1166
91
- langtrace_python_sdk/langtrace.py,sha256=cwqjmqaKQBmP3VY0yTyfaNh6ykeWHu1qQvxcKvs0yKo,8697
92
- langtrace_python_sdk/version.py,sha256=d7cuwqxkJuICmemJ_2rkIxE0f8PFypzWeUNmJ-fIm0I,23
93
- langtrace_python_sdk/constants/__init__.py,sha256=P8QvYwt5czUNDZsKS64vxm9Dc41ptGbuF1TFtAF6nv4,44
91
+ langtrace_python_sdk/langtrace.py,sha256=labHlbgL6BbGwmreWT0xJwD2UxNU2vLOmojBzRQslR8,9771
92
+ langtrace_python_sdk/version.py,sha256=nuL9dghQK8vN4aR24DmbKir_FPU7ZcuF5DEn_IKqPMA,23
93
+ langtrace_python_sdk/constants/__init__.py,sha256=3CNYkWMdd1DrkGqzLUgNZXjdAlM6UFMlf_F-odAToyc,146
94
94
  langtrace_python_sdk/constants/exporter/langtrace_exporter.py,sha256=5MNjnAOg-4am78J3gVMH6FSwq5N8TOj72ugkhsw4vi0,46
95
95
  langtrace_python_sdk/constants/instrumentation/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
96
96
  langtrace_python_sdk/constants/instrumentation/anthropic.py,sha256=YX3llt3zwDY6XrYk3CB8WEVqgrzRXEw_ffyk56JoF3k,126
@@ -174,12 +174,12 @@ langtrace_python_sdk/instrumentation/weaviate/__init__.py,sha256=Mc-Je6evPo-kKQz
174
174
  langtrace_python_sdk/instrumentation/weaviate/instrumentation.py,sha256=bzPwtoQD0X6beLYXe6ZL7XRkyRkqdiqKiGc4gOlCQdU,2295
175
175
  langtrace_python_sdk/instrumentation/weaviate/patch.py,sha256=3qxhJjEnu5lNb6_x0p82PaFBgXul-b0XTyTQV1JHzhw,6597
176
176
  langtrace_python_sdk/types/__init__.py,sha256=MeGkmoy2OY3V21GErDIdlf_N8Aj7HDld5Tpbvq2PwTY,4104
177
- langtrace_python_sdk/utils/__init__.py,sha256=giTHkvDOQdqFqXU4PoGP7DhA9tAteZN-KxX3mEUg6QQ,893
177
+ langtrace_python_sdk/utils/__init__.py,sha256=E_e67mDn5fSGF3qcYilz2X2qtqAiIS0HTpbh9kzYcXY,967
178
178
  langtrace_python_sdk/utils/langtrace_sampler.py,sha256=BupNndHbU9IL_wGleKetz8FdcveqHMBVz1bfKTTW80w,1753
179
179
  langtrace_python_sdk/utils/llm.py,sha256=k16jQL3wf1dYIDOcXSvHVfL0s97cu3QVLMmZmtTT3Gk,14741
180
180
  langtrace_python_sdk/utils/misc.py,sha256=7PRJ45BwuwJ6fPAdy1OpBau8QERR2aWaVvzDvZ7JTkE,1729
181
181
  langtrace_python_sdk/utils/prompt_registry.py,sha256=n5dQMVLBw8aJZY8Utvf67bncc25ELf6AH9BYw8_hSzo,2619
182
- langtrace_python_sdk/utils/sdk_version_checker.py,sha256=FzjIWZjn53cX0LEVPdipQd1fO9lG8iGVUEVUs9Hyk6M,1713
182
+ langtrace_python_sdk/utils/sdk_version_checker.py,sha256=F-VVVH7Fmhr5LcY0IIe-34zIi5RQcx26uuxFpPzZesM,1782
183
183
  langtrace_python_sdk/utils/silently_fail.py,sha256=wzmvRDZppaRZgVP8C1xpq2GlWXYCwubhaeWvEbQP1SI,1196
184
184
  langtrace_python_sdk/utils/types.py,sha256=l-N6o7cnWUyrD6dBvW7W3Pf5CkPo5QaoT__k1XLbrQg,383
185
185
  langtrace_python_sdk/utils/with_root_span.py,sha256=2iWu8XD1NOFqSFgDZDJiMHZ1JB4HzmYPLr_F3Ugul2k,8480
@@ -225,8 +225,8 @@ tests/pinecone/cassettes/test_query.yaml,sha256=b5v9G3ssUy00oG63PlFUR3JErF2Js-5A
225
225
  tests/pinecone/cassettes/test_upsert.yaml,sha256=neWmQ1v3d03V8WoLl8FoFeeCYImb8pxlJBWnFd_lITU,38607
226
226
  tests/qdrant/conftest.py,sha256=9n0uHxxIjWk9fbYc4bx-uP8lSAgLBVx-cV9UjnsyCHM,381
227
227
  tests/qdrant/test_qdrant.py,sha256=pzjAjVY2kmsmGfrI2Gs2xrolfuaNHz7l1fqGQCjp5_o,3353
228
- langtrace_python_sdk-2.3.10.dist-info/METADATA,sha256=KA8joYIy5gc3BrFFTvfYm5RMWcWJvZjpwRDAKFBYVDo,15012
229
- langtrace_python_sdk-2.3.10.dist-info/WHEEL,sha256=1yFddiXMmvYK7QYTqtRNtX66WJ0Mz8PYEiEUoOUUxRY,87
230
- langtrace_python_sdk-2.3.10.dist-info/entry_points.txt,sha256=1_b9-qvf2fE7uQNZcbUei9vLpFZBbbh9LrtGw95ssAo,70
231
- langtrace_python_sdk-2.3.10.dist-info/licenses/LICENSE,sha256=QwcOLU5TJoTeUhuIXzhdCEEDDvorGiC6-3YTOl4TecE,11356
232
- langtrace_python_sdk-2.3.10.dist-info/RECORD,,
228
+ langtrace_python_sdk-2.3.11.dist-info/METADATA,sha256=6ZhhzV4Eyq5rgOMd1k-fLf20WBgoKzS8yPd6KTG7bLo,15265
229
+ langtrace_python_sdk-2.3.11.dist-info/WHEEL,sha256=1yFddiXMmvYK7QYTqtRNtX66WJ0Mz8PYEiEUoOUUxRY,87
230
+ langtrace_python_sdk-2.3.11.dist-info/entry_points.txt,sha256=1_b9-qvf2fE7uQNZcbUei9vLpFZBbbh9LrtGw95ssAo,70
231
+ langtrace_python_sdk-2.3.11.dist-info/licenses/LICENSE,sha256=QwcOLU5TJoTeUhuIXzhdCEEDDvorGiC6-3YTOl4TecE,11356
232
+ langtrace_python_sdk-2.3.11.dist-info/RECORD,,