langtrace-python-sdk 2.2.22__py3-none-any.whl → 2.2.24__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,6 +1,7 @@
1
1
  import json
2
2
  import os
3
3
  import typing
4
+ import sys
4
5
 
5
6
  import requests
6
7
  from opentelemetry.sdk.trace.export import ReadableSpan, SpanExporter, SpanExportResult
@@ -49,11 +50,13 @@ class LangTraceExporter(SpanExporter):
49
50
 
50
51
  api_key: str
51
52
  api_host: str
53
+ disable_logging: bool
52
54
 
53
55
  def __init__(
54
56
  self,
55
57
  api_host,
56
58
  api_key: str = None,
59
+ disable_logging: bool = False,
57
60
  ) -> None:
58
61
  self.api_key = api_key or os.environ.get("LANGTRACE_API_KEY")
59
62
  self.api_host = (
@@ -61,6 +64,7 @@ class LangTraceExporter(SpanExporter):
61
64
  if api_host == LANGTRACE_REMOTE_URL
62
65
  else api_host
63
66
  )
67
+ self.disable_logging = disable_logging
64
68
 
65
69
  def export(self, spans: typing.Sequence[ReadableSpan]) -> SpanExportResult:
66
70
  """
@@ -72,7 +76,7 @@ class LangTraceExporter(SpanExporter):
72
76
  Returns:
73
77
  The result of the export SUCCESS or FAILURE
74
78
  """
75
- if not self.api_key:
79
+ if not self.api_key and not self.disable_logging:
76
80
  print(Fore.RED)
77
81
  print(
78
82
  "Missing Langtrace API key, proceed to https://langtrace.ai to create one"
@@ -107,14 +111,15 @@ class LangTraceExporter(SpanExporter):
107
111
 
108
112
  if not response.ok:
109
113
  raise RequestException(response.text)
110
-
111
- print(
112
- Fore.GREEN + f"Exported {len(spans)} spans successfully." + Fore.RESET
113
- )
114
+ if not self.disable_logging:
115
+ print(
116
+ Fore.GREEN + f"Exported {len(spans)} spans successfully." + Fore.RESET
117
+ )
114
118
  return SpanExportResult.SUCCESS
115
119
  except RequestException as err:
116
- print(Fore.RED + "Failed to export spans.")
117
- print(Fore.RED + f"Error: {err}" + Fore.RESET)
120
+ if not self.disable_logging:
121
+ print(Fore.RED + "Failed to export spans.")
122
+ print(Fore.RED + f"Error: {err}" + Fore.RESET)
118
123
  return SpanExportResult.FAILURE
119
124
 
120
125
  def shutdown(self) -> None:
@@ -23,7 +23,6 @@ from langtrace_python_sdk.utils.llm import (
23
23
  get_llm_url,
24
24
  get_span_name,
25
25
  set_event_completion,
26
- set_event_completion_chunk,
27
26
  set_usage_attributes,
28
27
  )
29
28
  from langtrace.trace_attributes import Event, LLMSpanAttributes
@@ -13,7 +13,6 @@ from langtrace_python_sdk.utils.llm import (
13
13
  get_span_name,
14
14
  is_streaming,
15
15
  set_event_completion,
16
- set_event_completion_chunk,
17
16
  set_span_attributes,
18
17
  set_usage_attributes,
19
18
  )
@@ -156,7 +155,6 @@ def build_streaming_response(span, response):
156
155
  item_to_yield = item
157
156
  complete_response += str(item.text)
158
157
  yield item_to_yield
159
- set_event_completion_chunk(span, item.text)
160
158
  if hasattr(item, "usage_metadata"):
161
159
  usage = item.usage_metadata
162
160
  input_tokens = usage.prompt_token_count
@@ -176,7 +174,6 @@ async def abuild_streaming_response(span, response):
176
174
  item_to_yield = item
177
175
  complete_response += str(item.text)
178
176
  yield item_to_yield
179
- set_event_completion_chunk(span, item.text)
180
177
  if hasattr(item, "usage_metadata"):
181
178
  usage = item.usage_metadata
182
179
  input_tokens = usage.prompt_token_count
@@ -31,7 +31,6 @@ from langtrace_python_sdk.utils.llm import (
31
31
  get_langtrace_attributes,
32
32
  get_span_name,
33
33
  set_event_completion,
34
- set_event_completion_chunk,
35
34
  set_usage_attributes,
36
35
  )
37
36
  from langtrace_python_sdk.constants.instrumentation.common import (
@@ -245,14 +244,6 @@ def chat_completions_create(original_method, version, tracer):
245
244
  else:
246
245
  content = []
247
246
 
248
- set_event_completion_chunk(
249
- span,
250
- (
251
- "".join(content)
252
- if len(content) > 0 and content[0] is not None
253
- else ""
254
- ),
255
- )
256
247
  result_content.append(content[0] if len(content) > 0 else "")
257
248
  yield chunk
258
249
  finally:
@@ -8,7 +8,6 @@ from langtrace_python_sdk.utils.llm import (
8
8
  get_llm_url,
9
9
  get_span_name,
10
10
  set_event_completion,
11
- set_event_completion_chunk,
12
11
  )
13
12
  from langtrace_python_sdk.utils.silently_fail import silently_fail
14
13
  from langtrace_python_sdk.constants.instrumentation.common import SERVICE_PROVIDERS
@@ -72,7 +72,10 @@ def init(
72
72
  disable_instrumentations: Optional[DisableInstrumentations] = None,
73
73
  disable_tracing_for_functions: Optional[InstrumentationMethods] = None,
74
74
  service_name: Optional[str] = None,
75
+ disable_logging = False
75
76
  ):
77
+ if disable_logging:
78
+ sys.stdout = open(os.devnull, "w")
76
79
 
77
80
  host = (
78
81
  os.environ.get("LANGTRACE_API_HOST", None) or api_host or LANGTRACE_REMOTE_URL
@@ -90,7 +93,7 @@ def init(
90
93
  provider = TracerProvider(resource=resource, sampler=sampler)
91
94
 
92
95
  remote_write_exporter = (
93
- LangTraceExporter(api_key=api_key, api_host=host)
96
+ LangTraceExporter(api_key=api_key, api_host=host, disable_logging=disable_logging)
94
97
  if custom_remote_exporter is None
95
98
  else custom_remote_exporter
96
99
  )
@@ -146,6 +149,8 @@ def init(
146
149
  print(Fore.BLUE + "Exporting spans to Langtrace cloud.." + Fore.RESET)
147
150
  provider.add_span_processor(batch_processor_remote)
148
151
 
152
+ sys.stdout = sys.__stdout__
153
+
149
154
 
150
155
  def init_instrumentations(
151
156
  disable_instrumentations: DisableInstrumentations, all_instrumentations: dict
@@ -1 +1 @@
1
- __version__ = "2.2.22"
1
+ __version__ = "2.2.24"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: langtrace-python-sdk
3
- Version: 2.2.22
3
+ Version: 2.2.24
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>
@@ -73,8 +73,8 @@ examples/vertexai_example/main.py,sha256=gndId5X5ksD-ycxnAWMdEqIDbLc3kz5Vt8vm4YP
73
73
  examples/weaviate_example/__init__.py,sha256=8JMDBsRSEV10HfTd-YC7xb4txBjD3la56snk-Bbg2Kw,618
74
74
  examples/weaviate_example/query_text.py,sha256=sG8O-bXQpflBAiYpgE_M2X7GcHUlZNgl_wJW8_h-W6Q,127024
75
75
  langtrace_python_sdk/__init__.py,sha256=VZM6i71NR7pBQK6XvJWRelknuTYUhqwqE7PlicKa5Wg,1166
76
- langtrace_python_sdk/langtrace.py,sha256=hh3okJYyxXvC9TMm_vaFOGz-5TxxJp1zQDmZmy63aRY,7813
77
- langtrace_python_sdk/version.py,sha256=pX8tRH0Idy_gR6E_Dzk1LImPGfPmc0Pkc62fJ617lUk,23
76
+ langtrace_python_sdk/langtrace.py,sha256=5BL5lNZejLRq9AVuOCjFaPpIkFNUh2vLvlGSGVxUlE4,7974
77
+ langtrace_python_sdk/version.py,sha256=n8FieBUcrlslt3wDEzcByvZRql2CrZ3Use6OmcxZsKg,23
78
78
  langtrace_python_sdk/constants/__init__.py,sha256=P8QvYwt5czUNDZsKS64vxm9Dc41ptGbuF1TFtAF6nv4,44
79
79
  langtrace_python_sdk/constants/exporter/langtrace_exporter.py,sha256=5MNjnAOg-4am78J3gVMH6FSwq5N8TOj72ugkhsw4vi0,46
80
80
  langtrace_python_sdk/constants/instrumentation/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -91,7 +91,7 @@ langtrace_python_sdk/constants/instrumentation/qdrant.py,sha256=yL7BopNQTXW7L7Z-
91
91
  langtrace_python_sdk/constants/instrumentation/vertexai.py,sha256=0s2vX3Y0iwjOPkUg5lAKi-7o3LaNivDSBBbF-o695Ok,1266
92
92
  langtrace_python_sdk/constants/instrumentation/weaviate.py,sha256=gtv-JBxvNGClEMxClmRKzjJ1khgOonsli4D_k9IagSE,2601
93
93
  langtrace_python_sdk/extensions/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
94
- langtrace_python_sdk/extensions/langtrace_exporter.py,sha256=gTdmje-q5DGYNl2S6tmVnGPHj_nZNiCB3tux9RWDiYM,4316
94
+ langtrace_python_sdk/extensions/langtrace_exporter.py,sha256=_GIH4zP9lpk8UO81zBJ_9HklNszg1bsndqqXwcVe2rY,4569
95
95
  langtrace_python_sdk/extensions/langtrace_filesystem.py,sha256=34fZutG28EJ66l67OvTGsydAH3ZpXgikdE7hVLqBpG4,7863
96
96
  langtrace_python_sdk/instrumentation/__init__.py,sha256=yJd3aGu4kPfm2h6oe6kiCWvzTF9awpC1UztjXF9WSO4,1391
97
97
  langtrace_python_sdk/instrumentation/anthropic/__init__.py,sha256=donrurJAGYlxrSRA3BIf76jGeUcAx9Tq8CVpah68S0Y,101
@@ -102,7 +102,7 @@ langtrace_python_sdk/instrumentation/chroma/instrumentation.py,sha256=nT6PS6bsrI
102
102
  langtrace_python_sdk/instrumentation/chroma/patch.py,sha256=1jCbyum11ifbQFLO43eg0yW33Yc7NI_fwhRf1gspHcM,9087
103
103
  langtrace_python_sdk/instrumentation/cohere/__init__.py,sha256=sGUSLdTUyYf36Tm6L5jQflhzCqvmWrhnBOMYHjvp6Hs,95
104
104
  langtrace_python_sdk/instrumentation/cohere/instrumentation.py,sha256=YQFHZIBd7SSPD4b6Va-ZR0thf_AuBCqj5yzHLHJVWnM,2121
105
- langtrace_python_sdk/instrumentation/cohere/patch.py,sha256=Mv9mk3HBdMYsartyYzqsGPkY791LkEoigyShaQBM0xk,21004
105
+ langtrace_python_sdk/instrumentation/cohere/patch.py,sha256=Yb0OwxO4gG-WBfGhTFrwUUJEgpnRlyWI_FZveA4T1QU,20972
106
106
  langtrace_python_sdk/instrumentation/crewai/__init__.py,sha256=_UBKfvQv7l0g2_wnmA5F6CdSAFH0atNOVPd49zsN3aM,88
107
107
  langtrace_python_sdk/instrumentation/crewai/instrumentation.py,sha256=q07x6nnig9JPxDT6ZylyIShfXWjNafKBetnNcA1UdEU,1836
108
108
  langtrace_python_sdk/instrumentation/crewai/patch.py,sha256=4W7jEIJX4SJNViPlFTBJdSkvvPVJoI76Bb5DX673Ql8,6203
@@ -111,10 +111,10 @@ langtrace_python_sdk/instrumentation/dspy/instrumentation.py,sha256=o8URiDvCbZ8L
111
111
  langtrace_python_sdk/instrumentation/dspy/patch.py,sha256=E2P3MJBQ71or4M6BsvZOwYFtJK1UdTsYkdxVj9fSWPs,9869
112
112
  langtrace_python_sdk/instrumentation/gemini/__init__.py,sha256=ilWmKA4Li-g3DX6R10WQ4v-51VljxToEnJpOQoQB5uQ,88
113
113
  langtrace_python_sdk/instrumentation/gemini/instrumentation.py,sha256=eGWr2dy1f_9TVZiXSH_MlNQINyS4I28EsOTKREdMVio,1304
114
- langtrace_python_sdk/instrumentation/gemini/patch.py,sha256=WIeZdge0uiWvzJ9HR2KHYyTYO6NpLjQwtjueq8lB8lA,6364
114
+ langtrace_python_sdk/instrumentation/gemini/patch.py,sha256=Zedp4bZH3-45LOaieSGyoTffgWJjqLs1YCDwM53v2CI,6228
115
115
  langtrace_python_sdk/instrumentation/groq/__init__.py,sha256=ZXeq_nrej6Lm_uoMFEg8wbSejhjB2UJ5IoHQBPc2-C0,91
116
116
  langtrace_python_sdk/instrumentation/groq/instrumentation.py,sha256=Ttf07XVKhdYY1_fqJc7QWiSdmgEhEVyQB_3Az2_wqYo,1832
117
- langtrace_python_sdk/instrumentation/groq/patch.py,sha256=pffttsSPgsvKxaWKd3y2RSzJQ8wRoLFO7SfsQ9vc93k,23813
117
+ langtrace_python_sdk/instrumentation/groq/patch.py,sha256=SmpsNVQyRcsvdh2fCKHsQ-EWsauMV972s99hznuNOjk,23504
118
118
  langtrace_python_sdk/instrumentation/langchain/__init__.py,sha256=-7ZkqQFu64F-cxSFd1ZPrciODKqmUIyUbQQ-eHuQPyM,101
119
119
  langtrace_python_sdk/instrumentation/langchain/instrumentation.py,sha256=_Z4AeNb2hBPSCvMRxE-mUfmkUO_wP_tGGtu-jppWPiI,3462
120
120
  langtrace_python_sdk/instrumentation/langchain/patch.py,sha256=BmVBKPpI4P9AX6Y8e67WYSz0a0rxZK7cJkI75ure2f4,4166
@@ -132,7 +132,7 @@ langtrace_python_sdk/instrumentation/llamaindex/instrumentation.py,sha256=8iAg-O
132
132
  langtrace_python_sdk/instrumentation/llamaindex/patch.py,sha256=548hzPyT_k-2wmt9AArv4JzTT4j4AGKJq5Ar2bWv7o8,4615
133
133
  langtrace_python_sdk/instrumentation/ollama/__init__.py,sha256=g2zJsXnDHinXPzTc-WxDeTtHmr9gmAj3K6l_00kP8c8,82
134
134
  langtrace_python_sdk/instrumentation/ollama/instrumentation.py,sha256=jdsvkqUJAAUNLVPtAkn_rG26HXetVQXWtjn4a6eWZro,2029
135
- langtrace_python_sdk/instrumentation/ollama/patch.py,sha256=5Y_pPVh1Pt8BcxyCiJWex3oNqYTcuOo5udh1-jNsCO0,5407
135
+ langtrace_python_sdk/instrumentation/ollama/patch.py,sha256=7ETx0tQic5h_kH1f-IeptFwgNTBb4hSkTkWsB18Avm0,5375
136
136
  langtrace_python_sdk/instrumentation/openai/__init__.py,sha256=VPHRNCQEdkizIVP2d0Uw_a7t8XOTSTprEIB8oboJFbs,95
137
137
  langtrace_python_sdk/instrumentation/openai/instrumentation.py,sha256=A0BJHRLcZ74TNVg6I0I9M5YWvSpAtXwMmME6N5CEQ_M,2945
138
138
  langtrace_python_sdk/instrumentation/openai/patch.py,sha256=4GCYJzZdUBopEDinpTwRBFf-Enb0hdNO16LiiMKqqvY,24226
@@ -200,8 +200,8 @@ tests/pinecone/cassettes/test_query.yaml,sha256=b5v9G3ssUy00oG63PlFUR3JErF2Js-5A
200
200
  tests/pinecone/cassettes/test_upsert.yaml,sha256=neWmQ1v3d03V8WoLl8FoFeeCYImb8pxlJBWnFd_lITU,38607
201
201
  tests/qdrant/conftest.py,sha256=9n0uHxxIjWk9fbYc4bx-uP8lSAgLBVx-cV9UjnsyCHM,381
202
202
  tests/qdrant/test_qdrant.py,sha256=pzjAjVY2kmsmGfrI2Gs2xrolfuaNHz7l1fqGQCjp5_o,3353
203
- langtrace_python_sdk-2.2.22.dist-info/METADATA,sha256=W2LdIpHk8FHlmtYVmgri3pLmJDK9D2Dq9mpBq15XYaw,14705
204
- langtrace_python_sdk-2.2.22.dist-info/WHEEL,sha256=1yFddiXMmvYK7QYTqtRNtX66WJ0Mz8PYEiEUoOUUxRY,87
205
- langtrace_python_sdk-2.2.22.dist-info/entry_points.txt,sha256=1_b9-qvf2fE7uQNZcbUei9vLpFZBbbh9LrtGw95ssAo,70
206
- langtrace_python_sdk-2.2.22.dist-info/licenses/LICENSE,sha256=QwcOLU5TJoTeUhuIXzhdCEEDDvorGiC6-3YTOl4TecE,11356
207
- langtrace_python_sdk-2.2.22.dist-info/RECORD,,
203
+ langtrace_python_sdk-2.2.24.dist-info/METADATA,sha256=2olUyDmzSjSowAHqjoWmRHZzaN4vcDcyYP6kjukVWQE,14705
204
+ langtrace_python_sdk-2.2.24.dist-info/WHEEL,sha256=1yFddiXMmvYK7QYTqtRNtX66WJ0Mz8PYEiEUoOUUxRY,87
205
+ langtrace_python_sdk-2.2.24.dist-info/entry_points.txt,sha256=1_b9-qvf2fE7uQNZcbUei9vLpFZBbbh9LrtGw95ssAo,70
206
+ langtrace_python_sdk-2.2.24.dist-info/licenses/LICENSE,sha256=QwcOLU5TJoTeUhuIXzhdCEEDDvorGiC6-3YTOl4TecE,11356
207
+ langtrace_python_sdk-2.2.24.dist-info/RECORD,,