lmnr 0.4.53.dev0__py3-none-any.whl → 0.7.26__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.
- lmnr/__init__.py +32 -11
- lmnr/cli/__init__.py +270 -0
- lmnr/cli/datasets.py +371 -0
- lmnr/cli/evals.py +111 -0
- lmnr/cli/rules.py +42 -0
- lmnr/opentelemetry_lib/__init__.py +70 -0
- lmnr/opentelemetry_lib/decorators/__init__.py +337 -0
- lmnr/opentelemetry_lib/litellm/__init__.py +685 -0
- lmnr/opentelemetry_lib/litellm/utils.py +100 -0
- lmnr/opentelemetry_lib/opentelemetry/instrumentation/anthropic/__init__.py +849 -0
- lmnr/opentelemetry_lib/opentelemetry/instrumentation/anthropic/config.py +13 -0
- lmnr/opentelemetry_lib/opentelemetry/instrumentation/anthropic/event_emitter.py +211 -0
- lmnr/opentelemetry_lib/opentelemetry/instrumentation/anthropic/event_models.py +41 -0
- lmnr/opentelemetry_lib/opentelemetry/instrumentation/anthropic/span_utils.py +401 -0
- lmnr/opentelemetry_lib/opentelemetry/instrumentation/anthropic/streaming.py +425 -0
- lmnr/opentelemetry_lib/opentelemetry/instrumentation/anthropic/utils.py +332 -0
- lmnr/opentelemetry_lib/opentelemetry/instrumentation/anthropic/version.py +1 -0
- lmnr/opentelemetry_lib/opentelemetry/instrumentation/claude_agent/__init__.py +451 -0
- lmnr/opentelemetry_lib/opentelemetry/instrumentation/claude_agent/proxy.py +144 -0
- lmnr/opentelemetry_lib/opentelemetry/instrumentation/cua_agent/__init__.py +100 -0
- lmnr/opentelemetry_lib/opentelemetry/instrumentation/cua_computer/__init__.py +476 -0
- lmnr/opentelemetry_lib/opentelemetry/instrumentation/cua_computer/utils.py +12 -0
- lmnr/opentelemetry_lib/opentelemetry/instrumentation/google_genai/__init__.py +599 -0
- lmnr/opentelemetry_lib/opentelemetry/instrumentation/google_genai/config.py +9 -0
- lmnr/opentelemetry_lib/opentelemetry/instrumentation/google_genai/schema_utils.py +26 -0
- lmnr/opentelemetry_lib/opentelemetry/instrumentation/google_genai/utils.py +330 -0
- lmnr/opentelemetry_lib/opentelemetry/instrumentation/groq/__init__.py +488 -0
- lmnr/opentelemetry_lib/opentelemetry/instrumentation/groq/config.py +8 -0
- lmnr/opentelemetry_lib/opentelemetry/instrumentation/groq/event_emitter.py +143 -0
- lmnr/opentelemetry_lib/opentelemetry/instrumentation/groq/event_models.py +41 -0
- lmnr/opentelemetry_lib/opentelemetry/instrumentation/groq/span_utils.py +229 -0
- lmnr/opentelemetry_lib/opentelemetry/instrumentation/groq/utils.py +92 -0
- lmnr/opentelemetry_lib/opentelemetry/instrumentation/groq/version.py +1 -0
- lmnr/opentelemetry_lib/opentelemetry/instrumentation/kernel/__init__.py +381 -0
- lmnr/opentelemetry_lib/opentelemetry/instrumentation/kernel/utils.py +36 -0
- lmnr/opentelemetry_lib/opentelemetry/instrumentation/langgraph/__init__.py +121 -0
- lmnr/opentelemetry_lib/opentelemetry/instrumentation/langgraph/utils.py +60 -0
- lmnr/opentelemetry_lib/opentelemetry/instrumentation/openai/__init__.py +61 -0
- lmnr/opentelemetry_lib/opentelemetry/instrumentation/openai/shared/__init__.py +472 -0
- lmnr/opentelemetry_lib/opentelemetry/instrumentation/openai/shared/chat_wrappers.py +1185 -0
- lmnr/opentelemetry_lib/opentelemetry/instrumentation/openai/shared/completion_wrappers.py +305 -0
- lmnr/opentelemetry_lib/opentelemetry/instrumentation/openai/shared/config.py +16 -0
- lmnr/opentelemetry_lib/opentelemetry/instrumentation/openai/shared/embeddings_wrappers.py +312 -0
- lmnr/opentelemetry_lib/opentelemetry/instrumentation/openai/shared/event_emitter.py +100 -0
- lmnr/opentelemetry_lib/opentelemetry/instrumentation/openai/shared/event_models.py +41 -0
- lmnr/opentelemetry_lib/opentelemetry/instrumentation/openai/shared/image_gen_wrappers.py +68 -0
- lmnr/opentelemetry_lib/opentelemetry/instrumentation/openai/utils.py +197 -0
- lmnr/opentelemetry_lib/opentelemetry/instrumentation/openai/v0/__init__.py +176 -0
- lmnr/opentelemetry_lib/opentelemetry/instrumentation/openai/v1/__init__.py +368 -0
- lmnr/opentelemetry_lib/opentelemetry/instrumentation/openai/v1/assistant_wrappers.py +325 -0
- lmnr/opentelemetry_lib/opentelemetry/instrumentation/openai/v1/event_handler_wrapper.py +135 -0
- lmnr/opentelemetry_lib/opentelemetry/instrumentation/openai/v1/responses_wrappers.py +786 -0
- lmnr/opentelemetry_lib/opentelemetry/instrumentation/openai/version.py +1 -0
- lmnr/opentelemetry_lib/opentelemetry/instrumentation/openhands_ai/__init__.py +388 -0
- lmnr/opentelemetry_lib/opentelemetry/instrumentation/opentelemetry/__init__.py +69 -0
- lmnr/opentelemetry_lib/opentelemetry/instrumentation/skyvern/__init__.py +191 -0
- lmnr/opentelemetry_lib/opentelemetry/instrumentation/threading/__init__.py +197 -0
- lmnr/opentelemetry_lib/tracing/__init__.py +263 -0
- lmnr/opentelemetry_lib/tracing/_instrument_initializers.py +516 -0
- lmnr/{openllmetry_sdk → opentelemetry_lib}/tracing/attributes.py +21 -8
- lmnr/opentelemetry_lib/tracing/context.py +200 -0
- lmnr/opentelemetry_lib/tracing/exporter.py +153 -0
- lmnr/opentelemetry_lib/tracing/instruments.py +140 -0
- lmnr/opentelemetry_lib/tracing/processor.py +193 -0
- lmnr/opentelemetry_lib/tracing/span.py +398 -0
- lmnr/opentelemetry_lib/tracing/tracer.py +57 -0
- lmnr/opentelemetry_lib/tracing/utils.py +62 -0
- lmnr/opentelemetry_lib/utils/package_check.py +18 -0
- lmnr/opentelemetry_lib/utils/wrappers.py +11 -0
- lmnr/sdk/browser/__init__.py +0 -0
- lmnr/sdk/browser/background_send_events.py +158 -0
- lmnr/sdk/browser/browser_use_cdp_otel.py +100 -0
- lmnr/sdk/browser/browser_use_otel.py +142 -0
- lmnr/sdk/browser/bubus_otel.py +71 -0
- lmnr/sdk/browser/cdp_utils.py +518 -0
- lmnr/sdk/browser/inject_script.js +514 -0
- lmnr/sdk/browser/patchright_otel.py +151 -0
- lmnr/sdk/browser/playwright_otel.py +322 -0
- lmnr/sdk/browser/pw_utils.py +363 -0
- lmnr/sdk/browser/recorder/record.umd.min.cjs +84 -0
- lmnr/sdk/browser/utils.py +70 -0
- lmnr/sdk/client/asynchronous/async_client.py +180 -0
- lmnr/sdk/client/asynchronous/resources/__init__.py +6 -0
- lmnr/sdk/client/asynchronous/resources/base.py +32 -0
- lmnr/sdk/client/asynchronous/resources/browser_events.py +41 -0
- lmnr/sdk/client/asynchronous/resources/datasets.py +131 -0
- lmnr/sdk/client/asynchronous/resources/evals.py +266 -0
- lmnr/sdk/client/asynchronous/resources/evaluators.py +85 -0
- lmnr/sdk/client/asynchronous/resources/tags.py +83 -0
- lmnr/sdk/client/synchronous/resources/__init__.py +6 -0
- lmnr/sdk/client/synchronous/resources/base.py +32 -0
- lmnr/sdk/client/synchronous/resources/browser_events.py +40 -0
- lmnr/sdk/client/synchronous/resources/datasets.py +131 -0
- lmnr/sdk/client/synchronous/resources/evals.py +263 -0
- lmnr/sdk/client/synchronous/resources/evaluators.py +85 -0
- lmnr/sdk/client/synchronous/resources/tags.py +83 -0
- lmnr/sdk/client/synchronous/sync_client.py +191 -0
- lmnr/sdk/datasets/__init__.py +94 -0
- lmnr/sdk/datasets/file_utils.py +91 -0
- lmnr/sdk/decorators.py +163 -26
- lmnr/sdk/eval_control.py +3 -2
- lmnr/sdk/evaluations.py +403 -191
- lmnr/sdk/laminar.py +1080 -549
- lmnr/sdk/log.py +7 -2
- lmnr/sdk/types.py +246 -134
- lmnr/sdk/utils.py +151 -7
- lmnr/version.py +46 -0
- {lmnr-0.4.53.dev0.dist-info → lmnr-0.7.26.dist-info}/METADATA +152 -106
- lmnr-0.7.26.dist-info/RECORD +116 -0
- lmnr-0.7.26.dist-info/WHEEL +4 -0
- lmnr-0.7.26.dist-info/entry_points.txt +3 -0
- lmnr/cli.py +0 -101
- lmnr/openllmetry_sdk/.python-version +0 -1
- lmnr/openllmetry_sdk/__init__.py +0 -72
- lmnr/openllmetry_sdk/config/__init__.py +0 -9
- lmnr/openllmetry_sdk/decorators/base.py +0 -185
- lmnr/openllmetry_sdk/instruments.py +0 -38
- lmnr/openllmetry_sdk/tracing/__init__.py +0 -1
- lmnr/openllmetry_sdk/tracing/content_allow_list.py +0 -24
- lmnr/openllmetry_sdk/tracing/context_manager.py +0 -13
- lmnr/openllmetry_sdk/tracing/tracing.py +0 -884
- lmnr/openllmetry_sdk/utils/in_memory_span_exporter.py +0 -61
- lmnr/openllmetry_sdk/utils/package_check.py +0 -7
- lmnr/openllmetry_sdk/version.py +0 -1
- lmnr/sdk/datasets.py +0 -55
- lmnr-0.4.53.dev0.dist-info/LICENSE +0 -75
- lmnr-0.4.53.dev0.dist-info/RECORD +0 -33
- lmnr-0.4.53.dev0.dist-info/WHEEL +0 -4
- lmnr-0.4.53.dev0.dist-info/entry_points.txt +0 -3
- /lmnr/{openllmetry_sdk → opentelemetry_lib}/.flake8 +0 -0
- /lmnr/{openllmetry_sdk → opentelemetry_lib}/utils/__init__.py +0 -0
- /lmnr/{openllmetry_sdk → opentelemetry_lib}/utils/json_encoder.py +0 -0
- /lmnr/{openllmetry_sdk/decorators/__init__.py → py.typed} +0 -0
|
@@ -0,0 +1,516 @@
|
|
|
1
|
+
import abc
|
|
2
|
+
|
|
3
|
+
from opentelemetry.instrumentation.instrumentor import BaseInstrumentor
|
|
4
|
+
|
|
5
|
+
from lmnr.opentelemetry_lib.utils.package_check import (
|
|
6
|
+
get_package_version,
|
|
7
|
+
is_package_installed,
|
|
8
|
+
)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class InstrumentorInitializer(abc.ABC):
|
|
12
|
+
@abc.abstractmethod
|
|
13
|
+
def init_instrumentor(self, *args, **kwargs) -> BaseInstrumentor | None:
|
|
14
|
+
pass
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class AlephAlphaInstrumentorInitializer(InstrumentorInitializer):
|
|
18
|
+
def init_instrumentor(self, *args, **kwargs) -> BaseInstrumentor | None:
|
|
19
|
+
if not is_package_installed("aleph_alpha_client"):
|
|
20
|
+
return None
|
|
21
|
+
if not is_package_installed("opentelemetry-instrumentation-alephalpha"):
|
|
22
|
+
return None
|
|
23
|
+
|
|
24
|
+
from opentelemetry.instrumentation.alephalpha import AlephAlphaInstrumentor
|
|
25
|
+
|
|
26
|
+
return AlephAlphaInstrumentor()
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
class AnthropicInstrumentorInitializer(InstrumentorInitializer):
|
|
30
|
+
def init_instrumentor(self, *args, **kwargs) -> BaseInstrumentor | None:
|
|
31
|
+
if not is_package_installed("anthropic"):
|
|
32
|
+
return None
|
|
33
|
+
|
|
34
|
+
from ..opentelemetry.instrumentation.anthropic import AnthropicInstrumentor
|
|
35
|
+
|
|
36
|
+
return AnthropicInstrumentor(
|
|
37
|
+
upload_base64_image=None,
|
|
38
|
+
)
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
class BedrockInstrumentorInitializer(InstrumentorInitializer):
|
|
42
|
+
def init_instrumentor(self, *args, **kwargs) -> BaseInstrumentor | None:
|
|
43
|
+
if not is_package_installed("boto3"):
|
|
44
|
+
return None
|
|
45
|
+
if not is_package_installed("opentelemetry-instrumentation-bedrock"):
|
|
46
|
+
return None
|
|
47
|
+
|
|
48
|
+
from opentelemetry.instrumentation.bedrock import BedrockInstrumentor
|
|
49
|
+
|
|
50
|
+
return BedrockInstrumentor()
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
class BrowserUseInstrumentorInitializer(InstrumentorInitializer):
|
|
54
|
+
"""Instruments for different versions of browser-use:
|
|
55
|
+
|
|
56
|
+
- browser-use < 0.5: BrowserUseLegacyInstrumentor to track agent_step and
|
|
57
|
+
other structure spans. Session instrumentation is controlled by
|
|
58
|
+
Instruments.PLAYWRIGHT (or Instruments.PATCHRIGHT for several versions
|
|
59
|
+
in 0.4.* that used patchright)
|
|
60
|
+
- browser-use ~= 0.5: Structure spans live in browser_use package itself.
|
|
61
|
+
Session instrumentation is controlled by Instruments.PLAYWRIGHT
|
|
62
|
+
- browser-use >= 0.6.0rc1: BubusInstrumentor to keep spans structure.
|
|
63
|
+
Session instrumentation is controlled by Instruments.BROWSER_USE_SESSION
|
|
64
|
+
"""
|
|
65
|
+
|
|
66
|
+
def init_instrumentor(self, *args, **kwargs) -> BaseInstrumentor | None:
|
|
67
|
+
if not is_package_installed("browser-use"):
|
|
68
|
+
return None
|
|
69
|
+
|
|
70
|
+
version = get_package_version("browser-use")
|
|
71
|
+
from packaging.version import parse
|
|
72
|
+
|
|
73
|
+
if version and parse(version) < parse("0.5.0"):
|
|
74
|
+
from lmnr.sdk.browser.browser_use_otel import BrowserUseLegacyInstrumentor
|
|
75
|
+
|
|
76
|
+
return BrowserUseLegacyInstrumentor()
|
|
77
|
+
|
|
78
|
+
return None
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
class BrowserUseSessionInstrumentorInitializer(InstrumentorInitializer):
|
|
82
|
+
def init_instrumentor(
|
|
83
|
+
self, async_client, *args, **kwargs
|
|
84
|
+
) -> BaseInstrumentor | None:
|
|
85
|
+
if not is_package_installed("browser-use"):
|
|
86
|
+
return None
|
|
87
|
+
|
|
88
|
+
version = get_package_version("browser-use")
|
|
89
|
+
from packaging.version import parse
|
|
90
|
+
|
|
91
|
+
if version and parse(version) >= parse("0.6.0rc1"):
|
|
92
|
+
from lmnr.sdk.browser.browser_use_cdp_otel import BrowserUseInstrumentor
|
|
93
|
+
|
|
94
|
+
if async_client is None:
|
|
95
|
+
return None
|
|
96
|
+
|
|
97
|
+
return BrowserUseInstrumentor(async_client)
|
|
98
|
+
|
|
99
|
+
return None
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
class BubusInstrumentorInitializer(InstrumentorInitializer):
|
|
103
|
+
def init_instrumentor(self, *args, **kwargs) -> BaseInstrumentor | None:
|
|
104
|
+
if not is_package_installed("bubus"):
|
|
105
|
+
return None
|
|
106
|
+
|
|
107
|
+
from lmnr.sdk.browser.bubus_otel import BubusInstrumentor
|
|
108
|
+
|
|
109
|
+
return BubusInstrumentor()
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
class ChromaInstrumentorInitializer(InstrumentorInitializer):
|
|
113
|
+
def init_instrumentor(self, *args, **kwargs) -> BaseInstrumentor | None:
|
|
114
|
+
if not is_package_installed("chromadb"):
|
|
115
|
+
return None
|
|
116
|
+
if not is_package_installed("opentelemetry-instrumentation-chromadb"):
|
|
117
|
+
return None
|
|
118
|
+
|
|
119
|
+
from opentelemetry.instrumentation.chromadb import ChromaInstrumentor
|
|
120
|
+
|
|
121
|
+
return ChromaInstrumentor()
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
class ClaudeAgentInstrumentorInitializer(InstrumentorInitializer):
|
|
125
|
+
def init_instrumentor(self, *args, **kwargs) -> BaseInstrumentor | None:
|
|
126
|
+
if not is_package_installed("claude-agent-sdk"):
|
|
127
|
+
return None
|
|
128
|
+
|
|
129
|
+
if not is_package_installed("lmnr-claude-code-proxy"):
|
|
130
|
+
return None
|
|
131
|
+
|
|
132
|
+
from ..opentelemetry.instrumentation.claude_agent import ClaudeAgentInstrumentor
|
|
133
|
+
|
|
134
|
+
return ClaudeAgentInstrumentor()
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
class CohereInstrumentorInitializer(InstrumentorInitializer):
|
|
138
|
+
def init_instrumentor(self, *args, **kwargs) -> BaseInstrumentor | None:
|
|
139
|
+
if not is_package_installed("cohere"):
|
|
140
|
+
return None
|
|
141
|
+
if not is_package_installed("opentelemetry-instrumentation-cohere"):
|
|
142
|
+
return None
|
|
143
|
+
|
|
144
|
+
from opentelemetry.instrumentation.cohere import CohereInstrumentor
|
|
145
|
+
|
|
146
|
+
return CohereInstrumentor()
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
class CrewAIInstrumentorInitializer(InstrumentorInitializer):
|
|
150
|
+
def init_instrumentor(self, *args, **kwargs) -> BaseInstrumentor | None:
|
|
151
|
+
if not is_package_installed("crewai"):
|
|
152
|
+
return None
|
|
153
|
+
if not is_package_installed("opentelemetry-instrumentation-crewai"):
|
|
154
|
+
return None
|
|
155
|
+
|
|
156
|
+
from opentelemetry.instrumentation.crewai import CrewAiInstrumentor
|
|
157
|
+
|
|
158
|
+
return CrewAiInstrumentor()
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
class CuaAgentInstrumentorInitializer(InstrumentorInitializer):
|
|
162
|
+
def init_instrumentor(self, *args, **kwargs) -> BaseInstrumentor | None:
|
|
163
|
+
if not is_package_installed("cua-agent"):
|
|
164
|
+
return None
|
|
165
|
+
|
|
166
|
+
from ..opentelemetry.instrumentation.cua_agent import CuaAgentInstrumentor
|
|
167
|
+
|
|
168
|
+
return CuaAgentInstrumentor()
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
class CuaComputerInstrumentorInitializer(InstrumentorInitializer):
|
|
172
|
+
def init_instrumentor(self, *args, **kwargs) -> BaseInstrumentor | None:
|
|
173
|
+
if not is_package_installed("cua-computer"):
|
|
174
|
+
return None
|
|
175
|
+
|
|
176
|
+
from ..opentelemetry.instrumentation.cua_computer import CuaComputerInstrumentor
|
|
177
|
+
|
|
178
|
+
return CuaComputerInstrumentor()
|
|
179
|
+
|
|
180
|
+
|
|
181
|
+
class GoogleGenAIInstrumentorInitializer(InstrumentorInitializer):
|
|
182
|
+
def init_instrumentor(self, *args, **kwargs) -> BaseInstrumentor | None:
|
|
183
|
+
if not is_package_installed("google-genai"):
|
|
184
|
+
return None
|
|
185
|
+
|
|
186
|
+
from ..opentelemetry.instrumentation.google_genai import (
|
|
187
|
+
GoogleGenAiSdkInstrumentor,
|
|
188
|
+
)
|
|
189
|
+
|
|
190
|
+
return GoogleGenAiSdkInstrumentor()
|
|
191
|
+
|
|
192
|
+
|
|
193
|
+
class GroqInstrumentorInitializer(InstrumentorInitializer):
|
|
194
|
+
def init_instrumentor(self, *args, **kwargs) -> BaseInstrumentor | None:
|
|
195
|
+
if not is_package_installed("groq"):
|
|
196
|
+
return None
|
|
197
|
+
|
|
198
|
+
from ..opentelemetry.instrumentation.groq import GroqInstrumentor
|
|
199
|
+
|
|
200
|
+
return GroqInstrumentor()
|
|
201
|
+
|
|
202
|
+
|
|
203
|
+
class HaystackInstrumentorInitializer(InstrumentorInitializer):
|
|
204
|
+
def init_instrumentor(self, *args, **kwargs) -> BaseInstrumentor | None:
|
|
205
|
+
if not is_package_installed("haystack"):
|
|
206
|
+
return None
|
|
207
|
+
if not is_package_installed("opentelemetry-instrumentation-haystack"):
|
|
208
|
+
return None
|
|
209
|
+
|
|
210
|
+
from opentelemetry.instrumentation.haystack import HaystackInstrumentor
|
|
211
|
+
|
|
212
|
+
return HaystackInstrumentor()
|
|
213
|
+
|
|
214
|
+
|
|
215
|
+
class KernelInstrumentorInitializer(InstrumentorInitializer):
|
|
216
|
+
def init_instrumentor(self, *args, **kwargs) -> BaseInstrumentor | None:
|
|
217
|
+
if not is_package_installed("kernel"):
|
|
218
|
+
return None
|
|
219
|
+
|
|
220
|
+
from ..opentelemetry.instrumentation.kernel import KernelInstrumentor
|
|
221
|
+
|
|
222
|
+
return KernelInstrumentor()
|
|
223
|
+
|
|
224
|
+
|
|
225
|
+
class LanceDBInstrumentorInitializer(InstrumentorInitializer):
|
|
226
|
+
def init_instrumentor(self, *args, **kwargs) -> BaseInstrumentor | None:
|
|
227
|
+
if not is_package_installed("lancedb"):
|
|
228
|
+
return None
|
|
229
|
+
if not is_package_installed("opentelemetry-instrumentation-lancedb"):
|
|
230
|
+
return None
|
|
231
|
+
|
|
232
|
+
from opentelemetry.instrumentation.lancedb import LanceInstrumentor
|
|
233
|
+
|
|
234
|
+
return LanceInstrumentor()
|
|
235
|
+
|
|
236
|
+
|
|
237
|
+
class LangchainInstrumentorInitializer(InstrumentorInitializer):
|
|
238
|
+
def init_instrumentor(self, *args, **kwargs) -> BaseInstrumentor | None:
|
|
239
|
+
if not is_package_installed("langchain"):
|
|
240
|
+
return None
|
|
241
|
+
if not is_package_installed("opentelemetry-instrumentation-langchain"):
|
|
242
|
+
return None
|
|
243
|
+
|
|
244
|
+
from opentelemetry.instrumentation.langchain import LangchainInstrumentor
|
|
245
|
+
|
|
246
|
+
return LangchainInstrumentor()
|
|
247
|
+
|
|
248
|
+
|
|
249
|
+
class LanggraphInstrumentorInitializer(InstrumentorInitializer):
|
|
250
|
+
def init_instrumentor(self, *args, **kwargs) -> BaseInstrumentor | None:
|
|
251
|
+
if not is_package_installed("langgraph"):
|
|
252
|
+
return None
|
|
253
|
+
if not is_package_installed("langchain-core"):
|
|
254
|
+
return None
|
|
255
|
+
|
|
256
|
+
from ..opentelemetry.instrumentation.langgraph import LanggraphInstrumentor
|
|
257
|
+
|
|
258
|
+
return LanggraphInstrumentor()
|
|
259
|
+
|
|
260
|
+
|
|
261
|
+
class LlamaIndexInstrumentorInitializer(InstrumentorInitializer):
|
|
262
|
+
def init_instrumentor(self, *args, **kwargs) -> BaseInstrumentor | None:
|
|
263
|
+
if not (
|
|
264
|
+
is_package_installed("llama-index") or is_package_installed("llama_index")
|
|
265
|
+
):
|
|
266
|
+
return None
|
|
267
|
+
if not is_package_installed("opentelemetry-instrumentation-llamaindex"):
|
|
268
|
+
return None
|
|
269
|
+
|
|
270
|
+
from opentelemetry.instrumentation.llamaindex import LlamaIndexInstrumentor
|
|
271
|
+
|
|
272
|
+
return LlamaIndexInstrumentor()
|
|
273
|
+
|
|
274
|
+
|
|
275
|
+
class MarqoInstrumentorInitializer(InstrumentorInitializer):
|
|
276
|
+
def init_instrumentor(self, *args, **kwargs) -> BaseInstrumentor | None:
|
|
277
|
+
if not is_package_installed("marqo"):
|
|
278
|
+
return None
|
|
279
|
+
if not is_package_installed("opentelemetry-instrumentation-marqo"):
|
|
280
|
+
return None
|
|
281
|
+
|
|
282
|
+
from opentelemetry.instrumentation.marqo import MarqoInstrumentor
|
|
283
|
+
|
|
284
|
+
return MarqoInstrumentor()
|
|
285
|
+
|
|
286
|
+
|
|
287
|
+
class MCPInstrumentorInitializer(InstrumentorInitializer):
|
|
288
|
+
def init_instrumentor(self, *args, **kwargs) -> BaseInstrumentor | None:
|
|
289
|
+
if not is_package_installed("mcp"):
|
|
290
|
+
return None
|
|
291
|
+
if not is_package_installed("opentelemetry-instrumentation-mcp"):
|
|
292
|
+
return None
|
|
293
|
+
|
|
294
|
+
from opentelemetry.instrumentation.mcp import McpInstrumentor
|
|
295
|
+
|
|
296
|
+
return McpInstrumentor()
|
|
297
|
+
|
|
298
|
+
|
|
299
|
+
class MilvusInstrumentorInitializer(InstrumentorInitializer):
|
|
300
|
+
def init_instrumentor(self, *args, **kwargs) -> BaseInstrumentor | None:
|
|
301
|
+
if not is_package_installed("pymilvus"):
|
|
302
|
+
return None
|
|
303
|
+
if not is_package_installed("opentelemetry-instrumentation-milvus"):
|
|
304
|
+
return None
|
|
305
|
+
|
|
306
|
+
from opentelemetry.instrumentation.milvus import MilvusInstrumentor
|
|
307
|
+
|
|
308
|
+
return MilvusInstrumentor()
|
|
309
|
+
|
|
310
|
+
|
|
311
|
+
class MistralInstrumentorInitializer(InstrumentorInitializer):
|
|
312
|
+
def init_instrumentor(self, *args, **kwargs) -> BaseInstrumentor | None:
|
|
313
|
+
if not is_package_installed("mistralai"):
|
|
314
|
+
return None
|
|
315
|
+
if not is_package_installed("opentelemetry-instrumentation-mistralai"):
|
|
316
|
+
return None
|
|
317
|
+
|
|
318
|
+
from opentelemetry.instrumentation.mistralai import MistralAiInstrumentor
|
|
319
|
+
|
|
320
|
+
return MistralAiInstrumentor()
|
|
321
|
+
|
|
322
|
+
|
|
323
|
+
class OllamaInstrumentorInitializer(InstrumentorInitializer):
|
|
324
|
+
def init_instrumentor(self, *args, **kwargs) -> BaseInstrumentor | None:
|
|
325
|
+
if not is_package_installed("ollama"):
|
|
326
|
+
return None
|
|
327
|
+
if not is_package_installed("opentelemetry-instrumentation-ollama"):
|
|
328
|
+
return None
|
|
329
|
+
|
|
330
|
+
from opentelemetry.instrumentation.ollama import OllamaInstrumentor
|
|
331
|
+
|
|
332
|
+
return OllamaInstrumentor()
|
|
333
|
+
|
|
334
|
+
|
|
335
|
+
class OpenAIInstrumentorInitializer(InstrumentorInitializer):
|
|
336
|
+
def init_instrumentor(self, *args, **kwargs) -> BaseInstrumentor | None:
|
|
337
|
+
if not is_package_installed("openai"):
|
|
338
|
+
return None
|
|
339
|
+
|
|
340
|
+
from ..opentelemetry.instrumentation.openai import OpenAIInstrumentor
|
|
341
|
+
|
|
342
|
+
return OpenAIInstrumentor(
|
|
343
|
+
# Default in the package provided is an empty function, which
|
|
344
|
+
# results in dropping the image data if we don't explicitly
|
|
345
|
+
# set it to None.
|
|
346
|
+
upload_base64_image=None,
|
|
347
|
+
)
|
|
348
|
+
|
|
349
|
+
|
|
350
|
+
class OpenHandsAIInstrumentorInitializer(InstrumentorInitializer):
|
|
351
|
+
def init_instrumentor(self, *args, **kwargs) -> BaseInstrumentor | None:
|
|
352
|
+
if not is_package_installed("openhands-ai"):
|
|
353
|
+
return None
|
|
354
|
+
from ..opentelemetry.instrumentation.openhands_ai import OpenHandsInstrumentor
|
|
355
|
+
|
|
356
|
+
return OpenHandsInstrumentor()
|
|
357
|
+
|
|
358
|
+
|
|
359
|
+
class OpenTelemetryInstrumentorInitializer(InstrumentorInitializer):
|
|
360
|
+
def init_instrumentor(self, *args, **kwargs) -> BaseInstrumentor | None:
|
|
361
|
+
from ..opentelemetry.instrumentation.opentelemetry import (
|
|
362
|
+
OpentelemetryInstrumentor,
|
|
363
|
+
)
|
|
364
|
+
|
|
365
|
+
return OpentelemetryInstrumentor()
|
|
366
|
+
|
|
367
|
+
|
|
368
|
+
class PatchrightInstrumentorInitializer(InstrumentorInitializer):
|
|
369
|
+
def init_instrumentor(
|
|
370
|
+
self, async_client, *args, **kwargs
|
|
371
|
+
) -> BaseInstrumentor | None:
|
|
372
|
+
if not is_package_installed("patchright"):
|
|
373
|
+
return None
|
|
374
|
+
|
|
375
|
+
from lmnr.sdk.browser.patchright_otel import PatchrightInstrumentor
|
|
376
|
+
|
|
377
|
+
if async_client is None:
|
|
378
|
+
return None
|
|
379
|
+
|
|
380
|
+
return PatchrightInstrumentor(async_client)
|
|
381
|
+
|
|
382
|
+
|
|
383
|
+
class PineconeInstrumentorInitializer(InstrumentorInitializer):
|
|
384
|
+
def init_instrumentor(self, *args, **kwargs) -> BaseInstrumentor | None:
|
|
385
|
+
if not is_package_installed("pinecone"):
|
|
386
|
+
return None
|
|
387
|
+
if not is_package_installed("opentelemetry-instrumentation-pinecone"):
|
|
388
|
+
return None
|
|
389
|
+
|
|
390
|
+
from opentelemetry.instrumentation.pinecone import PineconeInstrumentor
|
|
391
|
+
|
|
392
|
+
return PineconeInstrumentor()
|
|
393
|
+
|
|
394
|
+
|
|
395
|
+
class PlaywrightInstrumentorInitializer(InstrumentorInitializer):
|
|
396
|
+
def init_instrumentor(
|
|
397
|
+
self, async_client, *args, **kwargs
|
|
398
|
+
) -> BaseInstrumentor | None:
|
|
399
|
+
if not is_package_installed("playwright"):
|
|
400
|
+
return None
|
|
401
|
+
|
|
402
|
+
from lmnr.sdk.browser.playwright_otel import PlaywrightInstrumentor
|
|
403
|
+
|
|
404
|
+
if async_client is None:
|
|
405
|
+
return None
|
|
406
|
+
|
|
407
|
+
return PlaywrightInstrumentor(async_client)
|
|
408
|
+
|
|
409
|
+
|
|
410
|
+
class QdrantInstrumentorInitializer(InstrumentorInitializer):
|
|
411
|
+
def init_instrumentor(self, *args, **kwargs) -> BaseInstrumentor | None:
|
|
412
|
+
if not is_package_installed("qdrant_client"):
|
|
413
|
+
return None
|
|
414
|
+
if not is_package_installed("opentelemetry-instrumentation-qdrant"):
|
|
415
|
+
return None
|
|
416
|
+
|
|
417
|
+
from opentelemetry.instrumentation.qdrant import QdrantInstrumentor
|
|
418
|
+
|
|
419
|
+
return QdrantInstrumentor()
|
|
420
|
+
|
|
421
|
+
|
|
422
|
+
class ReplicateInstrumentorInitializer(InstrumentorInitializer):
|
|
423
|
+
def init_instrumentor(self, *args, **kwargs) -> BaseInstrumentor | None:
|
|
424
|
+
if not is_package_installed("replicate"):
|
|
425
|
+
return None
|
|
426
|
+
if not is_package_installed("opentelemetry-instrumentation-replicate"):
|
|
427
|
+
return None
|
|
428
|
+
|
|
429
|
+
from opentelemetry.instrumentation.replicate import ReplicateInstrumentor
|
|
430
|
+
|
|
431
|
+
return ReplicateInstrumentor()
|
|
432
|
+
|
|
433
|
+
|
|
434
|
+
class SageMakerInstrumentorInitializer(InstrumentorInitializer):
|
|
435
|
+
def init_instrumentor(self, *args, **kwargs) -> BaseInstrumentor | None:
|
|
436
|
+
if not is_package_installed("boto3"):
|
|
437
|
+
return None
|
|
438
|
+
if not is_package_installed("opentelemetry-instrumentation-sagemaker"):
|
|
439
|
+
return None
|
|
440
|
+
|
|
441
|
+
from opentelemetry.instrumentation.sagemaker import SageMakerInstrumentor
|
|
442
|
+
|
|
443
|
+
return SageMakerInstrumentor()
|
|
444
|
+
|
|
445
|
+
|
|
446
|
+
class SkyvernInstrumentorInitializer(InstrumentorInitializer):
|
|
447
|
+
def init_instrumentor(self, *args, **kwargs) -> BaseInstrumentor | None:
|
|
448
|
+
if not is_package_installed("skyvern"):
|
|
449
|
+
return None
|
|
450
|
+
|
|
451
|
+
from ..opentelemetry.instrumentation.skyvern import SkyvernInstrumentor
|
|
452
|
+
|
|
453
|
+
return SkyvernInstrumentor()
|
|
454
|
+
|
|
455
|
+
|
|
456
|
+
class TogetherInstrumentorInitializer(InstrumentorInitializer):
|
|
457
|
+
def init_instrumentor(self, *args, **kwargs) -> BaseInstrumentor | None:
|
|
458
|
+
if not is_package_installed("together"):
|
|
459
|
+
return None
|
|
460
|
+
if not is_package_installed("opentelemetry-instrumentation-together"):
|
|
461
|
+
return None
|
|
462
|
+
|
|
463
|
+
from opentelemetry.instrumentation.together import TogetherAiInstrumentor
|
|
464
|
+
|
|
465
|
+
return TogetherAiInstrumentor()
|
|
466
|
+
|
|
467
|
+
|
|
468
|
+
class TransformersInstrumentorInitializer(InstrumentorInitializer):
|
|
469
|
+
def init_instrumentor(self, *args, **kwargs) -> BaseInstrumentor | None:
|
|
470
|
+
if not is_package_installed("transformers"):
|
|
471
|
+
return None
|
|
472
|
+
if not is_package_installed("opentelemetry-instrumentation-transformers"):
|
|
473
|
+
return None
|
|
474
|
+
|
|
475
|
+
from opentelemetry.instrumentation.transformers import TransformersInstrumentor
|
|
476
|
+
|
|
477
|
+
return TransformersInstrumentor()
|
|
478
|
+
|
|
479
|
+
|
|
480
|
+
class VertexAIInstrumentorInitializer(InstrumentorInitializer):
|
|
481
|
+
def init_instrumentor(self, *args, **kwargs) -> BaseInstrumentor | None:
|
|
482
|
+
if not is_package_installed("vertexai"):
|
|
483
|
+
return None
|
|
484
|
+
if not is_package_installed("opentelemetry-instrumentation-vertexai"):
|
|
485
|
+
return None
|
|
486
|
+
|
|
487
|
+
from opentelemetry.instrumentation.vertexai import VertexAIInstrumentor
|
|
488
|
+
|
|
489
|
+
return VertexAIInstrumentor()
|
|
490
|
+
|
|
491
|
+
|
|
492
|
+
class WatsonxInstrumentorInitializer(InstrumentorInitializer):
|
|
493
|
+
def init_instrumentor(self, *args, **kwargs) -> BaseInstrumentor | None:
|
|
494
|
+
if not (
|
|
495
|
+
is_package_installed("ibm-watsonx-ai")
|
|
496
|
+
or is_package_installed("ibm-watson-machine-learning")
|
|
497
|
+
):
|
|
498
|
+
return None
|
|
499
|
+
if not is_package_installed("opentelemetry-instrumentation-watsonx"):
|
|
500
|
+
return None
|
|
501
|
+
|
|
502
|
+
from opentelemetry.instrumentation.watsonx import WatsonxInstrumentor
|
|
503
|
+
|
|
504
|
+
return WatsonxInstrumentor()
|
|
505
|
+
|
|
506
|
+
|
|
507
|
+
class WeaviateInstrumentorInitializer(InstrumentorInitializer):
|
|
508
|
+
def init_instrumentor(self, *args, **kwargs) -> BaseInstrumentor | None:
|
|
509
|
+
if not is_package_installed("weaviate"):
|
|
510
|
+
return None
|
|
511
|
+
if not is_package_installed("opentelemetry-instrumentation-weaviate"):
|
|
512
|
+
return None
|
|
513
|
+
|
|
514
|
+
from opentelemetry.instrumentation.weaviate import WeaviateInstrumentor
|
|
515
|
+
|
|
516
|
+
return WeaviateInstrumentor()
|
|
@@ -1,16 +1,30 @@
|
|
|
1
1
|
from enum import Enum
|
|
2
|
+
from opentelemetry.semconv._incubating.attributes.gen_ai_attributes import (
|
|
3
|
+
GEN_AI_SYSTEM,
|
|
4
|
+
GEN_AI_REQUEST_MODEL,
|
|
5
|
+
GEN_AI_RESPONSE_MODEL,
|
|
6
|
+
GEN_AI_USAGE_INPUT_TOKENS,
|
|
7
|
+
GEN_AI_USAGE_OUTPUT_TOKENS,
|
|
8
|
+
GEN_AI_RESPONSE_ID,
|
|
9
|
+
)
|
|
2
10
|
from opentelemetry.semconv_ai import SpanAttributes
|
|
3
11
|
|
|
4
12
|
SPAN_INPUT = "lmnr.span.input"
|
|
5
13
|
SPAN_OUTPUT = "lmnr.span.output"
|
|
6
14
|
SPAN_TYPE = "lmnr.span.type"
|
|
7
15
|
SPAN_PATH = "lmnr.span.path"
|
|
16
|
+
SPAN_IDS_PATH = "lmnr.span.ids_path"
|
|
17
|
+
PARENT_SPAN_PATH = "lmnr.span.parent_path"
|
|
18
|
+
PARENT_SPAN_IDS_PATH = "lmnr.span.parent_ids_path"
|
|
8
19
|
SPAN_INSTRUMENTATION_SOURCE = "lmnr.span.instrumentation_source"
|
|
9
|
-
|
|
20
|
+
SPAN_SDK_VERSION = "lmnr.span.sdk_version"
|
|
21
|
+
SPAN_LANGUAGE_VERSION = "lmnr.span.language_version"
|
|
22
|
+
HUMAN_EVALUATOR_OPTIONS = "lmnr.span.human_evaluator_options"
|
|
10
23
|
|
|
11
24
|
ASSOCIATION_PROPERTIES = "lmnr.association.properties"
|
|
12
25
|
SESSION_ID = "session_id"
|
|
13
26
|
USER_ID = "user_id"
|
|
27
|
+
METADATA = "metadata"
|
|
14
28
|
TRACE_TYPE = "trace_type"
|
|
15
29
|
TRACING_LEVEL = "tracing_level"
|
|
16
30
|
|
|
@@ -19,14 +33,12 @@ TRACING_LEVEL = "tracing_level"
|
|
|
19
33
|
class Attributes(Enum):
|
|
20
34
|
# == This is the minimum set of attributes for a proper LLM span ==
|
|
21
35
|
#
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
# not SpanAttributes.LLM_USAGE_COMPLETION_TOKENS,
|
|
25
|
-
OUTPUT_TOKEN_COUNT = "gen_ai.usage.output_tokens"
|
|
36
|
+
INPUT_TOKEN_COUNT = GEN_AI_USAGE_INPUT_TOKENS
|
|
37
|
+
OUTPUT_TOKEN_COUNT = GEN_AI_USAGE_OUTPUT_TOKENS
|
|
26
38
|
TOTAL_TOKEN_COUNT = SpanAttributes.LLM_USAGE_TOTAL_TOKENS
|
|
27
|
-
PROVIDER =
|
|
28
|
-
REQUEST_MODEL =
|
|
29
|
-
RESPONSE_MODEL =
|
|
39
|
+
PROVIDER = GEN_AI_SYSTEM
|
|
40
|
+
REQUEST_MODEL = GEN_AI_REQUEST_MODEL
|
|
41
|
+
RESPONSE_MODEL = GEN_AI_RESPONSE_MODEL
|
|
30
42
|
#
|
|
31
43
|
## == End of minimum set ==
|
|
32
44
|
# == Additional attributes ==
|
|
@@ -34,5 +46,6 @@ class Attributes(Enum):
|
|
|
34
46
|
INPUT_COST = "gen_ai.usage.input_cost"
|
|
35
47
|
OUTPUT_COST = "gen_ai.usage.output_cost"
|
|
36
48
|
TOTAL_COST = "gen_ai.usage.cost"
|
|
49
|
+
RESPONSE_ID = GEN_AI_RESPONSE_ID
|
|
37
50
|
#
|
|
38
51
|
# == End of additional attributes ==
|