langtrace-python-sdk 1.2.6__py3-none-any.whl → 1.2.7__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.
@@ -0,0 +1 @@
1
+ LANGTRACE_REMOTE_URL = "https://app.langtrace.ai/api/trace"
@@ -2,9 +2,11 @@ import json
2
2
  import os
3
3
  import typing
4
4
 
5
+ from langtrace_python_sdk.constants.exporter.langtrace_exporter import (
6
+ LANGTRACE_REMOTE_URL,
7
+ )
5
8
  import requests
6
- from opentelemetry.sdk.trace.export import (ReadableSpan, SpanExporter,
7
- SpanExportResult)
9
+ from opentelemetry.sdk.trace.export import ReadableSpan, SpanExporter, SpanExportResult
8
10
  from opentelemetry.trace.span import format_trace_id
9
11
 
10
12
 
@@ -22,7 +24,6 @@ class LangTraceExporter(SpanExporter):
22
24
  **Attributes:**
23
25
 
24
26
  * `api_key` (str): An API key to authenticate with the LangTrace collector (required).
25
- * `url` (str): The URL of the LangTrace collector endpoint (required if `write_to_remote_url` is True).
26
27
  * `write_to_remote_url` (bool): A flag indicating whether to send spans to the remote URL (defaults to False).
27
28
 
28
29
  **Methods:**
@@ -46,22 +47,15 @@ class LangTraceExporter(SpanExporter):
46
47
  """
47
48
 
48
49
  api_key: str
49
- url: str
50
50
  write_to_remote_url: bool
51
51
 
52
- def __init__(
53
- self, api_key: str = None, url: str = None, write_to_remote_url: bool = False
54
- ) -> None:
55
- self.api_key = api_key if api_key else os.environ.get("API_KEY")
56
- self.url = url if url else os.environ.get("URL")
52
+ def __init__(self, api_key: str = None, write_to_remote_url: bool = False) -> None:
53
+ self.api_key = api_key if api_key else os.environ.get("LANGTRACE_API_KEY")
57
54
  self.write_to_remote_url = write_to_remote_url
58
55
 
59
56
  if self.write_to_remote_url and not self.api_key:
60
57
  raise ValueError("No API key provided")
61
58
 
62
- if self.write_to_remote_url and not self.url:
63
- raise ValueError("No URL provided")
64
-
65
59
  def export(self, spans: typing.Sequence[ReadableSpan]) -> SpanExportResult:
66
60
  """
67
61
  Exports a batch of telemetry data.
@@ -92,11 +86,11 @@ class LangTraceExporter(SpanExporter):
92
86
  # Send data to remote URL
93
87
  try:
94
88
  requests.post(
95
- url=self.url,
89
+ url=LANGTRACE_REMOTE_URL,
96
90
  data=json.dumps(data),
97
91
  headers={"Content-Type": "application/json", "x-api-key": self.api_key},
98
92
  )
99
- print(f"Traces sent To {self.url}")
93
+ print(f"Traces sent To {LANGTRACE_REMOTE_URL}")
100
94
  return SpanExportResult.SUCCESS
101
95
  except Exception as e:
102
96
  print("Error sending data to remote URL", e)
@@ -37,17 +37,19 @@ def init(
37
37
  api_key: str = None,
38
38
  batch: bool = True,
39
39
  write_to_langtrace_cloud: bool = True,
40
- remote_url: str = None,
41
40
  debug_log_to_console: bool = False,
42
- custom_remote_exporter = None
41
+ custom_remote_exporter=None,
43
42
  ):
44
43
 
45
44
  provider = TracerProvider()
46
45
 
47
- remote_write_exporter = LangTraceExporter(api_key, remote_url, write_to_langtrace_cloud) if custom_remote_exporter is None else custom_remote_exporter
46
+ remote_write_exporter = (
47
+ LangTraceExporter(api_key, write_to_langtrace_cloud)
48
+ if custom_remote_exporter is None
49
+ else custom_remote_exporter
50
+ )
48
51
  console_exporter = ConsoleSpanExporter()
49
52
  batch_processor_remote = BatchSpanProcessor(remote_write_exporter)
50
- simple_processor_remote = SimpleSpanProcessor(remote_write_exporter)
51
53
  batch_processor_console = BatchSpanProcessor(console_exporter)
52
54
  simple_processor_console = SimpleSpanProcessor(console_exporter)
53
55
 
@@ -1 +1 @@
1
- __version__ = "1.2.6"
1
+ __version__ = "1.2.7"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: langtrace-python-sdk
3
- Version: 1.2.6
3
+ Version: 1.2.7
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>
@@ -14,6 +14,7 @@ Requires-Dist: opentelemetry-api
14
14
  Requires-Dist: opentelemetry-instrumentation
15
15
  Requires-Dist: opentelemetry-sdk
16
16
  Requires-Dist: pinecone-client
17
+ Requires-Dist: tiktoken
17
18
  Requires-Dist: trace-attributes
18
19
  Provides-Extra: dev
19
20
  Requires-Dist: anthropic; extra == 'dev'
@@ -17,9 +17,10 @@ examples/openai/images_generate.py,sha256=ZioxTuHKE_yYlhpESqXKVzdkiwdegkmLVB7N8T
17
17
  examples/pinecone_example/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
18
18
  examples/pinecone_example/basic.py,sha256=hdV6-5Fmol9zeyFzDtdabD62vkqUJ4lCHG2YcVNpIpI,933
19
19
  langtrace_python_sdk/__init__.py,sha256=SlHg447-nQBbw8exRNJP_OyHUZ39Sldb7aaQ35hIRm8,262
20
- langtrace_python_sdk/langtrace.py,sha256=XS4lhorNLPgsdKB2hTFsHR31_kUgr9cHZTc4dLgJs_g,3251
21
- langtrace_python_sdk/version.py,sha256=vMQK58X8_YZGKzRm0ThvPAKFtpfyejGmUnDrY9RQ13w,22
20
+ langtrace_python_sdk/langtrace.py,sha256=613Cu4_Wx0kmMXlx7xA3ms_wIYso0qP2so0OCqNFBmY,3169
21
+ langtrace_python_sdk/version.py,sha256=49prCLbE3fFzLfxem5rd2dr1iV4_L-bN0N4J7jxU5yA,22
22
22
  langtrace_python_sdk/constants/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
23
+ langtrace_python_sdk/constants/exporter/langtrace_exporter.py,sha256=qicGmyWf0aCb9ki2wmkHOv8rb7TF5o61_rJhjrbHJzs,60
23
24
  langtrace_python_sdk/constants/instrumentation/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
24
25
  langtrace_python_sdk/constants/instrumentation/anthropic.py,sha256=YX3llt3zwDY6XrYk3CB8WEVqgrzRXEw_ffyk56JoF3k,126
25
26
  langtrace_python_sdk/constants/instrumentation/chroma.py,sha256=hiPGYdHS0Yj4Kh3eaYBbuCAl_swqIygu80yFqkOgdak,955
@@ -27,7 +28,7 @@ langtrace_python_sdk/constants/instrumentation/common.py,sha256=6sy6Am2sd-yJ-3ZI
27
28
  langtrace_python_sdk/constants/instrumentation/openai.py,sha256=9VF6ic9Ed3bpSvdp6iNmrpx2Ppo6DPav3hoUcqSQSv0,1048
28
29
  langtrace_python_sdk/constants/instrumentation/pinecone.py,sha256=Xaqqw-xBO0JJLGk75hiCUQGztNm0HiVaLQvjtYK7VJM,472
29
30
  langtrace_python_sdk/extensions/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
30
- langtrace_python_sdk/extensions/langtrace_exporter.py,sha256=6dMS0MjYCmZbuj3CMb94JarR3DYmiHLeN81hXbPsKOA,4320
31
+ langtrace_python_sdk/extensions/langtrace_exporter.py,sha256=7lIsChmQSOWqFxiegNbHEA_rOTpbkm-RBlBYvKIHxg4,4097
31
32
  langtrace_python_sdk/instrumentation/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
32
33
  langtrace_python_sdk/instrumentation/anthropic/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
33
34
  langtrace_python_sdk/instrumentation/anthropic/instrumentation.py,sha256=1shNkDE7Yb-JFVlEZHMcDbJ6zW8SkSFdxf_yFo9wTNA,1101
@@ -56,7 +57,7 @@ langtrace_python_sdk/instrumentation/pinecone/patch.py,sha256=uDKUBjyOVCDL44YxXV
56
57
  langtrace_python_sdk/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
57
58
  langtrace_python_sdk/utils/llm.py,sha256=4z2e-md_ELXCEuOIRVWracR6qH2pmsOxCqpkuF9_3Nw,1589
58
59
  langtrace_python_sdk/utils/with_root_span.py,sha256=LgFVwHq7KZ6sj2d783NZXr2fFWqI1rqVWSjJR68Ad1E,1044
59
- langtrace_python_sdk-1.2.6.dist-info/METADATA,sha256=T_lC4-Z8756LuXKbG8PlDTSh7rynBD1jWxQe9EW10Wk,2773
60
- langtrace_python_sdk-1.2.6.dist-info/WHEEL,sha256=uNdcs2TADwSd5pVaP0Z_kcjcvvTUklh2S7bxZMF8Uj0,87
61
- langtrace_python_sdk-1.2.6.dist-info/licenses/LICENSE,sha256=VD-pauwiiia-Xi2zgKvalKRIFSJJjqRCQw6aIpK2T9U,33892
62
- langtrace_python_sdk-1.2.6.dist-info/RECORD,,
60
+ langtrace_python_sdk-1.2.7.dist-info/METADATA,sha256=3d6MLApnY3VbhG1KA64XtybUMsknp5qsJcNvqQBnsfI,2797
61
+ langtrace_python_sdk-1.2.7.dist-info/WHEEL,sha256=uNdcs2TADwSd5pVaP0Z_kcjcvvTUklh2S7bxZMF8Uj0,87
62
+ langtrace_python_sdk-1.2.7.dist-info/licenses/LICENSE,sha256=VD-pauwiiia-Xi2zgKvalKRIFSJJjqRCQw6aIpK2T9U,33892
63
+ langtrace_python_sdk-1.2.7.dist-info/RECORD,,