lmnr 0.4.39b1__tar.gz → 0.4.40__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.
- {lmnr-0.4.39b1 → lmnr-0.4.40}/PKG-INFO +49 -54
- {lmnr-0.4.39b1 → lmnr-0.4.40}/README.md +22 -27
- {lmnr-0.4.39b1 → lmnr-0.4.40}/pyproject.toml +7 -7
- {lmnr-0.4.39b1 → lmnr-0.4.40}/src/lmnr/openllmetry_sdk/tracing/tracing.py +79 -28
- {lmnr-0.4.39b1 → lmnr-0.4.40}/src/lmnr/openllmetry_sdk/utils/package_check.py +1 -0
- {lmnr-0.4.39b1 → lmnr-0.4.40}/src/lmnr/sdk/decorators.py +1 -9
- {lmnr-0.4.39b1 → lmnr-0.4.40}/src/lmnr/sdk/laminar.py +2 -15
- {lmnr-0.4.39b1 → lmnr-0.4.40}/LICENSE +0 -0
- {lmnr-0.4.39b1 → lmnr-0.4.40}/src/lmnr/__init__.py +0 -0
- {lmnr-0.4.39b1 → lmnr-0.4.40}/src/lmnr/cli.py +0 -0
- {lmnr-0.4.39b1 → lmnr-0.4.40}/src/lmnr/openllmetry_sdk/.flake8 +0 -0
- {lmnr-0.4.39b1 → lmnr-0.4.40}/src/lmnr/openllmetry_sdk/.python-version +0 -0
- {lmnr-0.4.39b1 → lmnr-0.4.40}/src/lmnr/openllmetry_sdk/__init__.py +0 -0
- {lmnr-0.4.39b1 → lmnr-0.4.40}/src/lmnr/openllmetry_sdk/config/__init__.py +0 -0
- {lmnr-0.4.39b1 → lmnr-0.4.40}/src/lmnr/openllmetry_sdk/decorators/__init__.py +0 -0
- {lmnr-0.4.39b1 → lmnr-0.4.40}/src/lmnr/openllmetry_sdk/decorators/base.py +0 -0
- {lmnr-0.4.39b1 → lmnr-0.4.40}/src/lmnr/openllmetry_sdk/instruments.py +0 -0
- {lmnr-0.4.39b1 → lmnr-0.4.40}/src/lmnr/openllmetry_sdk/tracing/__init__.py +0 -0
- {lmnr-0.4.39b1 → lmnr-0.4.40}/src/lmnr/openllmetry_sdk/tracing/attributes.py +0 -0
- {lmnr-0.4.39b1 → lmnr-0.4.40}/src/lmnr/openllmetry_sdk/tracing/content_allow_list.py +0 -0
- {lmnr-0.4.39b1 → lmnr-0.4.40}/src/lmnr/openllmetry_sdk/tracing/context_manager.py +0 -0
- {lmnr-0.4.39b1 → lmnr-0.4.40}/src/lmnr/openllmetry_sdk/utils/__init__.py +0 -0
- {lmnr-0.4.39b1 → lmnr-0.4.40}/src/lmnr/openllmetry_sdk/utils/in_memory_span_exporter.py +0 -0
- {lmnr-0.4.39b1 → lmnr-0.4.40}/src/lmnr/openllmetry_sdk/utils/json_encoder.py +0 -0
- {lmnr-0.4.39b1 → lmnr-0.4.40}/src/lmnr/openllmetry_sdk/version.py +0 -0
- {lmnr-0.4.39b1 → lmnr-0.4.40}/src/lmnr/sdk/__init__.py +0 -0
- {lmnr-0.4.39b1 → lmnr-0.4.40}/src/lmnr/sdk/datasets.py +0 -0
- {lmnr-0.4.39b1 → lmnr-0.4.40}/src/lmnr/sdk/evaluations.py +0 -0
- {lmnr-0.4.39b1 → lmnr-0.4.40}/src/lmnr/sdk/log.py +0 -0
- {lmnr-0.4.39b1 → lmnr-0.4.40}/src/lmnr/sdk/types.py +0 -0
- {lmnr-0.4.39b1 → lmnr-0.4.40}/src/lmnr/sdk/utils.py +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: lmnr
|
3
|
-
Version: 0.4.
|
3
|
+
Version: 0.4.40
|
4
4
|
Summary: Python SDK for Laminar AI
|
5
5
|
License: Apache-2.0
|
6
6
|
Author: lmnr.ai
|
@@ -13,11 +13,11 @@ Classifier: Programming Language :: Python :: 3.11
|
|
13
13
|
Classifier: Programming Language :: Python :: 3.12
|
14
14
|
Classifier: Programming Language :: Python :: 3.13
|
15
15
|
Provides-Extra: alephalpha
|
16
|
+
Provides-Extra: all
|
16
17
|
Provides-Extra: anthropic
|
17
18
|
Provides-Extra: bedrock
|
18
19
|
Provides-Extra: chromadb
|
19
20
|
Provides-Extra: cohere
|
20
|
-
Provides-Extra: full
|
21
21
|
Provides-Extra: google-generativeai
|
22
22
|
Provides-Extra: groq
|
23
23
|
Provides-Extra: haystack
|
@@ -45,35 +45,35 @@ Requires-Dist: jinja2 (>=3.0,<4.0)
|
|
45
45
|
Requires-Dist: opentelemetry-api (>=1.28.0)
|
46
46
|
Requires-Dist: opentelemetry-exporter-otlp-proto-grpc (>=1.28.0)
|
47
47
|
Requires-Dist: opentelemetry-exporter-otlp-proto-http (>=1.28.0)
|
48
|
-
Requires-Dist: opentelemetry-instrumentation-alephalpha (>=0.33.12) ; extra == "
|
49
|
-
Requires-Dist: opentelemetry-instrumentation-anthropic (>=0.33.12) ; extra == "
|
50
|
-
Requires-Dist: opentelemetry-instrumentation-bedrock (>=0.33.12) ; extra == "
|
51
|
-
Requires-Dist: opentelemetry-instrumentation-chromadb (>=0.33.12) ; extra == "
|
52
|
-
Requires-Dist: opentelemetry-instrumentation-cohere (>=0.33.12) ; extra == "
|
53
|
-
Requires-Dist: opentelemetry-instrumentation-google-generativeai (>=0.33.12) ; extra == "
|
54
|
-
Requires-Dist: opentelemetry-instrumentation-groq (>=0.33.12) ; extra == "
|
55
|
-
Requires-Dist: opentelemetry-instrumentation-haystack (>=0.33.12) ; extra == "
|
56
|
-
Requires-Dist: opentelemetry-instrumentation-lancedb (>=0.33.12) ; extra == "
|
57
|
-
Requires-Dist: opentelemetry-instrumentation-langchain (>=0.33.12) ; extra == "
|
58
|
-
Requires-Dist: opentelemetry-instrumentation-llamaindex (>=0.33.12) ; extra == "
|
59
|
-
Requires-Dist: opentelemetry-instrumentation-marqo (>=0.33.12) ; extra == "
|
60
|
-
Requires-Dist: opentelemetry-instrumentation-milvus (>=0.33.12) ; extra == "
|
61
|
-
Requires-Dist: opentelemetry-instrumentation-mistralai (>=0.33.12) ; extra == "
|
62
|
-
Requires-Dist: opentelemetry-instrumentation-ollama (>=0.33.12) ; extra == "
|
63
|
-
Requires-Dist: opentelemetry-instrumentation-openai (>=0.33.12) ; extra == "
|
64
|
-
Requires-Dist: opentelemetry-instrumentation-pinecone (>=0.33.12) ; extra == "
|
65
|
-
Requires-Dist: opentelemetry-instrumentation-qdrant (>=0.33.12) ; extra == "
|
66
|
-
Requires-Dist: opentelemetry-instrumentation-replicate (>=0.33.12) ; extra == "
|
48
|
+
Requires-Dist: opentelemetry-instrumentation-alephalpha (>=0.33.12) ; extra == "all" or extra == "alephalpha"
|
49
|
+
Requires-Dist: opentelemetry-instrumentation-anthropic (>=0.33.12) ; extra == "all" or extra == "anthropic"
|
50
|
+
Requires-Dist: opentelemetry-instrumentation-bedrock (>=0.33.12) ; extra == "all" or extra == "bedrock"
|
51
|
+
Requires-Dist: opentelemetry-instrumentation-chromadb (>=0.33.12) ; extra == "all" or extra == "chromadb"
|
52
|
+
Requires-Dist: opentelemetry-instrumentation-cohere (>=0.33.12) ; extra == "all" or extra == "cohere"
|
53
|
+
Requires-Dist: opentelemetry-instrumentation-google-generativeai (>=0.33.12) ; extra == "all" or extra == "google-generativeai"
|
54
|
+
Requires-Dist: opentelemetry-instrumentation-groq (>=0.33.12) ; extra == "all" or extra == "groq"
|
55
|
+
Requires-Dist: opentelemetry-instrumentation-haystack (>=0.33.12) ; extra == "all" or extra == "haystack"
|
56
|
+
Requires-Dist: opentelemetry-instrumentation-lancedb (>=0.33.12) ; extra == "all" or extra == "lancedb"
|
57
|
+
Requires-Dist: opentelemetry-instrumentation-langchain (>=0.33.12) ; extra == "all" or extra == "langchain"
|
58
|
+
Requires-Dist: opentelemetry-instrumentation-llamaindex (>=0.33.12) ; extra == "all" or extra == "llamaindex"
|
59
|
+
Requires-Dist: opentelemetry-instrumentation-marqo (>=0.33.12) ; extra == "all" or extra == "marqo"
|
60
|
+
Requires-Dist: opentelemetry-instrumentation-milvus (>=0.33.12) ; extra == "all" or extra == "milvus"
|
61
|
+
Requires-Dist: opentelemetry-instrumentation-mistralai (>=0.33.12) ; extra == "all" or extra == "mistralai"
|
62
|
+
Requires-Dist: opentelemetry-instrumentation-ollama (>=0.33.12) ; extra == "all" or extra == "ollama"
|
63
|
+
Requires-Dist: opentelemetry-instrumentation-openai (>=0.33.12) ; extra == "all" or extra == "openai"
|
64
|
+
Requires-Dist: opentelemetry-instrumentation-pinecone (>=0.33.12) ; extra == "all" or extra == "pinecone"
|
65
|
+
Requires-Dist: opentelemetry-instrumentation-qdrant (>=0.33.12) ; extra == "all" or extra == "qdrant"
|
66
|
+
Requires-Dist: opentelemetry-instrumentation-replicate (>=0.33.12) ; extra == "all" or extra == "replicate"
|
67
67
|
Requires-Dist: opentelemetry-instrumentation-requests (>=0.49b0,<0.50)
|
68
|
-
Requires-Dist: opentelemetry-instrumentation-sagemaker (>=0.33.12) ; extra == "
|
68
|
+
Requires-Dist: opentelemetry-instrumentation-sagemaker (>=0.33.12) ; extra == "all" or extra == "sagemaker"
|
69
69
|
Requires-Dist: opentelemetry-instrumentation-sqlalchemy (>=0.49b0,<0.50)
|
70
70
|
Requires-Dist: opentelemetry-instrumentation-threading (>=0.49b0,<0.50)
|
71
|
-
Requires-Dist: opentelemetry-instrumentation-together (>=0.33.12) ; extra == "
|
72
|
-
Requires-Dist: opentelemetry-instrumentation-transformers (>=0.33.12) ; extra == "
|
71
|
+
Requires-Dist: opentelemetry-instrumentation-together (>=0.33.12) ; extra == "all" or extra == "together"
|
72
|
+
Requires-Dist: opentelemetry-instrumentation-transformers (>=0.33.12) ; extra == "all" or extra == "transformers"
|
73
73
|
Requires-Dist: opentelemetry-instrumentation-urllib3 (>=0.49b0,<0.50)
|
74
|
-
Requires-Dist: opentelemetry-instrumentation-vertexai (>=0.33.12) ; extra == "
|
75
|
-
Requires-Dist: opentelemetry-instrumentation-watsonx (>=0.33.12) ; extra == "
|
76
|
-
Requires-Dist: opentelemetry-instrumentation-weaviate (>=0.33.12) ; extra == "
|
74
|
+
Requires-Dist: opentelemetry-instrumentation-vertexai (>=0.33.12) ; extra == "all" or extra == "vertexai"
|
75
|
+
Requires-Dist: opentelemetry-instrumentation-watsonx (>=0.33.12) ; extra == "all" or extra == "watsonx"
|
76
|
+
Requires-Dist: opentelemetry-instrumentation-weaviate (>=0.33.12) ; extra == "all" or extra == "weaviate"
|
77
77
|
Requires-Dist: opentelemetry-sdk (>=1.28.0)
|
78
78
|
Requires-Dist: opentelemetry-semantic-conventions-ai (==0.4.2)
|
79
79
|
Requires-Dist: pydantic (>=2.7,<3.0)
|
@@ -98,23 +98,28 @@ Check our [open-source repo](https://github.com/lmnr-ai/lmnr) and don't forget t
|
|
98
98
|
|
99
99
|
## Quickstart
|
100
100
|
|
101
|
-
First, install the package
|
101
|
+
First, install the package, specifying the instrumentations you want to use.
|
102
|
+
|
103
|
+
For example, to install the package with OpenAI and Anthropic instrumentations:
|
102
104
|
|
103
105
|
```sh
|
104
|
-
pip install lmnr
|
106
|
+
pip install 'lmnr[anthropic,openai]'
|
105
107
|
```
|
106
108
|
|
107
|
-
|
109
|
+
To install all possible instrumentations, use the following command:
|
110
|
+
|
111
|
+
```sh
|
112
|
+
pip install 'lmnr[all]'
|
113
|
+
```
|
114
|
+
|
115
|
+
Initialize Laminar in your code:
|
108
116
|
|
109
117
|
```python
|
110
|
-
from lmnr import Laminar
|
118
|
+
from lmnr import Laminar
|
111
119
|
|
112
|
-
|
120
|
+
Laminar.initialize(project_api_key="<PROJECT_API_KEY>")
|
113
121
|
```
|
114
122
|
|
115
|
-
This will automatically instrument most of the LLM, Vector DB, and related
|
116
|
-
calls with OpenTelemetry-compatible instrumentation.
|
117
|
-
|
118
123
|
Note that you need to only initialize Laminar once in your application.
|
119
124
|
|
120
125
|
## Instrumentation
|
@@ -127,9 +132,9 @@ This can be useful if you want to trace a request handler or a function which co
|
|
127
132
|
```python
|
128
133
|
import os
|
129
134
|
from openai import OpenAI
|
130
|
-
from lmnr import Laminar
|
135
|
+
from lmnr import Laminar
|
131
136
|
|
132
|
-
|
137
|
+
Laminar.initialize(project_api_key=os.environ["LMNR_PROJECT_API_KEY"])
|
133
138
|
|
134
139
|
client = OpenAI(api_key=os.environ["OPENAI_API_KEY"])
|
135
140
|
|
@@ -152,9 +157,7 @@ def poem_writer(topic: str):
|
|
152
157
|
@observe()
|
153
158
|
def generate_poems():
|
154
159
|
poem1 = poem_writer(topic="laminar flow")
|
155
|
-
L.event("is_poem_generated", True)
|
156
160
|
poem2 = poem_writer(topic="turbulence")
|
157
|
-
L.event("is_poem_generated", True)
|
158
161
|
poems = f"{poem1}\n\n---\n\n{poem2}"
|
159
162
|
return poems
|
160
163
|
```
|
@@ -163,18 +166,10 @@ Also, you can use `Laminar.start_as_current_span` if you want to record a chunk
|
|
163
166
|
|
164
167
|
```python
|
165
168
|
def handle_user_request(topic: str):
|
166
|
-
with
|
167
|
-
...
|
168
|
-
|
169
|
+
with Laminar.start_as_current_span(name="poem_writer", input=topic):
|
169
170
|
poem = poem_writer(topic=topic)
|
170
|
-
|
171
|
-
...
|
172
|
-
|
173
|
-
# while within the span, you can attach laminar events to it
|
174
|
-
L.event("is_poem_generated", True)
|
175
|
-
|
176
171
|
# Use set_span_output to record the output of the span
|
177
|
-
|
172
|
+
Laminar.set_span_output(poem)
|
178
173
|
```
|
179
174
|
|
180
175
|
### Automatic instrumentation
|
@@ -189,9 +184,9 @@ calls with OpenTelemetry-compatible instrumentation, then pass the appropriate i
|
|
189
184
|
For example, if you want to only instrument OpenAI and Anthropic, then do the following:
|
190
185
|
|
191
186
|
```python
|
192
|
-
from lmnr import Laminar
|
187
|
+
from lmnr import Laminar, Instruments
|
193
188
|
|
194
|
-
|
189
|
+
Laminar.initialize(project_api_key=os.environ["LMNR_PROJECT_API_KEY"], instruments={Instruments.OPENAI, Instruments.ANTHROPIC})
|
195
190
|
```
|
196
191
|
|
197
192
|
If you want to fully disable any kind of autoinstrumentation, pass an empty set as `instruments=set()` to `.initialize()`.
|
@@ -272,11 +267,11 @@ Once your pipeline target is set, you can call it from Python in just a few line
|
|
272
267
|
Example use:
|
273
268
|
|
274
269
|
```python
|
275
|
-
from lmnr import Laminar
|
270
|
+
from lmnr import Laminar
|
276
271
|
|
277
|
-
|
272
|
+
Laminar.initialize('<YOUR_PROJECT_API_KEY>', instruments=set())
|
278
273
|
|
279
|
-
result =
|
274
|
+
result = Laminar.run(
|
280
275
|
pipeline = 'my_pipeline_name',
|
281
276
|
inputs = {'input_node_name': 'some_value'},
|
282
277
|
# all environment variables
|
@@ -13,23 +13,28 @@ Check our [open-source repo](https://github.com/lmnr-ai/lmnr) and don't forget t
|
|
13
13
|
|
14
14
|
## Quickstart
|
15
15
|
|
16
|
-
First, install the package
|
16
|
+
First, install the package, specifying the instrumentations you want to use.
|
17
|
+
|
18
|
+
For example, to install the package with OpenAI and Anthropic instrumentations:
|
17
19
|
|
18
20
|
```sh
|
19
|
-
pip install lmnr
|
21
|
+
pip install 'lmnr[anthropic,openai]'
|
20
22
|
```
|
21
23
|
|
22
|
-
|
24
|
+
To install all possible instrumentations, use the following command:
|
25
|
+
|
26
|
+
```sh
|
27
|
+
pip install 'lmnr[all]'
|
28
|
+
```
|
29
|
+
|
30
|
+
Initialize Laminar in your code:
|
23
31
|
|
24
32
|
```python
|
25
|
-
from lmnr import Laminar
|
33
|
+
from lmnr import Laminar
|
26
34
|
|
27
|
-
|
35
|
+
Laminar.initialize(project_api_key="<PROJECT_API_KEY>")
|
28
36
|
```
|
29
37
|
|
30
|
-
This will automatically instrument most of the LLM, Vector DB, and related
|
31
|
-
calls with OpenTelemetry-compatible instrumentation.
|
32
|
-
|
33
38
|
Note that you need to only initialize Laminar once in your application.
|
34
39
|
|
35
40
|
## Instrumentation
|
@@ -42,9 +47,9 @@ This can be useful if you want to trace a request handler or a function which co
|
|
42
47
|
```python
|
43
48
|
import os
|
44
49
|
from openai import OpenAI
|
45
|
-
from lmnr import Laminar
|
50
|
+
from lmnr import Laminar
|
46
51
|
|
47
|
-
|
52
|
+
Laminar.initialize(project_api_key=os.environ["LMNR_PROJECT_API_KEY"])
|
48
53
|
|
49
54
|
client = OpenAI(api_key=os.environ["OPENAI_API_KEY"])
|
50
55
|
|
@@ -67,9 +72,7 @@ def poem_writer(topic: str):
|
|
67
72
|
@observe()
|
68
73
|
def generate_poems():
|
69
74
|
poem1 = poem_writer(topic="laminar flow")
|
70
|
-
L.event("is_poem_generated", True)
|
71
75
|
poem2 = poem_writer(topic="turbulence")
|
72
|
-
L.event("is_poem_generated", True)
|
73
76
|
poems = f"{poem1}\n\n---\n\n{poem2}"
|
74
77
|
return poems
|
75
78
|
```
|
@@ -78,18 +81,10 @@ Also, you can use `Laminar.start_as_current_span` if you want to record a chunk
|
|
78
81
|
|
79
82
|
```python
|
80
83
|
def handle_user_request(topic: str):
|
81
|
-
with
|
82
|
-
...
|
83
|
-
|
84
|
+
with Laminar.start_as_current_span(name="poem_writer", input=topic):
|
84
85
|
poem = poem_writer(topic=topic)
|
85
|
-
|
86
|
-
...
|
87
|
-
|
88
|
-
# while within the span, you can attach laminar events to it
|
89
|
-
L.event("is_poem_generated", True)
|
90
|
-
|
91
86
|
# Use set_span_output to record the output of the span
|
92
|
-
|
87
|
+
Laminar.set_span_output(poem)
|
93
88
|
```
|
94
89
|
|
95
90
|
### Automatic instrumentation
|
@@ -104,9 +99,9 @@ calls with OpenTelemetry-compatible instrumentation, then pass the appropriate i
|
|
104
99
|
For example, if you want to only instrument OpenAI and Anthropic, then do the following:
|
105
100
|
|
106
101
|
```python
|
107
|
-
from lmnr import Laminar
|
102
|
+
from lmnr import Laminar, Instruments
|
108
103
|
|
109
|
-
|
104
|
+
Laminar.initialize(project_api_key=os.environ["LMNR_PROJECT_API_KEY"], instruments={Instruments.OPENAI, Instruments.ANTHROPIC})
|
110
105
|
```
|
111
106
|
|
112
107
|
If you want to fully disable any kind of autoinstrumentation, pass an empty set as `instruments=set()` to `.initialize()`.
|
@@ -187,11 +182,11 @@ Once your pipeline target is set, you can call it from Python in just a few line
|
|
187
182
|
Example use:
|
188
183
|
|
189
184
|
```python
|
190
|
-
from lmnr import Laminar
|
185
|
+
from lmnr import Laminar
|
191
186
|
|
192
|
-
|
187
|
+
Laminar.initialize('<YOUR_PROJECT_API_KEY>', instruments=set())
|
193
188
|
|
194
|
-
result =
|
189
|
+
result = Laminar.run(
|
195
190
|
pipeline = 'my_pipeline_name',
|
196
191
|
inputs = {'input_node_name': 'some_value'},
|
197
192
|
# all environment variables
|
@@ -6,7 +6,7 @@
|
|
6
6
|
|
7
7
|
[project]
|
8
8
|
name = "lmnr"
|
9
|
-
version = "0.4.
|
9
|
+
version = "0.4.40"
|
10
10
|
description = "Python SDK for Laminar AI"
|
11
11
|
authors = [
|
12
12
|
{ name = "lmnr.ai", email = "founders@lmnr.ai" }
|
@@ -17,7 +17,7 @@ license = "Apache-2.0"
|
|
17
17
|
|
18
18
|
[tool.poetry]
|
19
19
|
name = "lmnr"
|
20
|
-
version = "0.4.
|
20
|
+
version = "0.4.40"
|
21
21
|
description = "Python SDK for Laminar AI"
|
22
22
|
authors = ["lmnr.ai"]
|
23
23
|
readme = "README.md"
|
@@ -70,16 +70,16 @@ opentelemetry-instrumentation-watsonx = {version = ">=0.33.12", optional = true}
|
|
70
70
|
opentelemetry-instrumentation-weaviate = {version = ">=0.33.12", optional = true}
|
71
71
|
|
72
72
|
# List of all possible extras. You can specify one or more of these extras
|
73
|
-
# when installing the package,
|
73
|
+
# when installing the package, using any of the following:
|
74
74
|
# `pip install 'lmnr[anthropic,openai]'`
|
75
|
-
# `uv pip install lmnr[anthropic,openai]`
|
75
|
+
# `uv pip install 'lmnr[anthropic,openai]'`
|
76
76
|
# `uv add lmnr --extra anthropic --extra openai`
|
77
|
-
# `poetry add lmnr[anthropic,openai]`
|
77
|
+
# `poetry add 'lmnr[anthropic,openai]'`
|
78
78
|
|
79
|
-
# `
|
79
|
+
# `all` is the group added for convenience, if you want to install all
|
80
80
|
# the instrumentations.
|
81
81
|
[tool.poetry.extras]
|
82
|
-
|
82
|
+
all = [
|
83
83
|
"opentelemetry-instrumentation-alephalpha",
|
84
84
|
"opentelemetry-instrumentation-anthropic",
|
85
85
|
"opentelemetry-instrumentation-bedrock",
|
@@ -407,7 +407,9 @@ def init_instrumentations(
|
|
407
407
|
|
408
408
|
def init_openai_instrumentor(should_enrich_metrics: bool):
|
409
409
|
try:
|
410
|
-
if is_package_installed("openai")
|
410
|
+
if is_package_installed("openai") and is_package_installed(
|
411
|
+
"opentelemetry-instrumentation-openai"
|
412
|
+
):
|
411
413
|
from opentelemetry.instrumentation.openai import OpenAIInstrumentor
|
412
414
|
|
413
415
|
instrumentor = OpenAIInstrumentor(
|
@@ -425,7 +427,9 @@ def init_openai_instrumentor(should_enrich_metrics: bool):
|
|
425
427
|
|
426
428
|
def init_anthropic_instrumentor(should_enrich_metrics: bool):
|
427
429
|
try:
|
428
|
-
if is_package_installed("anthropic")
|
430
|
+
if is_package_installed("anthropic") and is_package_installed(
|
431
|
+
"opentelemetry-instrumentation-anthropic"
|
432
|
+
):
|
429
433
|
from opentelemetry.instrumentation.anthropic import AnthropicInstrumentor
|
430
434
|
|
431
435
|
instrumentor = AnthropicInstrumentor(
|
@@ -442,7 +446,9 @@ def init_anthropic_instrumentor(should_enrich_metrics: bool):
|
|
442
446
|
|
443
447
|
def init_cohere_instrumentor():
|
444
448
|
try:
|
445
|
-
if is_package_installed("cohere")
|
449
|
+
if is_package_installed("cohere") and is_package_installed(
|
450
|
+
"opentelemetry-instrumentation-cohere"
|
451
|
+
):
|
446
452
|
from opentelemetry.instrumentation.cohere import CohereInstrumentor
|
447
453
|
|
448
454
|
instrumentor = CohereInstrumentor()
|
@@ -456,7 +462,9 @@ def init_cohere_instrumentor():
|
|
456
462
|
|
457
463
|
def init_pinecone_instrumentor():
|
458
464
|
try:
|
459
|
-
if is_package_installed("pinecone")
|
465
|
+
if is_package_installed("pinecone") and is_package_installed(
|
466
|
+
"opentelemetry-instrumentation-pinecone"
|
467
|
+
):
|
460
468
|
from opentelemetry.instrumentation.pinecone import PineconeInstrumentor
|
461
469
|
|
462
470
|
instrumentor = PineconeInstrumentor()
|
@@ -470,7 +478,9 @@ def init_pinecone_instrumentor():
|
|
470
478
|
|
471
479
|
def init_qdrant_instrumentor():
|
472
480
|
try:
|
473
|
-
if is_package_installed("qdrant_client")
|
481
|
+
if is_package_installed("qdrant_client") and is_package_installed(
|
482
|
+
"opentelemetry-instrumentation-qdrant"
|
483
|
+
):
|
474
484
|
from opentelemetry.instrumentation.qdrant import QdrantInstrumentor
|
475
485
|
|
476
486
|
instrumentor = QdrantInstrumentor()
|
@@ -483,7 +493,9 @@ def init_qdrant_instrumentor():
|
|
483
493
|
|
484
494
|
def init_chroma_instrumentor():
|
485
495
|
try:
|
486
|
-
if is_package_installed("chromadb")
|
496
|
+
if is_package_installed("chromadb") and is_package_installed(
|
497
|
+
"opentelemetry-instrumentation-chromadb"
|
498
|
+
):
|
487
499
|
from opentelemetry.instrumentation.chromadb import ChromaInstrumentor
|
488
500
|
|
489
501
|
instrumentor = ChromaInstrumentor()
|
@@ -497,7 +509,9 @@ def init_chroma_instrumentor():
|
|
497
509
|
|
498
510
|
def init_google_generativeai_instrumentor():
|
499
511
|
try:
|
500
|
-
if is_package_installed("google.generativeai")
|
512
|
+
if is_package_installed("google.generativeai") and is_package_installed(
|
513
|
+
"opentelemetry-instrumentation-google-generativeai"
|
514
|
+
):
|
501
515
|
from opentelemetry.instrumentation.google_generativeai import (
|
502
516
|
GoogleGenerativeAiInstrumentor,
|
503
517
|
)
|
@@ -513,7 +527,9 @@ def init_google_generativeai_instrumentor():
|
|
513
527
|
|
514
528
|
def init_haystack_instrumentor():
|
515
529
|
try:
|
516
|
-
if is_package_installed("haystack")
|
530
|
+
if is_package_installed("haystack") and is_package_installed(
|
531
|
+
"opentelemetry-instrumentation-haystack"
|
532
|
+
):
|
517
533
|
from opentelemetry.instrumentation.haystack import HaystackInstrumentor
|
518
534
|
|
519
535
|
instrumentor = HaystackInstrumentor()
|
@@ -527,7 +543,9 @@ def init_haystack_instrumentor():
|
|
527
543
|
|
528
544
|
def init_langchain_instrumentor():
|
529
545
|
try:
|
530
|
-
if is_package_installed("langchain")
|
546
|
+
if is_package_installed("langchain") and is_package_installed(
|
547
|
+
"opentelemetry-instrumentation-langchain"
|
548
|
+
):
|
531
549
|
from opentelemetry.instrumentation.langchain import LangchainInstrumentor
|
532
550
|
|
533
551
|
instrumentor = LangchainInstrumentor()
|
@@ -543,7 +561,9 @@ def init_langchain_instrumentor():
|
|
543
561
|
|
544
562
|
def init_mistralai_instrumentor():
|
545
563
|
try:
|
546
|
-
if is_package_installed("mistralai")
|
564
|
+
if is_package_installed("mistralai") and is_package_installed(
|
565
|
+
"opentelemetry-instrumentation-mistralai"
|
566
|
+
):
|
547
567
|
from opentelemetry.instrumentation.mistralai import MistralAiInstrumentor
|
548
568
|
|
549
569
|
instrumentor = MistralAiInstrumentor()
|
@@ -557,7 +577,9 @@ def init_mistralai_instrumentor():
|
|
557
577
|
|
558
578
|
def init_ollama_instrumentor():
|
559
579
|
try:
|
560
|
-
if is_package_installed("ollama")
|
580
|
+
if is_package_installed("ollama") and is_package_installed(
|
581
|
+
"opentelemetry-instrumentation-ollama"
|
582
|
+
):
|
561
583
|
from opentelemetry.instrumentation.ollama import OllamaInstrumentor
|
562
584
|
|
563
585
|
instrumentor = OllamaInstrumentor()
|
@@ -571,7 +593,9 @@ def init_ollama_instrumentor():
|
|
571
593
|
|
572
594
|
def init_transformers_instrumentor():
|
573
595
|
try:
|
574
|
-
if is_package_installed("transformers")
|
596
|
+
if is_package_installed("transformers") and is_package_installed(
|
597
|
+
"opentelemetry-instrumentation-transformers"
|
598
|
+
):
|
575
599
|
from opentelemetry.instrumentation.transformers import (
|
576
600
|
TransformersInstrumentor,
|
577
601
|
)
|
@@ -587,7 +611,9 @@ def init_transformers_instrumentor():
|
|
587
611
|
|
588
612
|
def init_together_instrumentor():
|
589
613
|
try:
|
590
|
-
if is_package_installed("together")
|
614
|
+
if is_package_installed("together") and is_package_installed(
|
615
|
+
"opentelemetry-instrumentation-together"
|
616
|
+
):
|
591
617
|
from opentelemetry.instrumentation.together import TogetherAiInstrumentor
|
592
618
|
|
593
619
|
instrumentor = TogetherAiInstrumentor()
|
@@ -601,7 +627,9 @@ def init_together_instrumentor():
|
|
601
627
|
|
602
628
|
def init_llama_index_instrumentor():
|
603
629
|
try:
|
604
|
-
if
|
630
|
+
if (
|
631
|
+
is_package_installed("llama-index") or is_package_installed("llama_index")
|
632
|
+
) and is_package_installed("opentelemetry-instrumentation-llamaindex"):
|
605
633
|
from opentelemetry.instrumentation.llamaindex import LlamaIndexInstrumentor
|
606
634
|
|
607
635
|
instrumentor = LlamaIndexInstrumentor()
|
@@ -615,7 +643,9 @@ def init_llama_index_instrumentor():
|
|
615
643
|
|
616
644
|
def init_milvus_instrumentor():
|
617
645
|
try:
|
618
|
-
if is_package_installed("pymilvus")
|
646
|
+
if is_package_installed("pymilvus") and is_package_installed(
|
647
|
+
"opentelemetry-instrumentation-milvus"
|
648
|
+
):
|
619
649
|
from opentelemetry.instrumentation.milvus import MilvusInstrumentor
|
620
650
|
|
621
651
|
instrumentor = MilvusInstrumentor()
|
@@ -671,7 +701,9 @@ def init_pymysql_instrumentor():
|
|
671
701
|
|
672
702
|
def init_bedrock_instrumentor(should_enrich_metrics: bool):
|
673
703
|
try:
|
674
|
-
if is_package_installed("boto3")
|
704
|
+
if is_package_installed("boto3") and is_package_installed(
|
705
|
+
"opentelemetry-instrumentation-bedrock"
|
706
|
+
):
|
675
707
|
from opentelemetry.instrumentation.bedrock import BedrockInstrumentor
|
676
708
|
|
677
709
|
instrumentor = BedrockInstrumentor(
|
@@ -687,7 +719,9 @@ def init_bedrock_instrumentor(should_enrich_metrics: bool):
|
|
687
719
|
|
688
720
|
def init_replicate_instrumentor():
|
689
721
|
try:
|
690
|
-
if is_package_installed("replicate")
|
722
|
+
if is_package_installed("replicate") and is_package_installed(
|
723
|
+
"opentelemetry-instrumentation-replicate"
|
724
|
+
):
|
691
725
|
from opentelemetry.instrumentation.replicate import ReplicateInstrumentor
|
692
726
|
|
693
727
|
instrumentor = ReplicateInstrumentor()
|
@@ -701,7 +735,9 @@ def init_replicate_instrumentor():
|
|
701
735
|
|
702
736
|
def init_vertexai_instrumentor():
|
703
737
|
try:
|
704
|
-
if is_package_installed("vertexai")
|
738
|
+
if is_package_installed("vertexai") and is_package_installed(
|
739
|
+
"opentelemetry-instrumentation-vertexai"
|
740
|
+
):
|
705
741
|
from opentelemetry.instrumentation.vertexai import VertexAIInstrumentor
|
706
742
|
|
707
743
|
instrumentor = VertexAIInstrumentor()
|
@@ -715,9 +751,10 @@ def init_vertexai_instrumentor():
|
|
715
751
|
|
716
752
|
def init_watsonx_instrumentor():
|
717
753
|
try:
|
718
|
-
if
|
719
|
-
"ibm-
|
720
|
-
|
754
|
+
if (
|
755
|
+
is_package_installed("ibm-watsonx-ai")
|
756
|
+
or is_package_installed("ibm-watson-machine-learning")
|
757
|
+
) and is_package_installed("opentelemetry-instrumentation-watsonx"):
|
721
758
|
from opentelemetry.instrumentation.watsonx import WatsonxInstrumentor
|
722
759
|
|
723
760
|
instrumentor = WatsonxInstrumentor()
|
@@ -731,7 +768,9 @@ def init_watsonx_instrumentor():
|
|
731
768
|
|
732
769
|
def init_weaviate_instrumentor():
|
733
770
|
try:
|
734
|
-
if is_package_installed("weaviate")
|
771
|
+
if is_package_installed("weaviate") and is_package_installed(
|
772
|
+
"opentelemetry-instrumentation-weaviate"
|
773
|
+
):
|
735
774
|
from opentelemetry.instrumentation.weaviate import WeaviateInstrumentor
|
736
775
|
|
737
776
|
instrumentor = WeaviateInstrumentor()
|
@@ -745,7 +784,9 @@ def init_weaviate_instrumentor():
|
|
745
784
|
|
746
785
|
def init_alephalpha_instrumentor():
|
747
786
|
try:
|
748
|
-
if is_package_installed("aleph_alpha_client")
|
787
|
+
if is_package_installed("aleph_alpha_client") and is_package_installed(
|
788
|
+
"opentelemetry-instrumentation-alephalpha"
|
789
|
+
):
|
749
790
|
from opentelemetry.instrumentation.alephalpha import AlephAlphaInstrumentor
|
750
791
|
|
751
792
|
instrumentor = AlephAlphaInstrumentor()
|
@@ -759,7 +800,9 @@ def init_alephalpha_instrumentor():
|
|
759
800
|
|
760
801
|
def init_marqo_instrumentor():
|
761
802
|
try:
|
762
|
-
if is_package_installed("marqo")
|
803
|
+
if is_package_installed("marqo") and is_package_installed(
|
804
|
+
"opentelemetry-instrumentation-marqo"
|
805
|
+
):
|
763
806
|
from opentelemetry.instrumentation.marqo import MarqoInstrumentor
|
764
807
|
|
765
808
|
instrumentor = MarqoInstrumentor()
|
@@ -773,7 +816,9 @@ def init_marqo_instrumentor():
|
|
773
816
|
|
774
817
|
def init_lancedb_instrumentor():
|
775
818
|
try:
|
776
|
-
if is_package_installed("lancedb")
|
819
|
+
if is_package_installed("lancedb") and is_package_installed(
|
820
|
+
"opentelemetry-instrumentation-lancedb"
|
821
|
+
):
|
777
822
|
from opentelemetry.instrumentation.lancedb import LanceInstrumentor
|
778
823
|
|
779
824
|
instrumentor = LanceInstrumentor()
|
@@ -786,7 +831,9 @@ def init_lancedb_instrumentor():
|
|
786
831
|
|
787
832
|
def init_redis_instrumentor():
|
788
833
|
try:
|
789
|
-
if is_package_installed("redis")
|
834
|
+
if is_package_installed("redis") and is_package_installed(
|
835
|
+
"opentelemetry-instrumentation-redis"
|
836
|
+
):
|
790
837
|
from opentelemetry.instrumentation.redis import RedisInstrumentor
|
791
838
|
|
792
839
|
instrumentor = RedisInstrumentor()
|
@@ -800,7 +847,9 @@ def init_redis_instrumentor():
|
|
800
847
|
|
801
848
|
def init_groq_instrumentor():
|
802
849
|
try:
|
803
|
-
if is_package_installed("groq")
|
850
|
+
if is_package_installed("groq") and is_package_installed(
|
851
|
+
"opentelemetry-instrumentation-groq"
|
852
|
+
):
|
804
853
|
from opentelemetry.instrumentation.groq import GroqInstrumentor
|
805
854
|
|
806
855
|
instrumentor = GroqInstrumentor()
|
@@ -814,7 +863,9 @@ def init_groq_instrumentor():
|
|
814
863
|
|
815
864
|
def init_sagemaker_instrumentor(should_enrich_metrics: bool):
|
816
865
|
try:
|
817
|
-
if is_package_installed("boto3")
|
866
|
+
if is_package_installed("boto3") and is_package_installed(
|
867
|
+
"opentelemetry-instrumentation-sagemaker"
|
868
|
+
):
|
818
869
|
from opentelemetry.instrumentation.sagemaker import SageMakerInstrumentor
|
819
870
|
|
820
871
|
instrumentor = SageMakerInstrumentor(
|
@@ -7,7 +7,7 @@ from opentelemetry.trace import INVALID_SPAN, get_current_span
|
|
7
7
|
from typing import Callable, Optional, TypeVar, cast
|
8
8
|
from typing_extensions import ParamSpec
|
9
9
|
|
10
|
-
from lmnr.openllmetry_sdk.tracing.attributes import SESSION_ID
|
10
|
+
from lmnr.openllmetry_sdk.tracing.attributes import SESSION_ID
|
11
11
|
from lmnr.openllmetry_sdk.tracing.tracing import update_association_properties
|
12
12
|
|
13
13
|
from .utils import is_async
|
@@ -20,7 +20,6 @@ R = TypeVar("R")
|
|
20
20
|
def observe(
|
21
21
|
*,
|
22
22
|
name: Optional[str] = None,
|
23
|
-
user_id: Optional[str] = None,
|
24
23
|
session_id: Optional[str] = None,
|
25
24
|
) -> Callable[[Callable[P, R]], Callable[P, R]]:
|
26
25
|
"""The main decorator entrypoint for Laminar. This is used to wrap
|
@@ -30,9 +29,6 @@ def observe(
|
|
30
29
|
name (Optional[str], optional): Name of the span. Function
|
31
30
|
name is used if not specified.
|
32
31
|
Defaults to None.
|
33
|
-
user_id (Optional[str], optional): User ID to associate
|
34
|
-
with the span and the following context.
|
35
|
-
Defaults to None.
|
36
32
|
session_id (Optional[str], optional): Session ID to associate with the
|
37
33
|
span and the following context. Defaults to None.
|
38
34
|
|
@@ -49,13 +45,9 @@ def observe(
|
|
49
45
|
if current_span != INVALID_SPAN:
|
50
46
|
if session_id is not None:
|
51
47
|
current_span.set_attribute(SESSION_ID, session_id)
|
52
|
-
if user_id is not None:
|
53
|
-
current_span.set_attribute(USER_ID, user_id)
|
54
48
|
association_properties = {}
|
55
49
|
if session_id is not None:
|
56
50
|
association_properties["session_id"] = session_id
|
57
|
-
if user_id is not None:
|
58
|
-
association_properties["user_id"] = user_id
|
59
51
|
update_association_properties(association_properties)
|
60
52
|
return (
|
61
53
|
aentity_method(name=name)(func)
|
@@ -36,7 +36,6 @@ from lmnr.openllmetry_sdk.tracing.attributes import (
|
|
36
36
|
SPAN_OUTPUT,
|
37
37
|
SPAN_PATH,
|
38
38
|
TRACE_TYPE,
|
39
|
-
USER_ID,
|
40
39
|
)
|
41
40
|
from lmnr.openllmetry_sdk.tracing.tracing import (
|
42
41
|
get_span_path,
|
@@ -588,7 +587,6 @@ class Laminar:
|
|
588
587
|
def set_session(
|
589
588
|
cls,
|
590
589
|
session_id: Optional[str] = None,
|
591
|
-
user_id: Optional[str] = None,
|
592
590
|
):
|
593
591
|
"""Set the session and user id for the current span and the context
|
594
592
|
(i.e. any children spans created from the current span in the current
|
@@ -599,29 +597,18 @@ class Laminar:
|
|
599
597
|
Useful to debug and group long-running\
|
600
598
|
sessions/conversations.
|
601
599
|
Defaults to None.
|
602
|
-
user_id (Optional[str], optional). Deprecated.\
|
603
|
-
Use `Laminar.set_metadata` instead.\
|
604
|
-
Custom user id.\
|
605
|
-
Useful for grouping spans or traces by user.\
|
606
|
-
Defaults to None.
|
607
600
|
"""
|
608
601
|
association_properties = {}
|
609
602
|
if session_id is not None:
|
610
603
|
association_properties[SESSION_ID] = session_id
|
611
|
-
if user_id is not None:
|
612
|
-
cls.__logger.warning(
|
613
|
-
"User ID in set_session is deprecated and will be removed soon. "
|
614
|
-
"Please use `Laminar.set_metadata` instead."
|
615
|
-
)
|
616
|
-
association_properties["metadata." + USER_ID] = user_id
|
617
604
|
update_association_properties(association_properties)
|
618
605
|
|
619
606
|
@classmethod
|
620
|
-
def set_metadata(cls, metadata: dict[str,
|
607
|
+
def set_metadata(cls, metadata: dict[str, str]):
|
621
608
|
"""Set the metadata for the current trace.
|
622
609
|
|
623
610
|
Args:
|
624
|
-
metadata (dict[str,
|
611
|
+
metadata (dict[str, str]): Metadata to set for the trace. Willl be\
|
625
612
|
sent as attributes, so must be json serializable.
|
626
613
|
"""
|
627
614
|
props = {f"metadata.{k}": json_dumps(v) for k, v in metadata.items()}
|
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
|
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
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|