lmnr 0.4.50__tar.gz → 0.4.51__tar.gz

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.
Files changed (33) hide show
  1. {lmnr-0.4.50 → lmnr-0.4.51}/PKG-INFO +55 -29
  2. lmnr-0.4.51/pyproject.toml +116 -0
  3. {lmnr-0.4.50 → lmnr-0.4.51}/src/lmnr/openllmetry_sdk/__init__.py +0 -2
  4. {lmnr-0.4.50 → lmnr-0.4.51}/src/lmnr/openllmetry_sdk/decorators/base.py +4 -14
  5. {lmnr-0.4.50 → lmnr-0.4.51}/src/lmnr/openllmetry_sdk/tracing/tracing.py +21 -16
  6. {lmnr-0.4.50 → lmnr-0.4.51}/src/lmnr/sdk/datasets.py +0 -1
  7. {lmnr-0.4.50 → lmnr-0.4.51}/src/lmnr/sdk/laminar.py +16 -13
  8. lmnr-0.4.50/pyproject.toml +0 -149
  9. {lmnr-0.4.50 → lmnr-0.4.51}/LICENSE +0 -0
  10. {lmnr-0.4.50 → lmnr-0.4.51}/README.md +0 -0
  11. {lmnr-0.4.50 → lmnr-0.4.51}/src/lmnr/__init__.py +0 -0
  12. {lmnr-0.4.50 → lmnr-0.4.51}/src/lmnr/cli.py +0 -0
  13. {lmnr-0.4.50 → lmnr-0.4.51}/src/lmnr/openllmetry_sdk/.flake8 +0 -0
  14. {lmnr-0.4.50 → lmnr-0.4.51}/src/lmnr/openllmetry_sdk/.python-version +0 -0
  15. {lmnr-0.4.50 → lmnr-0.4.51}/src/lmnr/openllmetry_sdk/config/__init__.py +0 -0
  16. {lmnr-0.4.50 → lmnr-0.4.51}/src/lmnr/openllmetry_sdk/decorators/__init__.py +0 -0
  17. {lmnr-0.4.50 → lmnr-0.4.51}/src/lmnr/openllmetry_sdk/instruments.py +0 -0
  18. {lmnr-0.4.50 → lmnr-0.4.51}/src/lmnr/openllmetry_sdk/tracing/__init__.py +0 -0
  19. {lmnr-0.4.50 → lmnr-0.4.51}/src/lmnr/openllmetry_sdk/tracing/attributes.py +0 -0
  20. {lmnr-0.4.50 → lmnr-0.4.51}/src/lmnr/openllmetry_sdk/tracing/content_allow_list.py +0 -0
  21. {lmnr-0.4.50 → lmnr-0.4.51}/src/lmnr/openllmetry_sdk/tracing/context_manager.py +0 -0
  22. {lmnr-0.4.50 → lmnr-0.4.51}/src/lmnr/openllmetry_sdk/utils/__init__.py +0 -0
  23. {lmnr-0.4.50 → lmnr-0.4.51}/src/lmnr/openllmetry_sdk/utils/in_memory_span_exporter.py +0 -0
  24. {lmnr-0.4.50 → lmnr-0.4.51}/src/lmnr/openllmetry_sdk/utils/json_encoder.py +0 -0
  25. {lmnr-0.4.50 → lmnr-0.4.51}/src/lmnr/openllmetry_sdk/utils/package_check.py +0 -0
  26. {lmnr-0.4.50 → lmnr-0.4.51}/src/lmnr/openllmetry_sdk/version.py +0 -0
  27. {lmnr-0.4.50 → lmnr-0.4.51}/src/lmnr/sdk/__init__.py +0 -0
  28. {lmnr-0.4.50 → lmnr-0.4.51}/src/lmnr/sdk/decorators.py +0 -0
  29. {lmnr-0.4.50 → lmnr-0.4.51}/src/lmnr/sdk/eval_control.py +0 -0
  30. {lmnr-0.4.50 → lmnr-0.4.51}/src/lmnr/sdk/evaluations.py +0 -0
  31. {lmnr-0.4.50 → lmnr-0.4.51}/src/lmnr/sdk/log.py +0 -0
  32. {lmnr-0.4.50 → lmnr-0.4.51}/src/lmnr/sdk/types.py +0 -0
  33. {lmnr-0.4.50 → lmnr-0.4.51}/src/lmnr/sdk/utils.py +0 -0
@@ -1,9 +1,10 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.3
2
2
  Name: lmnr
3
- Version: 0.4.50
4
- Summary: Python SDK for Laminar AI
3
+ Version: 0.4.51
4
+ Summary: Python SDK for Laminar
5
5
  License: Apache-2.0
6
6
  Author: lmnr.ai
7
+ Author-email: founders@lmnr.ai
7
8
  Requires-Python: >=3.9,<4
8
9
  Classifier: License :: OSI Approved :: Apache Software License
9
10
  Classifier: Programming Language :: Python :: 3
@@ -44,37 +45,62 @@ Requires-Dist: deprecated (>=1.0)
44
45
  Requires-Dist: opentelemetry-api (>=1.28.0)
45
46
  Requires-Dist: opentelemetry-exporter-otlp-proto-grpc (>=1.28.0)
46
47
  Requires-Dist: opentelemetry-exporter-otlp-proto-http (>=1.28.0)
47
- Requires-Dist: opentelemetry-instrumentation-alephalpha (>=0.34.0) ; extra == "all" or extra == "alephalpha"
48
- Requires-Dist: opentelemetry-instrumentation-anthropic (>=0.34.0) ; extra == "all" or extra == "anthropic"
49
- Requires-Dist: opentelemetry-instrumentation-bedrock (>=0.34.0) ; extra == "all" or extra == "bedrock"
50
- Requires-Dist: opentelemetry-instrumentation-chromadb (>=0.34.0) ; extra == "all" or extra == "chromadb"
51
- Requires-Dist: opentelemetry-instrumentation-cohere (>=0.34.0) ; extra == "all" or extra == "cohere"
52
- Requires-Dist: opentelemetry-instrumentation-google-generativeai (>=0.34.0) ; extra == "all" or extra == "google-generativeai"
53
- Requires-Dist: opentelemetry-instrumentation-groq (>=0.34.0) ; extra == "all" or extra == "groq"
54
- Requires-Dist: opentelemetry-instrumentation-haystack (>=0.34.0) ; extra == "all" or extra == "haystack"
55
- Requires-Dist: opentelemetry-instrumentation-lancedb (>=0.34.0) ; extra == "all" or extra == "lancedb"
56
- Requires-Dist: opentelemetry-instrumentation-langchain (>=0.34.0) ; extra == "all" or extra == "langchain"
57
- Requires-Dist: opentelemetry-instrumentation-llamaindex (>=0.34.0) ; extra == "all" or extra == "llamaindex"
58
- Requires-Dist: opentelemetry-instrumentation-marqo (>=0.34.0) ; extra == "all" or extra == "marqo"
59
- Requires-Dist: opentelemetry-instrumentation-milvus (>=0.34.0) ; extra == "all" or extra == "milvus"
60
- Requires-Dist: opentelemetry-instrumentation-mistralai (>=0.34.0) ; extra == "all" or extra == "mistralai"
61
- Requires-Dist: opentelemetry-instrumentation-ollama (>=0.34.0) ; extra == "all" or extra == "ollama"
62
- Requires-Dist: opentelemetry-instrumentation-openai (>=0.33.12) ; extra == "all" or extra == "openai"
63
- Requires-Dist: opentelemetry-instrumentation-pinecone (>=0.34.0) ; extra == "all" or extra == "pinecone"
64
- Requires-Dist: opentelemetry-instrumentation-qdrant (>=0.34.0) ; extra == "all" or extra == "qdrant"
65
- Requires-Dist: opentelemetry-instrumentation-replicate (>=0.34.0) ; extra == "all" or extra == "replicate"
48
+ Requires-Dist: opentelemetry-instrumentation-alephalpha (>=0.35.0) ; extra == "alephalpha"
49
+ Requires-Dist: opentelemetry-instrumentation-alephalpha ; extra == "all"
50
+ Requires-Dist: opentelemetry-instrumentation-anthropic (>=0.35.0) ; extra == "anthropic"
51
+ Requires-Dist: opentelemetry-instrumentation-anthropic ; extra == "all"
52
+ Requires-Dist: opentelemetry-instrumentation-bedrock (>=0.35.0) ; extra == "bedrock"
53
+ Requires-Dist: opentelemetry-instrumentation-bedrock ; extra == "all"
54
+ Requires-Dist: opentelemetry-instrumentation-chromadb (>=0.35.0) ; extra == "chromadb"
55
+ Requires-Dist: opentelemetry-instrumentation-chromadb ; extra == "all"
56
+ Requires-Dist: opentelemetry-instrumentation-cohere (>=0.35.0) ; extra == "cohere"
57
+ Requires-Dist: opentelemetry-instrumentation-cohere ; extra == "all"
58
+ Requires-Dist: opentelemetry-instrumentation-google-generativeai (>=0.35.0) ; extra == "google-generativeai"
59
+ Requires-Dist: opentelemetry-instrumentation-google-generativeai ; extra == "all"
60
+ Requires-Dist: opentelemetry-instrumentation-groq (>=0.35.0) ; extra == "groq"
61
+ Requires-Dist: opentelemetry-instrumentation-groq ; extra == "all"
62
+ Requires-Dist: opentelemetry-instrumentation-haystack (>=0.35.0) ; extra == "haystack"
63
+ Requires-Dist: opentelemetry-instrumentation-haystack ; extra == "all"
64
+ Requires-Dist: opentelemetry-instrumentation-lancedb (>=0.35.0) ; extra == "lancedb"
65
+ Requires-Dist: opentelemetry-instrumentation-lancedb ; extra == "all"
66
+ Requires-Dist: opentelemetry-instrumentation-langchain (>=0.35.0) ; extra == "langchain"
67
+ Requires-Dist: opentelemetry-instrumentation-langchain ; extra == "all"
68
+ Requires-Dist: opentelemetry-instrumentation-llamaindex (>=0.35.0) ; extra == "llamaindex"
69
+ Requires-Dist: opentelemetry-instrumentation-llamaindex ; extra == "all"
70
+ Requires-Dist: opentelemetry-instrumentation-marqo (>=0.35.0) ; extra == "marqo"
71
+ Requires-Dist: opentelemetry-instrumentation-marqo ; extra == "all"
72
+ Requires-Dist: opentelemetry-instrumentation-milvus (>=0.35.0) ; extra == "milvus"
73
+ Requires-Dist: opentelemetry-instrumentation-milvus ; extra == "all"
74
+ Requires-Dist: opentelemetry-instrumentation-mistralai (>=0.35.0) ; extra == "mistralai"
75
+ Requires-Dist: opentelemetry-instrumentation-mistralai ; extra == "all"
76
+ Requires-Dist: opentelemetry-instrumentation-ollama (>=0.35.0) ; extra == "ollama"
77
+ Requires-Dist: opentelemetry-instrumentation-ollama ; extra == "all"
78
+ Requires-Dist: opentelemetry-instrumentation-openai (>=0.35.0) ; extra == "openai"
79
+ Requires-Dist: opentelemetry-instrumentation-openai ; extra == "all"
80
+ Requires-Dist: opentelemetry-instrumentation-pinecone (>=0.35.0) ; extra == "pinecone"
81
+ Requires-Dist: opentelemetry-instrumentation-pinecone ; extra == "all"
82
+ Requires-Dist: opentelemetry-instrumentation-qdrant (>=0.35.0) ; extra == "qdrant"
83
+ Requires-Dist: opentelemetry-instrumentation-qdrant ; extra == "all"
84
+ Requires-Dist: opentelemetry-instrumentation-replicate (>=0.35.0) ; extra == "replicate"
85
+ Requires-Dist: opentelemetry-instrumentation-replicate ; extra == "all"
66
86
  Requires-Dist: opentelemetry-instrumentation-requests (>=0.50b0)
67
- Requires-Dist: opentelemetry-instrumentation-sagemaker (>=0.34.0) ; extra == "all" or extra == "sagemaker"
87
+ Requires-Dist: opentelemetry-instrumentation-sagemaker (>=0.35.0) ; extra == "sagemaker"
88
+ Requires-Dist: opentelemetry-instrumentation-sagemaker ; extra == "all"
68
89
  Requires-Dist: opentelemetry-instrumentation-sqlalchemy (>=0.50b0)
69
90
  Requires-Dist: opentelemetry-instrumentation-threading (>=0.50b0)
70
- Requires-Dist: opentelemetry-instrumentation-together (>=0.34.0) ; extra == "all" or extra == "together"
71
- Requires-Dist: opentelemetry-instrumentation-transformers (>=0.34.0) ; extra == "all" or extra == "transformers"
91
+ Requires-Dist: opentelemetry-instrumentation-together (>=0.35.0) ; extra == "together"
92
+ Requires-Dist: opentelemetry-instrumentation-together ; extra == "all"
93
+ Requires-Dist: opentelemetry-instrumentation-transformers (>=0.35.0) ; extra == "transformers"
94
+ Requires-Dist: opentelemetry-instrumentation-transformers ; extra == "all"
72
95
  Requires-Dist: opentelemetry-instrumentation-urllib3 (>=0.50b0)
73
- Requires-Dist: opentelemetry-instrumentation-vertexai (>=0.34.0) ; extra == "all" or extra == "vertexai"
74
- Requires-Dist: opentelemetry-instrumentation-watsonx (>=0.34.0) ; extra == "all" or extra == "watsonx"
75
- Requires-Dist: opentelemetry-instrumentation-weaviate (>=0.34.0) ; extra == "all" or extra == "weaviate"
96
+ Requires-Dist: opentelemetry-instrumentation-vertexai (>=0.35.0) ; extra == "vertexai"
97
+ Requires-Dist: opentelemetry-instrumentation-vertexai ; extra == "all"
98
+ Requires-Dist: opentelemetry-instrumentation-watsonx (>=0.35.0) ; extra == "watsonx"
99
+ Requires-Dist: opentelemetry-instrumentation-watsonx ; extra == "all"
100
+ Requires-Dist: opentelemetry-instrumentation-weaviate (>=0.35.0) ; extra == "weaviate"
101
+ Requires-Dist: opentelemetry-instrumentation-weaviate ; extra == "all"
76
102
  Requires-Dist: opentelemetry-sdk (>=1.28.0)
77
- Requires-Dist: opentelemetry-semantic-conventions-ai (==0.4.2)
103
+ Requires-Dist: opentelemetry-semantic-conventions-ai (>=0.4.2)
78
104
  Requires-Dist: pydantic (>=2.7)
79
105
  Requires-Dist: python-dotenv (>=1.0)
80
106
  Requires-Dist: requests (>=2.0)
@@ -0,0 +1,116 @@
1
+ # Laminar Python
2
+
3
+ # If you are looking for information about possible extras installations,
4
+ # i.e. what you can pass into `pip install 'lmnr[extra1,extra2]'`, please see the
5
+ # `[project.optional-dependencies]` section below.
6
+
7
+ [project]
8
+ name = "lmnr"
9
+ version = "0.4.51"
10
+ description = "Python SDK for Laminar"
11
+ authors = [
12
+ { name = "lmnr.ai", email = "founders@lmnr.ai" }
13
+ ]
14
+ readme = "README.md"
15
+ requires-python = ">=3.9,<4"
16
+ license = "Apache-2.0"
17
+ dependencies = [
18
+ "pydantic (>=2.7)",
19
+ "requests (>=2.0)",
20
+ "python-dotenv (>=1.0)",
21
+ "opentelemetry-api (>=1.28.0)",
22
+ "opentelemetry-sdk (>=1.28.0)",
23
+ "opentelemetry-exporter-otlp-proto-http (>=1.28.0)",
24
+ "opentelemetry-exporter-otlp-proto-grpc (>=1.28.0)",
25
+ "opentelemetry-instrumentation-requests (>=0.50b0)",
26
+ "opentelemetry-instrumentation-sqlalchemy (>=0.50b0)",
27
+ "opentelemetry-instrumentation-urllib3 (>=0.50b0)",
28
+ "opentelemetry-instrumentation-threading (>=0.50b0)",
29
+ "opentelemetry-semantic-conventions-ai (>=0.4.2)",
30
+ "deprecated (>=1.0)",
31
+ "tqdm (>=4.0)",
32
+ "argparse (>=1.0)",
33
+ "aiohttp (>=3.0)",
34
+ "tenacity (>=8.0)",
35
+ ]
36
+
37
+ [project.scripts]
38
+ lmnr = "lmnr.cli:cli"
39
+
40
+ [project.optional-dependencies]
41
+ # List of all possible extras. You can specify one or more of these extras
42
+ # when installing the package, using any of the following examples:
43
+ # `pip install 'lmnr[anthropic,openai]'`
44
+ # `uv pip install 'lmnr[anthropic,openai]'`
45
+ # `uv add lmnr --extra anthropic --extra openai`
46
+ # `poetry add 'lmnr[anthropic,openai]'`
47
+
48
+ alephalpha=["opentelemetry-instrumentation-alephalpha>=0.35.0"]
49
+ anthropic=["opentelemetry-instrumentation-anthropic>=0.35.0"]
50
+ bedrock=["opentelemetry-instrumentation-bedrock>=0.35.0"]
51
+ chromadb=["opentelemetry-instrumentation-chromadb>=0.35.0"]
52
+ cohere=["opentelemetry-instrumentation-cohere>=0.35.0"]
53
+ google-generativeai=["opentelemetry-instrumentation-google-generativeai>=0.35.0"]
54
+ groq=["opentelemetry-instrumentation-groq>=0.35.0"]
55
+ haystack=["opentelemetry-instrumentation-haystack>=0.35.0"]
56
+ lancedb=["opentelemetry-instrumentation-lancedb>=0.35.0"]
57
+ langchain=["opentelemetry-instrumentation-langchain>=0.35.0"]
58
+ llamaindex=["opentelemetry-instrumentation-llamaindex>=0.35.0"]
59
+ marqo=["opentelemetry-instrumentation-marqo>=0.35.0"]
60
+ milvus=["opentelemetry-instrumentation-milvus>=0.35.0"]
61
+ mistralai=["opentelemetry-instrumentation-mistralai>=0.35.0"]
62
+ ollama=["opentelemetry-instrumentation-ollama>=0.35.0"]
63
+ openai=["opentelemetry-instrumentation-openai>=0.35.0"]
64
+ pinecone=["opentelemetry-instrumentation-pinecone>=0.35.0"]
65
+ qdrant=["opentelemetry-instrumentation-qdrant>=0.35.0"]
66
+ replicate=["opentelemetry-instrumentation-replicate>=0.35.0"]
67
+ sagemaker=["opentelemetry-instrumentation-sagemaker>=0.35.0"]
68
+ together=["opentelemetry-instrumentation-together>=0.35.0"]
69
+ transformers=["opentelemetry-instrumentation-transformers>=0.35.0"]
70
+ vertexai=["opentelemetry-instrumentation-vertexai>=0.35.0"]
71
+ watsonx=["opentelemetry-instrumentation-watsonx>=0.35.0"]
72
+ weaviate=["opentelemetry-instrumentation-weaviate>=0.35.0"]
73
+ # `all` is the group added for convenience, if you want to install all
74
+ # the instrumentations.
75
+ all = [
76
+ "opentelemetry-instrumentation-alephalpha",
77
+ "opentelemetry-instrumentation-anthropic",
78
+ "opentelemetry-instrumentation-bedrock",
79
+ "opentelemetry-instrumentation-chromadb",
80
+ "opentelemetry-instrumentation-cohere",
81
+ "opentelemetry-instrumentation-google-generativeai",
82
+ "opentelemetry-instrumentation-groq",
83
+ "opentelemetry-instrumentation-haystack",
84
+ "opentelemetry-instrumentation-lancedb",
85
+ "opentelemetry-instrumentation-langchain",
86
+ "opentelemetry-instrumentation-llamaindex",
87
+ "opentelemetry-instrumentation-marqo",
88
+ "opentelemetry-instrumentation-milvus",
89
+ "opentelemetry-instrumentation-mistralai",
90
+ "opentelemetry-instrumentation-ollama",
91
+ "opentelemetry-instrumentation-openai",
92
+ "opentelemetry-instrumentation-pinecone",
93
+ "opentelemetry-instrumentation-qdrant",
94
+ "opentelemetry-instrumentation-replicate",
95
+ "opentelemetry-instrumentation-sagemaker",
96
+ "opentelemetry-instrumentation-together",
97
+ "opentelemetry-instrumentation-transformers",
98
+ "opentelemetry-instrumentation-vertexai",
99
+ "opentelemetry-instrumentation-watsonx",
100
+ "opentelemetry-instrumentation-weaviate"
101
+ ]
102
+
103
+ # TODO: Migrate these to project section
104
+ [dependency-groups]
105
+ dev = [
106
+ "autopep8",
107
+ "flake8",
108
+ "pytest",
109
+ "pytest-sugar",
110
+ "pytest-asyncio"
111
+ ]
112
+
113
+ [build-system]
114
+ requires = ["poetry-core"]
115
+ build-backend = "poetry.core.masonry.api"
116
+
@@ -1,6 +1,4 @@
1
- import os
2
1
  import sys
3
- from pathlib import Path
4
2
 
5
3
  from typing import Optional, Set
6
4
  from opentelemetry.sdk.trace import SpanProcessor
@@ -12,8 +12,8 @@ from opentelemetry.trace import Span
12
12
 
13
13
  from lmnr.sdk.utils import get_input_from_func_args, is_method
14
14
  from lmnr.openllmetry_sdk.tracing import get_tracer
15
- from lmnr.openllmetry_sdk.tracing.attributes import SPAN_INPUT, SPAN_OUTPUT, SPAN_PATH
16
- from lmnr.openllmetry_sdk.tracing.tracing import TracerWrapper, get_span_path
15
+ from lmnr.openllmetry_sdk.tracing.attributes import SPAN_INPUT, SPAN_OUTPUT
16
+ from lmnr.openllmetry_sdk.tracing.tracing import TracerWrapper
17
17
  from lmnr.openllmetry_sdk.utils.json_encoder import JSONEncoder
18
18
 
19
19
 
@@ -50,11 +50,7 @@ def entity_method(
50
50
  with get_tracer() as tracer:
51
51
  span = tracer.start_span(span_name)
52
52
 
53
- span_path = get_span_path(span_name)
54
- span.set_attribute(SPAN_PATH, span_path)
55
- ctx = context_api.set_value("span_path", span_path)
56
-
57
- ctx = trace.set_span_in_context(span, ctx)
53
+ ctx = trace.set_span_in_context(span, context_api.get_current())
58
54
  ctx_token = context_api.attach(ctx)
59
55
 
60
56
  try:
@@ -101,8 +97,6 @@ def entity_method(
101
97
 
102
98
 
103
99
  # Async Decorators
104
-
105
-
106
100
  def aentity_method(
107
101
  name: Optional[str] = None,
108
102
  ):
@@ -117,11 +111,7 @@ def aentity_method(
117
111
  with get_tracer() as tracer:
118
112
  span = tracer.start_span(span_name)
119
113
 
120
- span_path = get_span_path(span_name)
121
- span.set_attribute(SPAN_PATH, span_path)
122
- ctx = context_api.set_value("span_path", span_path)
123
-
124
- ctx = trace.set_span_in_context(span, ctx)
114
+ ctx = trace.set_span_in_context(span, context_api.get_current())
125
115
  ctx_token = context_api.attach(ctx)
126
116
 
127
117
  try:
@@ -23,11 +23,11 @@ from opentelemetry.exporter.otlp.proto.grpc.trace_exporter import (
23
23
  OTLPSpanExporter as GRPCExporter,
24
24
  )
25
25
  from opentelemetry.instrumentation.threading import ThreadingInstrumentor
26
- from opentelemetry.context import get_value, attach, set_value
26
+ from opentelemetry.context import get_value, attach, get_current, set_value, Context
27
27
  from opentelemetry.propagate import set_global_textmap
28
28
  from opentelemetry.propagators.textmap import TextMapPropagator
29
29
  from opentelemetry.sdk.resources import Resource
30
- from opentelemetry.sdk.trace import TracerProvider, SpanProcessor
30
+ from opentelemetry.sdk.trace import TracerProvider, SpanProcessor, Span
31
31
  from opentelemetry.sdk.trace.export import (
32
32
  SpanExporter,
33
33
  SimpleSpanProcessor,
@@ -70,6 +70,7 @@ class TracerWrapper(object):
70
70
  headers: Dict[str, str] = {}
71
71
  __tracer_provider: TracerProvider = None
72
72
  __logger: logging.Logger = None
73
+ __span_id_to_path: dict[int, str] = {}
73
74
 
74
75
  def __new__(
75
76
  cls,
@@ -137,6 +138,7 @@ class TracerWrapper(object):
137
138
  return cls.instance
138
139
 
139
140
  def exit_handler(self):
141
+ self.__span_id_to_path = {}
140
142
  self.flush()
141
143
 
142
144
  def _initialize_logger(self):
@@ -145,14 +147,18 @@ class TracerWrapper(object):
145
147
  console_log_handler.setFormatter(VerboseColorfulFormatter())
146
148
  self.__logger.addHandler(console_log_handler)
147
149
 
148
- def _span_processor_on_start(self, span, parent_context):
149
- span_path = get_value("span_path")
150
- if span_path is not None:
151
- # This is done redundantly here for most decorated functions
152
- # However, need to do this for auto-instrumented libraries.
153
- # Then, for auto-instrumented ones, they'll attach
154
- # the final part of the name to the span on the backend.
155
- span.set_attribute(SPAN_PATH, span_path)
150
+ def _span_processor_on_start(
151
+ self, span: Span, parent_context: Optional[Context] = None
152
+ ):
153
+ span_path_in_context = get_value("span_path", parent_context or get_current())
154
+ span_path_in_context = None
155
+ parent_span_path = span_path_in_context or (
156
+ self.__span_id_to_path.get(span.parent.span_id) if span.parent else None
157
+ )
158
+ span_path = f"{parent_span_path}.{span.name}" if parent_span_path else span.name
159
+ span.set_attribute(SPAN_PATH, span_path)
160
+ set_value("span_path", span_path, get_current())
161
+ self.__span_id_to_path[span.get_span_context().span_id] = span_path
156
162
 
157
163
  span.set_attribute(SPAN_INSTRUMENTATION_SOURCE, "python")
158
164
 
@@ -186,6 +192,11 @@ class TracerWrapper(object):
186
192
  def verify_initialized(cls) -> bool:
187
193
  return hasattr(cls, "instance")
188
194
 
195
+ @classmethod
196
+ def clear(cls):
197
+ # Any state cleanup. Now used in between tests
198
+ cls.__span_id_to_path = {}
199
+
189
200
  def flush(self):
190
201
  self.__spans_processor.force_flush()
191
202
 
@@ -231,12 +242,6 @@ def _set_association_properties_attributes(span, properties: dict) -> None:
231
242
  span.set_attribute(f"{ASSOCIATION_PROPERTIES}.{key}", value)
232
243
 
233
244
 
234
- def get_span_path(span_name: str) -> str:
235
- current_span_path = get_value("span_path")
236
- span_path = f"{current_span_path}.{span_name}" if current_span_path else span_name
237
- return span_path
238
-
239
-
240
245
  def set_managed_prompt_tracing_context(
241
246
  key: str,
242
247
  version: int,
@@ -1,5 +1,4 @@
1
1
  from abc import ABC, abstractmethod
2
- import asyncio
3
2
 
4
3
  from .log import get_default_logger
5
4
  from .laminar import Laminar as L
@@ -10,8 +10,8 @@ from lmnr.openllmetry_sdk.tracing.attributes import (
10
10
  OVERRIDE_PARENT_SPAN,
11
11
  )
12
12
  from lmnr.openllmetry_sdk.decorators.base import json_dumps
13
- from opentelemetry import context, trace
14
- from opentelemetry.context import attach, detach, set_value
13
+ from opentelemetry import context as context_api, trace
14
+ from opentelemetry.context import attach, detach
15
15
  from opentelemetry.sdk.trace import SpanProcessor
16
16
  from opentelemetry.exporter.otlp.proto.grpc.trace_exporter import OTLPSpanExporter
17
17
  from opentelemetry.util.types import AttributeValue
@@ -37,11 +37,9 @@ from lmnr.openllmetry_sdk.tracing.attributes import (
37
37
  SESSION_ID,
38
38
  SPAN_INPUT,
39
39
  SPAN_OUTPUT,
40
- SPAN_PATH,
41
40
  TRACE_TYPE,
42
41
  )
43
42
  from lmnr.openllmetry_sdk.tracing.tracing import (
44
- get_span_path,
45
43
  remove_association_properties,
46
44
  set_association_properties,
47
45
  update_association_properties,
@@ -80,7 +78,7 @@ class Laminar:
80
78
  http_port: Optional[int] = None,
81
79
  grpc_port: Optional[int] = None,
82
80
  instruments: Optional[Set[Instruments]] = None,
83
- _processor: Optional[SpanProcessor] = None,
81
+ disable_batch: bool = False,
84
82
  ):
85
83
  """Initialize Laminar context across the application.
86
84
  This method must be called before using any other Laminar methods or
@@ -105,6 +103,14 @@ class Laminar:
105
103
  If not specified, defaults to 443.
106
104
  grpc_port (Optional[int], optional): Laminar API grpc port.\
107
105
  If not specified, defaults to 8443.
106
+ instruments (Optional[Set[Instruments]], optional): Instruments to\
107
+ enable. Defaults to all instruments. You can pass\
108
+ an empty set to disable all instruments. Read more:\
109
+ https://docs.lmnr.ai/tracing/automatic-instrumentation
110
+ disable_batch (bool, optional): If set to True, spans will be sent\
111
+ immediately to the backend. Useful for debugging, but\
112
+ may cause performance overhead in production.
113
+ Defaults to False.
108
114
 
109
115
  Raises:
110
116
  ValueError: If project API key is not set
@@ -142,6 +148,7 @@ class Laminar:
142
148
  headers={"authorization": f"Bearer {cls.__project_api_key}"},
143
149
  ),
144
150
  instruments=instruments,
151
+ disable_batch=disable_batch,
145
152
  )
146
153
 
147
154
  @classmethod
@@ -350,8 +357,7 @@ class Laminar:
350
357
  return
351
358
 
352
359
  with get_tracer() as tracer:
353
- span_path = get_span_path(name)
354
- ctx = set_value("span_path", span_path, context)
360
+ ctx = context or context_api.get_current()
355
361
  if trace_id is not None:
356
362
  if isinstance(trace_id, uuid.UUID):
357
363
  span_context = trace.SpanContext(
@@ -385,7 +391,6 @@ class Laminar:
385
391
  name,
386
392
  context=ctx,
387
393
  attributes={
388
- SPAN_PATH: span_path,
389
394
  SPAN_TYPE: span_type,
390
395
  **(label_props),
391
396
  },
@@ -497,8 +502,7 @@ class Laminar:
497
502
  span. Defaults to None.
498
503
  """
499
504
  with get_tracer() as tracer:
500
- span_path = get_span_path(name)
501
- ctx = set_value("span_path", span_path, context)
505
+ ctx = context or context_api.get_current()
502
506
  if trace_id is not None:
503
507
  if isinstance(trace_id, uuid.UUID):
504
508
  span_context = trace.SpanContext(
@@ -531,7 +535,6 @@ class Laminar:
531
535
  name,
532
536
  context=ctx,
533
537
  attributes={
534
- SPAN_PATH: span_path,
535
538
  SPAN_TYPE: span_type,
536
539
  **(label_props),
537
540
  },
@@ -670,7 +673,7 @@ class Laminar:
670
673
  @classmethod
671
674
  def clear_metadata(cls):
672
675
  """Clear the metadata from the context"""
673
- props: dict = copy.copy(context.get_value("association_properties"))
676
+ props: dict = copy.copy(context_api.get_value("association_properties"))
674
677
  metadata_keys = [k for k in props.keys() if k.startswith("metadata.")]
675
678
  for k in metadata_keys:
676
679
  props.pop(k)
@@ -679,7 +682,7 @@ class Laminar:
679
682
  @classmethod
680
683
  def clear_session(cls):
681
684
  """Clear the session and user id from the context"""
682
- props: dict = copy.copy(context.get_value("association_properties"))
685
+ props: dict = copy.copy(context_api.get_value("association_properties"))
683
686
  props.pop("session_id", None)
684
687
  props.pop("user_id", None)
685
688
  set_association_properties(props)
@@ -1,149 +0,0 @@
1
- # Laminar Python
2
-
3
- # If you are looking for information about possible extras installations,
4
- # i.e. what you can pass into `pip install 'lmnr[extra1,extra2]'`, please see the
5
- # `[tool.poetry.extras]` section below.
6
-
7
- [project]
8
- name = "lmnr"
9
- version = "0.4.50"
10
- description = "Python SDK for Laminar AI"
11
- authors = [
12
- { name = "lmnr.ai", email = "founders@lmnr.ai" }
13
- ]
14
- readme = "README.md"
15
- requires-python = ">=3.9,<4"
16
- license = "Apache-2.0"
17
-
18
- [tool.poetry]
19
- name = "lmnr"
20
- version = "0.4.50"
21
- description = "Python SDK for Laminar AI"
22
- authors = ["lmnr.ai"]
23
- readme = "README.md"
24
- license = "Apache-2.0"
25
-
26
- [tool.poetry.dependencies]
27
- python = ">=3.9,<4"
28
- pydantic = ">=2.7"
29
- requests = ">=2.0"
30
- python-dotenv = ">=1.0"
31
- opentelemetry-api = ">=1.28.0"
32
- opentelemetry-sdk = ">=1.28.0"
33
- opentelemetry-exporter-otlp-proto-http = ">=1.28.0"
34
- opentelemetry-exporter-otlp-proto-grpc = ">=1.28.0"
35
- opentelemetry-instrumentation-requests = ">=0.50b0"
36
- opentelemetry-instrumentation-sqlalchemy = ">=0.50b0"
37
- opentelemetry-instrumentation-urllib3 = ">=0.50b0"
38
- opentelemetry-instrumentation-threading = ">=0.50b0"
39
- opentelemetry-semantic-conventions-ai = "0.4.2"
40
- deprecated = ">=1.0"
41
- tqdm = ">=4.0"
42
- argparse = ">=1.0"
43
- aiohttp = ">=3.0"
44
- tenacity = ">=8.0"
45
- opentelemetry-instrumentation-alephalpha = {version = ">=0.34.0", optional = true}
46
- opentelemetry-instrumentation-anthropic = {version = ">=0.34.0", optional = true}
47
- opentelemetry-instrumentation-bedrock = {version = ">=0.34.0", optional = true}
48
- opentelemetry-instrumentation-chromadb = {version = ">=0.34.0", optional = true}
49
- opentelemetry-instrumentation-cohere = {version = ">=0.34.0", optional = true}
50
- opentelemetry-instrumentation-google-generativeai = {version = ">=0.34.0", optional = true}
51
- opentelemetry-instrumentation-groq = {version = ">=0.34.0", optional = true}
52
- opentelemetry-instrumentation-haystack = {version = ">=0.34.0", optional = true}
53
- opentelemetry-instrumentation-lancedb = {version = ">=0.34.0", optional = true}
54
- opentelemetry-instrumentation-langchain = {version = ">=0.34.0", optional = true}
55
- opentelemetry-instrumentation-llamaindex = {version = ">=0.34.0", optional = true}
56
- opentelemetry-instrumentation-marqo = {version = ">=0.34.0", optional = true}
57
- opentelemetry-instrumentation-milvus = {version = ">=0.34.0", optional = true}
58
- opentelemetry-instrumentation-mistralai = {version = ">=0.34.0", optional = true}
59
- opentelemetry-instrumentation-ollama = {version = ">=0.34.0", optional = true}
60
- opentelemetry-instrumentation-openai = {version = ">=0.33.12", optional = true}
61
- opentelemetry-instrumentation-pinecone = {version = ">=0.34.0", optional = true}
62
- opentelemetry-instrumentation-qdrant = {version = ">=0.34.0", optional = true}
63
- opentelemetry-instrumentation-replicate = {version = ">=0.34.0", optional = true}
64
- opentelemetry-instrumentation-sagemaker = {version = ">=0.34.0", optional = true}
65
- opentelemetry-instrumentation-together = {version = ">=0.34.0", optional = true}
66
- opentelemetry-instrumentation-transformers = {version = ">=0.34.0", optional = true}
67
- opentelemetry-instrumentation-vertexai = {version = ">=0.34.0", optional = true}
68
- opentelemetry-instrumentation-watsonx = {version = ">=0.34.0", optional = true}
69
- opentelemetry-instrumentation-weaviate = {version = ">=0.34.0", optional = true}
70
-
71
- [tool.poetry.extras]
72
- # List of all possible extras. You can specify one or more of these extras
73
- # when installing the package, using any of the following:
74
- # `pip install 'lmnr[anthropic,openai]'`
75
- # `uv pip install 'lmnr[anthropic,openai]'`
76
- # `uv add lmnr --extra anthropic --extra openai`
77
- # `poetry add 'lmnr[anthropic,openai]'`
78
-
79
- # `all` is the group added for convenience, if you want to install all
80
- # the instrumentations.
81
- all = [
82
- "opentelemetry-instrumentation-alephalpha",
83
- "opentelemetry-instrumentation-anthropic",
84
- "opentelemetry-instrumentation-bedrock",
85
- "opentelemetry-instrumentation-chromadb",
86
- "opentelemetry-instrumentation-cohere",
87
- "opentelemetry-instrumentation-google-generativeai",
88
- "opentelemetry-instrumentation-groq",
89
- "opentelemetry-instrumentation-haystack",
90
- "opentelemetry-instrumentation-lancedb",
91
- "opentelemetry-instrumentation-langchain",
92
- "opentelemetry-instrumentation-llamaindex",
93
- "opentelemetry-instrumentation-marqo",
94
- "opentelemetry-instrumentation-milvus",
95
- "opentelemetry-instrumentation-mistralai",
96
- "opentelemetry-instrumentation-ollama",
97
- "opentelemetry-instrumentation-openai",
98
- "opentelemetry-instrumentation-pinecone",
99
- "opentelemetry-instrumentation-qdrant",
100
- "opentelemetry-instrumentation-replicate",
101
- "opentelemetry-instrumentation-sagemaker",
102
- "opentelemetry-instrumentation-together",
103
- "opentelemetry-instrumentation-transformers",
104
- "opentelemetry-instrumentation-vertexai",
105
- "opentelemetry-instrumentation-watsonx",
106
- "opentelemetry-instrumentation-weaviate"
107
- ]
108
- alephalpha=["opentelemetry-instrumentation-alephalpha"]
109
- anthropic=["opentelemetry-instrumentation-anthropic"]
110
- bedrock=["opentelemetry-instrumentation-bedrock"]
111
- chromadb=["opentelemetry-instrumentation-chromadb"]
112
- cohere=["opentelemetry-instrumentation-cohere"]
113
- google-generativeai=["opentelemetry-instrumentation-google-generativeai"]
114
- groq=["opentelemetry-instrumentation-groq"]
115
- haystack=["opentelemetry-instrumentation-haystack"]
116
- lancedb=["opentelemetry-instrumentation-lancedb"]
117
- langchain=["opentelemetry-instrumentation-langchain"]
118
- llamaindex=["opentelemetry-instrumentation-llamaindex"]
119
- marqo=["opentelemetry-instrumentation-marqo"]
120
- milvus=["opentelemetry-instrumentation-milvus"]
121
- mistralai=["opentelemetry-instrumentation-mistralai"]
122
- ollama=["opentelemetry-instrumentation-ollama"]
123
- openai=["opentelemetry-instrumentation-openai"]
124
- pinecone=["opentelemetry-instrumentation-pinecone"]
125
- qdrant=["opentelemetry-instrumentation-qdrant"]
126
- replicate=["opentelemetry-instrumentation-replicate"]
127
- sagemaker=["opentelemetry-instrumentation-sagemaker"]
128
- together=["opentelemetry-instrumentation-together"]
129
- transformers=["opentelemetry-instrumentation-transformers"]
130
- vertexai=["opentelemetry-instrumentation-vertexai"]
131
- watsonx=["opentelemetry-instrumentation-watsonx"]
132
- weaviate=["opentelemetry-instrumentation-weaviate"]
133
-
134
- [tool.poetry.group.dev.dependencies]
135
- autopep8 = "^2.2.0"
136
- flake8 = "7.0.0"
137
- pytest = "^8.2.2"
138
- pytest-sugar = "1.0.0"
139
- pytest-asyncio = "^0.24.0"
140
-
141
- [build-system]
142
- requires = ["poetry-core"]
143
- build-backend = "poetry.core.masonry.api"
144
-
145
- [tool.poetry.scripts]
146
- lmnr = "lmnr.cli:cli"
147
-
148
- [project.optional-dependencies]
149
- test = ["pytest"]
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes