langtrace-python-sdk 2.2.22__py3-none-any.whl → 2.2.23__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:
@@ -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.23"
@@ -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.23
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=Q8BkngWSfGy5JQxcAsViGql-GdawCdx5vm_X4sj0nJc,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
@@ -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.23.dist-info/METADATA,sha256=x2GEjOIpSYOL_HIP8dzQYBMEU8AYVsJ3QE7Gn-KfIvU,14705
204
+ langtrace_python_sdk-2.2.23.dist-info/WHEEL,sha256=1yFddiXMmvYK7QYTqtRNtX66WJ0Mz8PYEiEUoOUUxRY,87
205
+ langtrace_python_sdk-2.2.23.dist-info/entry_points.txt,sha256=1_b9-qvf2fE7uQNZcbUei9vLpFZBbbh9LrtGw95ssAo,70
206
+ langtrace_python_sdk-2.2.23.dist-info/licenses/LICENSE,sha256=QwcOLU5TJoTeUhuIXzhdCEEDDvorGiC6-3YTOl4TecE,11356
207
+ langtrace_python_sdk-2.2.23.dist-info/RECORD,,