langtrace-python-sdk 2.1.7__py3-none-any.whl → 2.1.8__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.
@@ -45,6 +45,7 @@ from langtrace_python_sdk.instrumentation import (
45
45
  )
46
46
  from opentelemetry.instrumentation.sqlalchemy import SQLAlchemyInstrumentor
47
47
  from colorama import Fore
48
+ from langtrace_python_sdk.utils import check_if_sdk_is_outdated
48
49
 
49
50
 
50
51
  def init(
@@ -55,6 +56,7 @@ def init(
55
56
  api_host: Optional[str] = None,
56
57
  disable_instrumentations: Optional[DisableInstrumentations] = None,
57
58
  ):
59
+ check_if_sdk_is_outdated()
58
60
  print(Fore.GREEN + "Initializing Langtrace SDK.." + Fore.RESET)
59
61
  provider = TracerProvider(resource=Resource.create({"service.name": sys.argv[0]}))
60
62
 
@@ -1,5 +1,13 @@
1
+ from .sdk_version_checker import SDKVersionChecker
2
+
3
+
1
4
  def set_span_attribute(span, name, value):
2
5
  if value is not None:
3
6
  if value != "":
4
7
  span.set_attribute(name, value)
5
8
  return
9
+
10
+
11
+ def check_if_sdk_is_outdated():
12
+ SDKVersionChecker().check()
13
+ return
@@ -0,0 +1,48 @@
1
+ from importlib.metadata import version
2
+ import time
3
+ import requests
4
+ from colorama import Fore
5
+
6
+
7
+ class SDKVersionChecker:
8
+ _cache: None
9
+ _cache_duration: int
10
+ _current_version: str
11
+ _latest_version: str
12
+
13
+ def __init__(self):
14
+ self._cache = {"timestamp": 0, "latest_version": None}
15
+ self._cache_duration = 3600 # Cache for 1 hour
16
+ self._current_version = version("langtrace_python_sdk")
17
+
18
+ def fetch_latest(self):
19
+ current_time = time.time()
20
+ if (
21
+ current_time - self._cache["timestamp"] < self._cache_duration
22
+ and self._cache["latest_version"]
23
+ ):
24
+ return self._cache["latest_version"]
25
+
26
+ response = requests.get(
27
+ "https://api.github.com/repos/Scale3-Labs/langtrace-python-sdk/releases/latest",
28
+ timeout=20,
29
+ )
30
+ response.raise_for_status()
31
+ latest_version = response.json()["tag_name"]
32
+ self._cache.update(
33
+ {"timestamp": current_time, "latest_version": latest_version}
34
+ )
35
+ self._latest_version = latest_version
36
+ return latest_version
37
+
38
+ def is_outdated(self):
39
+ latest_version = self.fetch_latest()
40
+ return self._current_version < latest_version
41
+
42
+ def check(self):
43
+ if self.is_outdated():
44
+ print(
45
+ Fore.YELLOW
46
+ + f"Warning: Your Langtrace SDK version {self._current_version} is outdated. Please upgrade to {self._latest_version}."
47
+ + Fore.RESET
48
+ )
@@ -1 +1 @@
1
- __version__ = "2.1.7"
1
+ __version__ = "2.1.8"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: langtrace-python-sdk
3
- Version: 2.1.7
3
+ Version: 2.1.8
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>
@@ -37,8 +37,8 @@ examples/qdrant_example/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG
37
37
  examples/qdrant_example/basic.py,sha256=DCMjHSuBZKkhEjCkwy5d5La9WMyW0lCWqtcZWiFCEm4,1425
38
38
  examples/weaviate_example/query_text.py,sha256=iE9OiHsibjsprbCGzabE03eZsGN06e6ym2iS1A9P3ig,64650
39
39
  langtrace_python_sdk/__init__.py,sha256=R4dv73QARUw4WRfCdSKkKzZTLDumF9jcSdwtVrzWhb4,962
40
- langtrace_python_sdk/langtrace.py,sha256=h168V4kyqSezozDnMVar2Xgbi764WvVA_PpSgVuBzz0,6560
41
- langtrace_python_sdk/version.py,sha256=f8a2MVmX1Pzg6y0vb9wOlUWlRzaM1t0oaZBemKhaz6M,22
40
+ langtrace_python_sdk/langtrace.py,sha256=_qJsbLo-4GqhXd8apg3W7A_l3ZnFYEX1wOA-_rg-TZA,6655
41
+ langtrace_python_sdk/version.py,sha256=Zs7yBsCpiMSJW2PP_mZoH_3cEDqJwh80ulBcmuMBwMU,22
42
42
  langtrace_python_sdk/constants/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
43
43
  langtrace_python_sdk/constants/exporter/langtrace_exporter.py,sha256=5MNjnAOg-4am78J3gVMH6FSwq5N8TOj72ugkhsw4vi0,46
44
44
  langtrace_python_sdk/constants/instrumentation/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -94,10 +94,11 @@ langtrace_python_sdk/instrumentation/weaviate/__init__.py,sha256=Mc-Je6evPo-kKQz
94
94
  langtrace_python_sdk/instrumentation/weaviate/instrumentation.py,sha256=Dn2wMj__nNZkUtDw_jEYslE8-bz2KGkdAU_t8qzWjuA,2281
95
95
  langtrace_python_sdk/instrumentation/weaviate/patch.py,sha256=ig2fc33hNydEcH5cJWRycFnMXiXiJr731J-Vg5Ze4No,5634
96
96
  langtrace_python_sdk/types/__init__.py,sha256=-j8cuz3bhUdOqj7N2c0w5y-j3UmcxwEgNh8BWeXwHoI,813
97
- langtrace_python_sdk/utils/__init__.py,sha256=MbBqT4NpDCNTqqvZ0lG4tRiFFZ-tlM8Dwophg4xyrRw,148
97
+ langtrace_python_sdk/utils/__init__.py,sha256=E0nQyBE-4O_GR2PM9y_l7shx4hJLo5xRThR_LMx97M0,278
98
98
  langtrace_python_sdk/utils/llm.py,sha256=CiASOvObFvsN6T7ogWywNXfXGzI__u9misgolLxyeZk,2161
99
99
  langtrace_python_sdk/utils/misc.py,sha256=CD9NWRLxLpFd0YwlHJqzlpFNedXVWtAKGOjQWnDCo8k,838
100
100
  langtrace_python_sdk/utils/prompt_registry.py,sha256=7FFB4Pj0414qgf02h5zL5vXBZgNBf74g4Iq7GdFaIO0,2689
101
+ langtrace_python_sdk/utils/sdk_version_checker.py,sha256=_ZqW7y-aP5qddbObbM_gMlmhCZbnIH83C1pa_KN8glE,1523
101
102
  langtrace_python_sdk/utils/silently_fail.py,sha256=F_9EteXCO9Cyq-8MA1OT2Zy_dx8n06nt31I7t7ui24E,478
102
103
  langtrace_python_sdk/utils/types.py,sha256=l-N6o7cnWUyrD6dBvW7W3Pf5CkPo5QaoT__k1XLbrQg,383
103
104
  langtrace_python_sdk/utils/with_root_span.py,sha256=rSPrTnKndJo6cFUWL4907IkJFbtLwqMS87paADUxD6A,5957
@@ -137,7 +138,7 @@ tests/pinecone/cassettes/test_query.yaml,sha256=b5v9G3ssUy00oG63PlFUR3JErF2Js-5A
137
138
  tests/pinecone/cassettes/test_upsert.yaml,sha256=neWmQ1v3d03V8WoLl8FoFeeCYImb8pxlJBWnFd_lITU,38607
138
139
  tests/qdrant/conftest.py,sha256=9n0uHxxIjWk9fbYc4bx-uP8lSAgLBVx-cV9UjnsyCHM,381
139
140
  tests/qdrant/test_qdrant.py,sha256=pzjAjVY2kmsmGfrI2Gs2xrolfuaNHz7l1fqGQCjp5_o,3353
140
- langtrace_python_sdk-2.1.7.dist-info/METADATA,sha256=H9c6_Gh8svD7ffbYCi3WSUEBItnwNzyX_CPpVf4Bueg,11859
141
- langtrace_python_sdk-2.1.7.dist-info/WHEEL,sha256=zEMcRr9Kr03x1ozGwg5v9NQBKn3kndp6LSoSlVg-jhU,87
142
- langtrace_python_sdk-2.1.7.dist-info/licenses/LICENSE,sha256=QwcOLU5TJoTeUhuIXzhdCEEDDvorGiC6-3YTOl4TecE,11356
143
- langtrace_python_sdk-2.1.7.dist-info/RECORD,,
141
+ langtrace_python_sdk-2.1.8.dist-info/METADATA,sha256=ZvEU8PvKSRRRttRHq2cOPOlMDWFjA9PS3k3zjhJgnCY,11859
142
+ langtrace_python_sdk-2.1.8.dist-info/WHEEL,sha256=zEMcRr9Kr03x1ozGwg5v9NQBKn3kndp6LSoSlVg-jhU,87
143
+ langtrace_python_sdk-2.1.8.dist-info/licenses/LICENSE,sha256=QwcOLU5TJoTeUhuIXzhdCEEDDvorGiC6-3YTOl4TecE,11356
144
+ langtrace_python_sdk-2.1.8.dist-info/RECORD,,