lmnr 0.5.1a0__py3-none-any.whl → 0.5.2__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 +0 -8
- lmnr/openllmetry_sdk/__init__.py +5 -33
- lmnr/openllmetry_sdk/decorators/base.py +24 -17
- lmnr/openllmetry_sdk/instruments.py +1 -0
- lmnr/openllmetry_sdk/opentelemetry/instrumentation/google_genai/__init__.py +454 -0
- lmnr/openllmetry_sdk/opentelemetry/instrumentation/google_genai/config.py +9 -0
- lmnr/openllmetry_sdk/opentelemetry/instrumentation/google_genai/utils.py +216 -0
- lmnr/openllmetry_sdk/tracing/__init__.py +1 -0
- lmnr/openllmetry_sdk/tracing/context_manager.py +13 -0
- lmnr/openllmetry_sdk/tracing/tracing.py +230 -252
- lmnr/sdk/browser/playwright_otel.py +42 -58
- lmnr/sdk/browser/pw_utils.py +8 -40
- lmnr/sdk/client/asynchronous/async_client.py +0 -34
- lmnr/sdk/client/asynchronous/resources/__init__.py +0 -4
- lmnr/sdk/client/asynchronous/resources/agent.py +96 -6
- lmnr/sdk/client/synchronous/resources/__init__.py +1 -3
- lmnr/sdk/client/synchronous/resources/agent.py +94 -8
- lmnr/sdk/client/synchronous/sync_client.py +0 -36
- lmnr/sdk/decorators.py +16 -2
- lmnr/sdk/laminar.py +3 -3
- lmnr/sdk/types.py +84 -170
- lmnr/sdk/utils.py +8 -1
- lmnr/version.py +1 -1
- {lmnr-0.5.1a0.dist-info → lmnr-0.5.2.dist-info}/METADATA +57 -57
- lmnr-0.5.2.dist-info/RECORD +54 -0
- lmnr/sdk/client/asynchronous/resources/pipeline.py +0 -89
- lmnr/sdk/client/asynchronous/resources/semantic_search.py +0 -60
- lmnr/sdk/client/synchronous/resources/pipeline.py +0 -89
- lmnr/sdk/client/synchronous/resources/semantic_search.py +0 -60
- lmnr-0.5.1a0.dist-info/RECORD +0 -54
- {lmnr-0.5.1a0.dist-info → lmnr-0.5.2.dist-info}/LICENSE +0 -0
- {lmnr-0.5.1a0.dist-info → lmnr-0.5.2.dist-info}/WHEEL +0 -0
- {lmnr-0.5.1a0.dist-info → lmnr-0.5.2.dist-info}/entry_points.txt +0 -0
@@ -4,6 +4,8 @@ import logging
|
|
4
4
|
import uuid
|
5
5
|
|
6
6
|
from contextvars import Context
|
7
|
+
from lmnr.sdk.client.asynchronous.async_client import AsyncLaminarClient
|
8
|
+
from lmnr.sdk.client.synchronous.sync_client import LaminarClient
|
7
9
|
from lmnr.sdk.log import VerboseColorfulFormatter
|
8
10
|
from lmnr.openllmetry_sdk.instruments import Instruments
|
9
11
|
from lmnr.openllmetry_sdk.tracing.attributes import (
|
@@ -25,8 +27,8 @@ from opentelemetry.exporter.otlp.proto.http.trace_exporter import (
|
|
25
27
|
from opentelemetry.exporter.otlp.proto.grpc.trace_exporter import (
|
26
28
|
OTLPSpanExporter as GRPCExporter,
|
27
29
|
)
|
28
|
-
from opentelemetry.instrumentation.instrumentor import BaseInstrumentor
|
29
30
|
from opentelemetry.exporter.otlp.proto.grpc.trace_exporter import Compression
|
31
|
+
from opentelemetry.instrumentation.threading import ThreadingInstrumentor
|
30
32
|
from opentelemetry.context import get_value, attach, get_current, set_value
|
31
33
|
from opentelemetry.propagate import set_global_textmap
|
32
34
|
from opentelemetry.propagators.textmap import TextMapPropagator
|
@@ -37,7 +39,7 @@ from opentelemetry.sdk.trace.export import (
|
|
37
39
|
SimpleSpanProcessor,
|
38
40
|
BatchSpanProcessor,
|
39
41
|
)
|
40
|
-
from opentelemetry.trace import ProxyTracerProvider
|
42
|
+
from opentelemetry.trace import get_tracer_provider, ProxyTracerProvider
|
41
43
|
|
42
44
|
from typing import Dict, Optional, Set
|
43
45
|
|
@@ -69,14 +71,24 @@ EXCLUDED_URLS = """
|
|
69
71
|
openaipublic.blob.core.windows.net"""
|
70
72
|
|
71
73
|
MAX_EVENTS_OR_ATTRIBUTES_PER_SPAN = 5000
|
72
|
-
instrumentors: dict[str, BaseInstrumentor] = {}
|
73
74
|
|
74
75
|
|
75
76
|
class TracerWrapper(object):
|
77
|
+
resource_attributes: dict = {}
|
78
|
+
enable_content_tracing: bool = True
|
79
|
+
endpoint: str = None
|
80
|
+
headers: Dict[str, str] = {}
|
76
81
|
__tracer_provider: TracerProvider = None
|
77
|
-
|
78
|
-
|
79
|
-
|
82
|
+
__logger: logging.Logger = None
|
83
|
+
__span_id_to_path: dict[int, list[str]] = {}
|
84
|
+
__span_id_lists: dict[int, list[str]] = {}
|
85
|
+
__client: LaminarClient = None
|
86
|
+
__async_client: AsyncLaminarClient = None
|
87
|
+
__spans_processor: SpanProcessor = None
|
88
|
+
__spans_exporter: SpanExporter = None
|
89
|
+
|
90
|
+
def __new__(
|
91
|
+
cls,
|
80
92
|
disable_batch=False,
|
81
93
|
processor: Optional[SpanProcessor] = None,
|
82
94
|
propagator: Optional[TextMapPropagator] = None,
|
@@ -86,73 +98,82 @@ class TracerWrapper(object):
|
|
86
98
|
base_http_url: Optional[str] = None,
|
87
99
|
project_api_key: Optional[str] = None,
|
88
100
|
max_export_batch_size: Optional[int] = None,
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
console_log_handler = logging.StreamHandler()
|
100
|
-
console_log_handler.setFormatter(VerboseColorfulFormatter())
|
101
|
-
console_log_handler.setLevel(logging.INFO)
|
102
|
-
self.__logger.addHandler(console_log_handler)
|
103
|
-
self.__span_id_to_path = {}
|
104
|
-
self.__span_id_lists = {}
|
105
|
-
|
106
|
-
if not self.endpoint:
|
107
|
-
return
|
108
|
-
|
109
|
-
self.__resource = Resource(attributes=self.resource_attributes)
|
110
|
-
self.__tracer_provider = init_tracer_provider(resource=self.__resource)
|
111
|
-
if processor:
|
112
|
-
self.__spans_processor = processor
|
113
|
-
self.__spans_processor_original_on_start = processor.on_start
|
114
|
-
else:
|
115
|
-
self.__spans_exporter = (
|
116
|
-
exporter
|
117
|
-
if exporter
|
118
|
-
else init_spans_exporter(self.endpoint, self.headers)
|
101
|
+
) -> "TracerWrapper":
|
102
|
+
cls._initialize_logger(cls)
|
103
|
+
if not hasattr(cls, "instance"):
|
104
|
+
obj = cls.instance = super(TracerWrapper, cls).__new__(cls)
|
105
|
+
if not TracerWrapper.endpoint:
|
106
|
+
return obj
|
107
|
+
|
108
|
+
obj.__client = LaminarClient(
|
109
|
+
base_url=base_http_url,
|
110
|
+
project_api_key=project_api_key,
|
119
111
|
)
|
120
|
-
|
121
|
-
|
112
|
+
obj.__async_client = AsyncLaminarClient(
|
113
|
+
base_url=base_http_url,
|
114
|
+
project_api_key=project_api_key,
|
115
|
+
)
|
116
|
+
|
117
|
+
obj.__resource = Resource(attributes=TracerWrapper.resource_attributes)
|
118
|
+
obj.__tracer_provider = init_tracer_provider(resource=obj.__resource)
|
119
|
+
if processor:
|
120
|
+
obj.__spans_processor = processor
|
121
|
+
obj.__spans_processor_original_on_start = processor.on_start
|
122
122
|
else:
|
123
|
-
|
124
|
-
|
125
|
-
|
123
|
+
obj.__spans_exporter = (
|
124
|
+
exporter
|
125
|
+
if exporter
|
126
|
+
else init_spans_exporter(
|
127
|
+
TracerWrapper.endpoint, TracerWrapper.headers
|
128
|
+
)
|
126
129
|
)
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
130
|
+
if disable_batch or is_notebook():
|
131
|
+
obj.__spans_processor = SimpleSpanProcessor(obj.__spans_exporter)
|
132
|
+
else:
|
133
|
+
obj.__spans_processor = BatchSpanProcessor(
|
134
|
+
obj.__spans_exporter,
|
135
|
+
max_export_batch_size=max_export_batch_size,
|
136
|
+
)
|
137
|
+
obj.__spans_processor_original_on_start = None
|
138
|
+
|
139
|
+
obj.__spans_processor.on_start = obj._span_processor_on_start
|
140
|
+
obj.__tracer_provider.add_span_processor(obj.__spans_processor)
|
141
|
+
|
142
|
+
if propagator:
|
143
|
+
set_global_textmap(propagator)
|
144
|
+
|
145
|
+
# this makes sure otel context is propagated so we always want it
|
146
|
+
ThreadingInstrumentor().instrument()
|
147
|
+
|
148
|
+
instrument_set = init_instrumentations(
|
149
|
+
should_enrich_metrics,
|
150
|
+
instruments,
|
151
|
+
client=obj.__client,
|
152
|
+
async_client=obj.__async_client,
|
153
|
+
)
|
134
154
|
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
base_http_url=base_http_url,
|
141
|
-
)
|
155
|
+
if not instrument_set:
|
156
|
+
cls.__logger.info(
|
157
|
+
"No instruments set through Laminar. "
|
158
|
+
"Only enabling basic OpenTelemetry tracing."
|
159
|
+
)
|
142
160
|
|
143
|
-
|
144
|
-
self.__logger.info(
|
145
|
-
"No instruments set through Laminar. "
|
146
|
-
"Only enabling basic OpenTelemetry tracing."
|
147
|
-
)
|
161
|
+
obj.__content_allow_list = ContentAllowList()
|
148
162
|
|
149
|
-
|
163
|
+
# Force flushes for debug environments (e.g. local development)
|
164
|
+
atexit.register(obj.exit_handler)
|
150
165
|
|
151
|
-
|
152
|
-
atexit.register(self.exit_handler)
|
166
|
+
return cls.instance
|
153
167
|
|
154
168
|
def exit_handler(self):
|
155
|
-
self.
|
169
|
+
self.__span_id_to_path = {}
|
170
|
+
self.flush()
|
171
|
+
|
172
|
+
def _initialize_logger(self):
|
173
|
+
self.__logger = logging.getLogger(__name__)
|
174
|
+
console_log_handler = logging.StreamHandler()
|
175
|
+
console_log_handler.setFormatter(VerboseColorfulFormatter())
|
176
|
+
self.__logger.addHandler(console_log_handler)
|
156
177
|
|
157
178
|
def _span_processor_on_start(
|
158
179
|
self, span: Span, parent_context: Optional[Context] = None
|
@@ -193,24 +214,30 @@ class TracerWrapper(object):
|
|
193
214
|
if self.__spans_processor_original_on_start:
|
194
215
|
self.__spans_processor_original_on_start(span, parent_context)
|
195
216
|
|
196
|
-
|
217
|
+
@staticmethod
|
218
|
+
def set_static_params(
|
219
|
+
resource_attributes: dict,
|
220
|
+
enable_content_tracing: bool,
|
221
|
+
endpoint: str,
|
222
|
+
headers: Dict[str, str],
|
223
|
+
) -> None:
|
224
|
+
TracerWrapper.resource_attributes = resource_attributes
|
225
|
+
TracerWrapper.enable_content_tracing = enable_content_tracing
|
226
|
+
TracerWrapper.endpoint = endpoint
|
227
|
+
TracerWrapper.headers = headers
|
228
|
+
|
229
|
+
@classmethod
|
230
|
+
def verify_initialized(cls) -> bool:
|
231
|
+
return hasattr(cls, "instance")
|
232
|
+
|
233
|
+
@classmethod
|
234
|
+
def clear(cls):
|
197
235
|
# Any state cleanup. Now used in between tests
|
198
|
-
|
199
|
-
|
236
|
+
cls.__span_id_to_path = {}
|
237
|
+
cls.__span_id_lists = {}
|
200
238
|
|
201
239
|
def shutdown(self):
|
202
|
-
|
203
|
-
self.__spans_processor.force_flush(timeout_millis=30000)
|
204
|
-
for v in instrumentors.values():
|
205
|
-
try:
|
206
|
-
v.uninstrument()
|
207
|
-
except Exception:
|
208
|
-
self.__logger.debug("Error uninstrumenting instrumentor", exc_info=True)
|
209
|
-
instrumentors = {}
|
210
|
-
self.__spans_processor.shutdown()
|
211
|
-
|
212
|
-
# Clean up attributes
|
213
|
-
self.clear_state()
|
240
|
+
self.__tracer_provider.shutdown()
|
214
241
|
|
215
242
|
def flush(self):
|
216
243
|
return self.__spans_processor.force_flush()
|
@@ -285,9 +312,11 @@ def init_spans_exporter(api_endpoint: str, headers: Dict[str, str]) -> SpanExpor
|
|
285
312
|
)
|
286
313
|
|
287
314
|
|
315
|
+
# TODO: check if it's safer to use the default tracer provider obtained from
|
316
|
+
# get_tracer_provider()
|
288
317
|
def init_tracer_provider(resource: Resource) -> TracerProvider:
|
289
318
|
provider: TracerProvider = None
|
290
|
-
default_provider: TracerProvider =
|
319
|
+
default_provider: TracerProvider = get_tracer_provider()
|
291
320
|
|
292
321
|
if isinstance(default_provider, ProxyTracerProvider):
|
293
322
|
provider = TracerProvider(resource=resource)
|
@@ -307,9 +336,8 @@ def init_instrumentations(
|
|
307
336
|
should_enrich_metrics: bool,
|
308
337
|
instruments: Optional[Set[Instruments]] = None,
|
309
338
|
block_instruments: Optional[Set[Instruments]] = None,
|
310
|
-
|
311
|
-
|
312
|
-
base_http_url: Optional[str] = None,
|
339
|
+
client: Optional[LaminarClient] = None,
|
340
|
+
async_client: Optional[AsyncLaminarClient] = None,
|
313
341
|
):
|
314
342
|
block_instruments = block_instruments or set()
|
315
343
|
# These libraries are not instrumented by default,
|
@@ -335,109 +363,100 @@ def init_instrumentations(
|
|
335
363
|
instrument_set = False
|
336
364
|
for instrument in instruments:
|
337
365
|
if instrument == Instruments.ALEPHALPHA:
|
338
|
-
if init_alephalpha_instrumentor(
|
366
|
+
if init_alephalpha_instrumentor():
|
339
367
|
instrument_set = True
|
340
368
|
elif instrument == Instruments.ANTHROPIC:
|
341
|
-
if init_anthropic_instrumentor(
|
342
|
-
should_enrich_metrics, tracer_provider=tracer_provider
|
343
|
-
):
|
369
|
+
if init_anthropic_instrumentor(should_enrich_metrics):
|
344
370
|
instrument_set = True
|
345
371
|
elif instrument == Instruments.BEDROCK:
|
346
|
-
if init_bedrock_instrumentor(
|
347
|
-
should_enrich_metrics, tracer_provider=tracer_provider
|
348
|
-
):
|
372
|
+
if init_bedrock_instrumentor(should_enrich_metrics):
|
349
373
|
instrument_set = True
|
350
374
|
elif instrument == Instruments.CHROMA:
|
351
|
-
if init_chroma_instrumentor(
|
375
|
+
if init_chroma_instrumentor():
|
352
376
|
instrument_set = True
|
353
377
|
elif instrument == Instruments.COHERE:
|
354
|
-
if init_cohere_instrumentor(
|
378
|
+
if init_cohere_instrumentor():
|
355
379
|
instrument_set = True
|
356
380
|
elif instrument == Instruments.GOOGLE_GENERATIVEAI:
|
357
|
-
if init_google_generativeai_instrumentor(
|
381
|
+
if init_google_generativeai_instrumentor():
|
382
|
+
instrument_set = True
|
383
|
+
elif instrument == Instruments.GOOGLE_GENAI:
|
384
|
+
if init_google_genai_instrumentor():
|
358
385
|
instrument_set = True
|
359
386
|
elif instrument == Instruments.GROQ:
|
360
|
-
if init_groq_instrumentor(
|
387
|
+
if init_groq_instrumentor():
|
361
388
|
instrument_set = True
|
362
389
|
elif instrument == Instruments.HAYSTACK:
|
363
|
-
if init_haystack_instrumentor(
|
390
|
+
if init_haystack_instrumentor():
|
364
391
|
instrument_set = True
|
365
392
|
elif instrument == Instruments.LANCEDB:
|
366
|
-
if init_lancedb_instrumentor(
|
393
|
+
if init_lancedb_instrumentor():
|
367
394
|
instrument_set = True
|
368
395
|
elif instrument == Instruments.LANGCHAIN:
|
369
|
-
if init_langchain_instrumentor(
|
396
|
+
if init_langchain_instrumentor():
|
370
397
|
instrument_set = True
|
371
398
|
elif instrument == Instruments.LLAMA_INDEX:
|
372
|
-
if init_llama_index_instrumentor(
|
399
|
+
if init_llama_index_instrumentor():
|
373
400
|
instrument_set = True
|
374
401
|
elif instrument == Instruments.MARQO:
|
375
|
-
if init_marqo_instrumentor(
|
402
|
+
if init_marqo_instrumentor():
|
376
403
|
instrument_set = True
|
377
404
|
elif instrument == Instruments.MILVUS:
|
378
|
-
if init_milvus_instrumentor(
|
405
|
+
if init_milvus_instrumentor():
|
379
406
|
instrument_set = True
|
380
407
|
elif instrument == Instruments.MISTRAL:
|
381
|
-
if init_mistralai_instrumentor(
|
408
|
+
if init_mistralai_instrumentor():
|
382
409
|
instrument_set = True
|
383
410
|
elif instrument == Instruments.OLLAMA:
|
384
|
-
if init_ollama_instrumentor(
|
411
|
+
if init_ollama_instrumentor():
|
385
412
|
instrument_set = True
|
386
413
|
elif instrument == Instruments.OPENAI:
|
387
|
-
if init_openai_instrumentor(
|
388
|
-
should_enrich_metrics, tracer_provider=tracer_provider
|
389
|
-
):
|
414
|
+
if init_openai_instrumentor(should_enrich_metrics):
|
390
415
|
instrument_set = True
|
391
416
|
elif instrument == Instruments.PINECONE:
|
392
|
-
if init_pinecone_instrumentor(
|
417
|
+
if init_pinecone_instrumentor():
|
393
418
|
instrument_set = True
|
394
419
|
elif instrument == Instruments.PYMYSQL:
|
395
|
-
if init_pymysql_instrumentor(
|
420
|
+
if init_pymysql_instrumentor():
|
396
421
|
instrument_set = True
|
397
422
|
elif instrument == Instruments.QDRANT:
|
398
|
-
if init_qdrant_instrumentor(
|
423
|
+
if init_qdrant_instrumentor():
|
399
424
|
instrument_set = True
|
400
425
|
elif instrument == Instruments.REDIS:
|
401
|
-
if init_redis_instrumentor(
|
426
|
+
if init_redis_instrumentor():
|
402
427
|
instrument_set = True
|
403
428
|
elif instrument == Instruments.REPLICATE:
|
404
|
-
if init_replicate_instrumentor(
|
429
|
+
if init_replicate_instrumentor():
|
405
430
|
instrument_set = True
|
406
431
|
elif instrument == Instruments.REQUESTS:
|
407
|
-
if init_requests_instrumentor(
|
432
|
+
if init_requests_instrumentor():
|
408
433
|
instrument_set = True
|
409
434
|
elif instrument == Instruments.SAGEMAKER:
|
410
|
-
if init_sagemaker_instrumentor(
|
411
|
-
should_enrich_metrics, tracer_provider=tracer_provider
|
412
|
-
):
|
435
|
+
if init_sagemaker_instrumentor(should_enrich_metrics):
|
413
436
|
instrument_set = True
|
414
437
|
elif instrument == Instruments.TOGETHER:
|
415
|
-
if init_together_instrumentor(
|
438
|
+
if init_together_instrumentor():
|
416
439
|
instrument_set = True
|
417
440
|
elif instrument == Instruments.TRANSFORMERS:
|
418
|
-
if init_transformers_instrumentor(
|
441
|
+
if init_transformers_instrumentor():
|
419
442
|
instrument_set = True
|
420
443
|
elif instrument == Instruments.URLLIB3:
|
421
|
-
if init_urllib3_instrumentor(
|
444
|
+
if init_urllib3_instrumentor():
|
422
445
|
instrument_set = True
|
423
446
|
elif instrument == Instruments.VERTEXAI:
|
424
|
-
if init_vertexai_instrumentor(
|
447
|
+
if init_vertexai_instrumentor():
|
425
448
|
instrument_set = True
|
426
449
|
elif instrument == Instruments.WATSONX:
|
427
|
-
if init_watsonx_instrumentor(
|
450
|
+
if init_watsonx_instrumentor():
|
428
451
|
instrument_set = True
|
429
452
|
elif instrument == Instruments.WEAVIATE:
|
430
|
-
if init_weaviate_instrumentor(
|
453
|
+
if init_weaviate_instrumentor():
|
431
454
|
instrument_set = True
|
432
455
|
elif instrument == Instruments.PLAYWRIGHT:
|
433
|
-
if init_playwright_instrumentor(
|
434
|
-
tracer_provider=tracer_provider,
|
435
|
-
project_api_key=project_api_key,
|
436
|
-
base_http_url=base_http_url,
|
437
|
-
):
|
456
|
+
if init_playwright_instrumentor(client, async_client):
|
438
457
|
instrument_set = True
|
439
458
|
elif instrument == Instruments.BROWSER_USE:
|
440
|
-
if init_browser_use_instrumentor(
|
459
|
+
if init_browser_use_instrumentor():
|
441
460
|
instrument_set = True
|
442
461
|
else:
|
443
462
|
module_logger.warning(
|
@@ -452,38 +471,35 @@ def init_instrumentations(
|
|
452
471
|
return instrument_set
|
453
472
|
|
454
473
|
|
455
|
-
def init_browser_use_instrumentor(
|
456
|
-
global instrumentors
|
474
|
+
def init_browser_use_instrumentor():
|
457
475
|
try:
|
458
476
|
if is_package_installed("browser-use"):
|
459
477
|
from lmnr.sdk.browser.browser_use_otel import BrowserUseInstrumentor
|
460
478
|
|
461
479
|
instrumentor = BrowserUseInstrumentor()
|
462
|
-
instrumentor.instrument(
|
463
|
-
instrumentors["browser_use"] = instrumentor
|
480
|
+
instrumentor.instrument()
|
464
481
|
return True
|
465
482
|
except Exception as e:
|
466
483
|
module_logger.error(f"Error initializing BrowserUse instrumentor: {e}")
|
467
484
|
return False
|
468
485
|
|
469
486
|
|
470
|
-
def init_playwright_instrumentor(
|
471
|
-
|
487
|
+
def init_playwright_instrumentor(
|
488
|
+
client: LaminarClient, async_client: AsyncLaminarClient
|
489
|
+
):
|
472
490
|
try:
|
473
491
|
if is_package_installed("playwright"):
|
474
492
|
from lmnr.sdk.browser.playwright_otel import PlaywrightInstrumentor
|
475
493
|
|
476
|
-
instrumentor = PlaywrightInstrumentor()
|
477
|
-
instrumentor.instrument(
|
478
|
-
instrumentors["playwright"] = instrumentor
|
494
|
+
instrumentor = PlaywrightInstrumentor(client, async_client)
|
495
|
+
instrumentor.instrument()
|
479
496
|
return True
|
480
497
|
except Exception as e:
|
481
498
|
module_logger.error(f"Error initializing Playwright instrumentor: {e}")
|
482
499
|
return False
|
483
500
|
|
484
501
|
|
485
|
-
def init_openai_instrumentor(should_enrich_metrics: bool
|
486
|
-
global instrumentors
|
502
|
+
def init_openai_instrumentor(should_enrich_metrics: bool):
|
487
503
|
try:
|
488
504
|
if is_package_installed("openai") and is_package_installed(
|
489
505
|
"opentelemetry-instrumentation-openai"
|
@@ -499,8 +515,7 @@ def init_openai_instrumentor(should_enrich_metrics: bool, **kwargs):
|
|
499
515
|
upload_base64_image=None,
|
500
516
|
)
|
501
517
|
if not instrumentor.is_instrumented_by_opentelemetry:
|
502
|
-
instrumentor.instrument(
|
503
|
-
instrumentors["openai"] = instrumentor
|
518
|
+
instrumentor.instrument()
|
504
519
|
return True
|
505
520
|
|
506
521
|
except Exception as e:
|
@@ -508,8 +523,7 @@ def init_openai_instrumentor(should_enrich_metrics: bool, **kwargs):
|
|
508
523
|
return False
|
509
524
|
|
510
525
|
|
511
|
-
def init_anthropic_instrumentor(should_enrich_metrics: bool
|
512
|
-
global instrumentors
|
526
|
+
def init_anthropic_instrumentor(should_enrich_metrics: bool):
|
513
527
|
try:
|
514
528
|
if is_package_installed("anthropic") and is_package_installed(
|
515
529
|
"opentelemetry-instrumentation-anthropic"
|
@@ -521,16 +535,14 @@ def init_anthropic_instrumentor(should_enrich_metrics: bool, **kwargs):
|
|
521
535
|
upload_base64_image=None,
|
522
536
|
)
|
523
537
|
if not instrumentor.is_instrumented_by_opentelemetry:
|
524
|
-
instrumentor.instrument(
|
525
|
-
instrumentors["anthropic"] = instrumentor
|
538
|
+
instrumentor.instrument()
|
526
539
|
return True
|
527
540
|
except Exception as e:
|
528
541
|
module_logger.error(f"Error initializing Anthropic instrumentor: {e}")
|
529
542
|
return False
|
530
543
|
|
531
544
|
|
532
|
-
def init_cohere_instrumentor(
|
533
|
-
global instrumentors
|
545
|
+
def init_cohere_instrumentor():
|
534
546
|
try:
|
535
547
|
if is_package_installed("cohere") and is_package_installed(
|
536
548
|
"opentelemetry-instrumentation-cohere"
|
@@ -539,16 +551,14 @@ def init_cohere_instrumentor(**kwargs):
|
|
539
551
|
|
540
552
|
instrumentor = CohereInstrumentor()
|
541
553
|
if not instrumentor.is_instrumented_by_opentelemetry:
|
542
|
-
instrumentor.instrument(
|
543
|
-
instrumentors["cohere"] = instrumentor
|
554
|
+
instrumentor.instrument()
|
544
555
|
return True
|
545
556
|
except Exception as e:
|
546
557
|
module_logger.error(f"Error initializing Cohere instrumentor: {e}")
|
547
558
|
return False
|
548
559
|
|
549
560
|
|
550
|
-
def init_pinecone_instrumentor(
|
551
|
-
global instrumentors
|
561
|
+
def init_pinecone_instrumentor():
|
552
562
|
try:
|
553
563
|
if is_package_installed("pinecone") and is_package_installed(
|
554
564
|
"opentelemetry-instrumentation-pinecone"
|
@@ -557,16 +567,14 @@ def init_pinecone_instrumentor(**kwargs):
|
|
557
567
|
|
558
568
|
instrumentor = PineconeInstrumentor()
|
559
569
|
if not instrumentor.is_instrumented_by_opentelemetry:
|
560
|
-
instrumentor.instrument(
|
561
|
-
instrumentors["pinecone"] = instrumentor
|
570
|
+
instrumentor.instrument()
|
562
571
|
return True
|
563
572
|
except Exception as e:
|
564
573
|
module_logger.error(f"Error initializing Pinecone instrumentor: {e}")
|
565
574
|
return False
|
566
575
|
|
567
576
|
|
568
|
-
def init_qdrant_instrumentor(
|
569
|
-
global instrumentors
|
577
|
+
def init_qdrant_instrumentor():
|
570
578
|
try:
|
571
579
|
if is_package_installed("qdrant_client") and is_package_installed(
|
572
580
|
"opentelemetry-instrumentation-qdrant"
|
@@ -575,16 +583,13 @@ def init_qdrant_instrumentor(**kwargs):
|
|
575
583
|
|
576
584
|
instrumentor = QdrantInstrumentor()
|
577
585
|
if not instrumentor.is_instrumented_by_opentelemetry:
|
578
|
-
instrumentor.instrument(
|
579
|
-
instrumentors["qdrant"] = instrumentor
|
580
|
-
return True
|
586
|
+
instrumentor.instrument()
|
581
587
|
except Exception as e:
|
582
588
|
module_logger.error(f"Error initializing Qdrant instrumentor: {e}")
|
583
589
|
return False
|
584
590
|
|
585
591
|
|
586
|
-
def init_chroma_instrumentor(
|
587
|
-
global instrumentors
|
592
|
+
def init_chroma_instrumentor():
|
588
593
|
try:
|
589
594
|
if is_package_installed("chromadb") and is_package_installed(
|
590
595
|
"opentelemetry-instrumentation-chromadb"
|
@@ -593,16 +598,14 @@ def init_chroma_instrumentor(**kwargs):
|
|
593
598
|
|
594
599
|
instrumentor = ChromaInstrumentor()
|
595
600
|
if not instrumentor.is_instrumented_by_opentelemetry:
|
596
|
-
instrumentor.instrument(
|
597
|
-
instrumentors["chroma"] = instrumentor
|
601
|
+
instrumentor.instrument()
|
598
602
|
return True
|
599
603
|
except Exception as e:
|
600
604
|
module_logger.error(f"Error initializing Chroma instrumentor: {e}")
|
601
605
|
return False
|
602
606
|
|
603
607
|
|
604
|
-
def init_google_generativeai_instrumentor(
|
605
|
-
global instrumentors
|
608
|
+
def init_google_generativeai_instrumentor():
|
606
609
|
try:
|
607
610
|
if is_package_installed("google-generativeai") and is_package_installed(
|
608
611
|
"opentelemetry-instrumentation-google-generativeai"
|
@@ -613,16 +616,35 @@ def init_google_generativeai_instrumentor(**kwargs):
|
|
613
616
|
|
614
617
|
instrumentor = GoogleGenerativeAiInstrumentor()
|
615
618
|
if not instrumentor.is_instrumented_by_opentelemetry:
|
616
|
-
instrumentor.instrument(
|
617
|
-
instrumentors["google_generativeai"] = instrumentor
|
619
|
+
instrumentor.instrument()
|
618
620
|
return True
|
619
621
|
except Exception as e:
|
620
622
|
module_logger.error(f"Error initializing Gemini instrumentor: {e}")
|
621
623
|
return False
|
622
624
|
|
623
625
|
|
624
|
-
def
|
625
|
-
|
626
|
+
def init_google_genai_instrumentor():
|
627
|
+
try:
|
628
|
+
if is_package_installed("google-genai"):
|
629
|
+
# TODO: uncomment this once we migrate to the contrib package
|
630
|
+
# and is_package_installed(
|
631
|
+
# "opentelemetry-instrumentation-google-genai"
|
632
|
+
# ):
|
633
|
+
# from opentelemetry.instrumentation.google_genai import (
|
634
|
+
from ..opentelemetry.instrumentation.google_genai import (
|
635
|
+
GoogleGenAiSdkInstrumentor,
|
636
|
+
)
|
637
|
+
|
638
|
+
instrumentor = GoogleGenAiSdkInstrumentor()
|
639
|
+
if not instrumentor.is_instrumented_by_opentelemetry:
|
640
|
+
instrumentor.instrument()
|
641
|
+
return True
|
642
|
+
except Exception as e:
|
643
|
+
module_logger.error(f"Error initializing Google GenAI instrumentor: {e}")
|
644
|
+
return False
|
645
|
+
|
646
|
+
|
647
|
+
def init_haystack_instrumentor():
|
626
648
|
try:
|
627
649
|
if is_package_installed("haystack") and is_package_installed(
|
628
650
|
"opentelemetry-instrumentation-haystack"
|
@@ -631,16 +653,14 @@ def init_haystack_instrumentor(**kwargs):
|
|
631
653
|
|
632
654
|
instrumentor = HaystackInstrumentor()
|
633
655
|
if not instrumentor.is_instrumented_by_opentelemetry:
|
634
|
-
instrumentor.instrument(
|
635
|
-
instrumentors["haystack"] = instrumentor
|
656
|
+
instrumentor.instrument()
|
636
657
|
return True
|
637
658
|
except Exception as e:
|
638
659
|
module_logger.error(f"Error initializing Haystack instrumentor: {e}")
|
639
660
|
return False
|
640
661
|
|
641
662
|
|
642
|
-
def init_langchain_instrumentor(
|
643
|
-
global instrumentors
|
663
|
+
def init_langchain_instrumentor():
|
644
664
|
try:
|
645
665
|
if is_package_installed("langchain") and is_package_installed(
|
646
666
|
"opentelemetry-instrumentation-langchain"
|
@@ -650,7 +670,6 @@ def init_langchain_instrumentor(**kwargs):
|
|
650
670
|
instrumentor = LangchainInstrumentor()
|
651
671
|
if not instrumentor.is_instrumented_by_opentelemetry:
|
652
672
|
instrumentor.instrument()
|
653
|
-
instrumentors["langchain"] = instrumentor
|
654
673
|
return True
|
655
674
|
except Exception as e:
|
656
675
|
# FIXME: silencing this error temporarily, it appears to not be critical
|
@@ -659,8 +678,7 @@ def init_langchain_instrumentor(**kwargs):
|
|
659
678
|
return False
|
660
679
|
|
661
680
|
|
662
|
-
def init_mistralai_instrumentor(
|
663
|
-
global instrumentors
|
681
|
+
def init_mistralai_instrumentor():
|
664
682
|
try:
|
665
683
|
if is_package_installed("mistralai") and is_package_installed(
|
666
684
|
"opentelemetry-instrumentation-mistralai"
|
@@ -669,16 +687,14 @@ def init_mistralai_instrumentor(**kwargs):
|
|
669
687
|
|
670
688
|
instrumentor = MistralAiInstrumentor()
|
671
689
|
if not instrumentor.is_instrumented_by_opentelemetry:
|
672
|
-
instrumentor.instrument(
|
673
|
-
instrumentors["mistralai"] = instrumentor
|
690
|
+
instrumentor.instrument()
|
674
691
|
return True
|
675
692
|
except Exception as e:
|
676
693
|
module_logger.error(f"Error initializing MistralAI instrumentor: {e}")
|
677
694
|
return False
|
678
695
|
|
679
696
|
|
680
|
-
def init_ollama_instrumentor(
|
681
|
-
global instrumentors
|
697
|
+
def init_ollama_instrumentor():
|
682
698
|
try:
|
683
699
|
if is_package_installed("ollama") and is_package_installed(
|
684
700
|
"opentelemetry-instrumentation-ollama"
|
@@ -687,16 +703,14 @@ def init_ollama_instrumentor(**kwargs):
|
|
687
703
|
|
688
704
|
instrumentor = OllamaInstrumentor()
|
689
705
|
if not instrumentor.is_instrumented_by_opentelemetry:
|
690
|
-
instrumentor.instrument(
|
691
|
-
instrumentors["ollama"] = instrumentor
|
706
|
+
instrumentor.instrument()
|
692
707
|
return True
|
693
708
|
except Exception as e:
|
694
709
|
module_logger.error(f"Error initializing Ollama instrumentor: {e}")
|
695
710
|
return False
|
696
711
|
|
697
712
|
|
698
|
-
def init_transformers_instrumentor(
|
699
|
-
global instrumentors
|
713
|
+
def init_transformers_instrumentor():
|
700
714
|
try:
|
701
715
|
if is_package_installed("transformers") and is_package_installed(
|
702
716
|
"opentelemetry-instrumentation-transformers"
|
@@ -707,16 +721,14 @@ def init_transformers_instrumentor(**kwargs):
|
|
707
721
|
|
708
722
|
instrumentor = TransformersInstrumentor()
|
709
723
|
if not instrumentor.is_instrumented_by_opentelemetry:
|
710
|
-
instrumentor.instrument(
|
711
|
-
instrumentors["transformers"] = instrumentor
|
724
|
+
instrumentor.instrument()
|
712
725
|
return True
|
713
726
|
except Exception as e:
|
714
727
|
module_logger.error(f"Error initializing Transformers instrumentor: {e}")
|
715
728
|
return False
|
716
729
|
|
717
730
|
|
718
|
-
def init_together_instrumentor(
|
719
|
-
global instrumentors
|
731
|
+
def init_together_instrumentor():
|
720
732
|
try:
|
721
733
|
if is_package_installed("together") and is_package_installed(
|
722
734
|
"opentelemetry-instrumentation-together"
|
@@ -725,16 +737,14 @@ def init_together_instrumentor(**kwargs):
|
|
725
737
|
|
726
738
|
instrumentor = TogetherAiInstrumentor()
|
727
739
|
if not instrumentor.is_instrumented_by_opentelemetry:
|
728
|
-
instrumentor.instrument(
|
729
|
-
instrumentors["together"] = instrumentor
|
740
|
+
instrumentor.instrument()
|
730
741
|
return True
|
731
742
|
except Exception as e:
|
732
743
|
module_logger.error(f"Error initializing TogetherAI instrumentor: {e}")
|
733
744
|
return False
|
734
745
|
|
735
746
|
|
736
|
-
def init_llama_index_instrumentor(
|
737
|
-
global instrumentors
|
747
|
+
def init_llama_index_instrumentor():
|
738
748
|
try:
|
739
749
|
if (
|
740
750
|
is_package_installed("llama-index") or is_package_installed("llama_index")
|
@@ -743,16 +753,14 @@ def init_llama_index_instrumentor(**kwargs):
|
|
743
753
|
|
744
754
|
instrumentor = LlamaIndexInstrumentor()
|
745
755
|
if not instrumentor.is_instrumented_by_opentelemetry:
|
746
|
-
instrumentor.instrument(
|
747
|
-
instrumentors["llama_index"] = instrumentor
|
756
|
+
instrumentor.instrument()
|
748
757
|
return True
|
749
758
|
except Exception as e:
|
750
759
|
module_logger.error(f"Error initializing LlamaIndex instrumentor: {e}")
|
751
760
|
return False
|
752
761
|
|
753
762
|
|
754
|
-
def init_milvus_instrumentor(
|
755
|
-
global instrumentors
|
763
|
+
def init_milvus_instrumentor():
|
756
764
|
try:
|
757
765
|
if is_package_installed("pymilvus") and is_package_installed(
|
758
766
|
"opentelemetry-instrumentation-milvus"
|
@@ -761,64 +769,56 @@ def init_milvus_instrumentor(**kwargs):
|
|
761
769
|
|
762
770
|
instrumentor = MilvusInstrumentor()
|
763
771
|
if not instrumentor.is_instrumented_by_opentelemetry:
|
764
|
-
instrumentor.instrument(
|
765
|
-
instrumentors["milvus"] = instrumentor
|
772
|
+
instrumentor.instrument()
|
766
773
|
return True
|
767
774
|
except Exception as e:
|
768
775
|
module_logger.error(f"Error initializing Milvus instrumentor: {e}")
|
769
776
|
return False
|
770
777
|
|
771
778
|
|
772
|
-
def init_requests_instrumentor(
|
773
|
-
global instrumentors
|
779
|
+
def init_requests_instrumentor():
|
774
780
|
try:
|
775
781
|
if is_package_installed("requests"):
|
776
782
|
from opentelemetry.instrumentation.requests import RequestsInstrumentor
|
777
783
|
|
778
784
|
instrumentor = RequestsInstrumentor()
|
779
785
|
if not instrumentor.is_instrumented_by_opentelemetry:
|
780
|
-
instrumentor.instrument(excluded_urls=EXCLUDED_URLS
|
781
|
-
instrumentors["requests"] = instrumentor
|
786
|
+
instrumentor.instrument(excluded_urls=EXCLUDED_URLS)
|
782
787
|
return True
|
783
788
|
except Exception as e:
|
784
789
|
module_logger.error(f"Error initializing Requests instrumentor: {e}")
|
785
790
|
return False
|
786
791
|
|
787
792
|
|
788
|
-
def init_urllib3_instrumentor(
|
789
|
-
global instrumentors
|
793
|
+
def init_urllib3_instrumentor():
|
790
794
|
try:
|
791
795
|
if is_package_installed("urllib3"):
|
792
796
|
from opentelemetry.instrumentation.urllib3 import URLLib3Instrumentor
|
793
797
|
|
794
798
|
instrumentor = URLLib3Instrumentor()
|
795
799
|
if not instrumentor.is_instrumented_by_opentelemetry:
|
796
|
-
instrumentor.instrument(excluded_urls=EXCLUDED_URLS
|
797
|
-
instrumentors["urllib3"] = instrumentor
|
800
|
+
instrumentor.instrument(excluded_urls=EXCLUDED_URLS)
|
798
801
|
return True
|
799
802
|
except Exception as e:
|
800
803
|
module_logger.error(f"Error initializing urllib3 instrumentor: {e}")
|
801
804
|
return False
|
802
805
|
|
803
806
|
|
804
|
-
def init_pymysql_instrumentor(
|
805
|
-
global instrumentors
|
807
|
+
def init_pymysql_instrumentor():
|
806
808
|
try:
|
807
809
|
if is_package_installed("sqlalchemy"):
|
808
810
|
from opentelemetry.instrumentation.sqlalchemy import SQLAlchemyInstrumentor
|
809
811
|
|
810
812
|
instrumentor = SQLAlchemyInstrumentor()
|
811
813
|
if not instrumentor.is_instrumented_by_opentelemetry:
|
812
|
-
instrumentor.instrument(
|
813
|
-
instrumentors["sqlalchemy"] = instrumentor
|
814
|
+
instrumentor.instrument()
|
814
815
|
return True
|
815
816
|
except Exception as e:
|
816
817
|
module_logger.error(f"Error initializing SQLAlchemy instrumentor: {e}")
|
817
818
|
return False
|
818
819
|
|
819
820
|
|
820
|
-
def init_bedrock_instrumentor(should_enrich_metrics: bool
|
821
|
-
global instrumentors
|
821
|
+
def init_bedrock_instrumentor(should_enrich_metrics: bool):
|
822
822
|
try:
|
823
823
|
if is_package_installed("boto3") and is_package_installed(
|
824
824
|
"opentelemetry-instrumentation-bedrock"
|
@@ -829,16 +829,14 @@ def init_bedrock_instrumentor(should_enrich_metrics: bool, **kwargs):
|
|
829
829
|
enrich_token_usage=should_enrich_metrics,
|
830
830
|
)
|
831
831
|
if not instrumentor.is_instrumented_by_opentelemetry:
|
832
|
-
instrumentor.instrument(
|
833
|
-
instrumentors["bedrock"] = instrumentor
|
832
|
+
instrumentor.instrument()
|
834
833
|
return True
|
835
834
|
except Exception as e:
|
836
835
|
module_logger.error(f"Error initializing Bedrock instrumentor: {e}")
|
837
836
|
return False
|
838
837
|
|
839
838
|
|
840
|
-
def init_replicate_instrumentor(
|
841
|
-
global instrumentors
|
839
|
+
def init_replicate_instrumentor():
|
842
840
|
try:
|
843
841
|
if is_package_installed("replicate") and is_package_installed(
|
844
842
|
"opentelemetry-instrumentation-replicate"
|
@@ -847,16 +845,14 @@ def init_replicate_instrumentor(**kwargs):
|
|
847
845
|
|
848
846
|
instrumentor = ReplicateInstrumentor()
|
849
847
|
if not instrumentor.is_instrumented_by_opentelemetry:
|
850
|
-
instrumentor.instrument(
|
851
|
-
instrumentors["replicate"] = instrumentor
|
848
|
+
instrumentor.instrument()
|
852
849
|
return True
|
853
850
|
except Exception as e:
|
854
851
|
module_logger.error(f"Error initializing Replicate instrumentor: {e}")
|
855
852
|
return False
|
856
853
|
|
857
854
|
|
858
|
-
def init_vertexai_instrumentor(
|
859
|
-
global instrumentors
|
855
|
+
def init_vertexai_instrumentor():
|
860
856
|
try:
|
861
857
|
if is_package_installed("vertexai") and is_package_installed(
|
862
858
|
"opentelemetry-instrumentation-vertexai"
|
@@ -865,16 +861,14 @@ def init_vertexai_instrumentor(**kwargs):
|
|
865
861
|
|
866
862
|
instrumentor = VertexAIInstrumentor()
|
867
863
|
if not instrumentor.is_instrumented_by_opentelemetry:
|
868
|
-
instrumentor.instrument(
|
869
|
-
instrumentors["vertexai"] = instrumentor
|
864
|
+
instrumentor.instrument()
|
870
865
|
return True
|
871
866
|
except Exception as e:
|
872
867
|
module_logger.warning(f"Error initializing Vertex AI instrumentor: {e}")
|
873
868
|
return False
|
874
869
|
|
875
870
|
|
876
|
-
def init_watsonx_instrumentor(
|
877
|
-
global instrumentors
|
871
|
+
def init_watsonx_instrumentor():
|
878
872
|
try:
|
879
873
|
if (
|
880
874
|
is_package_installed("ibm-watsonx-ai")
|
@@ -884,16 +878,14 @@ def init_watsonx_instrumentor(**kwargs):
|
|
884
878
|
|
885
879
|
instrumentor = WatsonxInstrumentor()
|
886
880
|
if not instrumentor.is_instrumented_by_opentelemetry:
|
887
|
-
instrumentor.instrument(
|
888
|
-
instrumentors["watsonx"] = instrumentor
|
881
|
+
instrumentor.instrument()
|
889
882
|
return True
|
890
883
|
except Exception as e:
|
891
884
|
module_logger.warning(f"Error initializing Watsonx instrumentor: {e}")
|
892
885
|
return False
|
893
886
|
|
894
887
|
|
895
|
-
def init_weaviate_instrumentor(
|
896
|
-
global instrumentors
|
888
|
+
def init_weaviate_instrumentor():
|
897
889
|
try:
|
898
890
|
if is_package_installed("weaviate") and is_package_installed(
|
899
891
|
"opentelemetry-instrumentation-weaviate"
|
@@ -902,16 +894,14 @@ def init_weaviate_instrumentor(**kwargs):
|
|
902
894
|
|
903
895
|
instrumentor = WeaviateInstrumentor()
|
904
896
|
if not instrumentor.is_instrumented_by_opentelemetry:
|
905
|
-
instrumentor.instrument(
|
906
|
-
instrumentors["weaviate"] = instrumentor
|
897
|
+
instrumentor.instrument()
|
907
898
|
return True
|
908
899
|
except Exception as e:
|
909
900
|
module_logger.warning(f"Error initializing Weaviate instrumentor: {e}")
|
910
901
|
return False
|
911
902
|
|
912
903
|
|
913
|
-
def init_alephalpha_instrumentor(
|
914
|
-
global instrumentors
|
904
|
+
def init_alephalpha_instrumentor():
|
915
905
|
try:
|
916
906
|
if is_package_installed("aleph_alpha_client") and is_package_installed(
|
917
907
|
"opentelemetry-instrumentation-alephalpha"
|
@@ -920,16 +910,14 @@ def init_alephalpha_instrumentor(**kwargs):
|
|
920
910
|
|
921
911
|
instrumentor = AlephAlphaInstrumentor()
|
922
912
|
if not instrumentor.is_instrumented_by_opentelemetry:
|
923
|
-
instrumentor.instrument(
|
924
|
-
instrumentors["alephalpha"] = instrumentor
|
913
|
+
instrumentor.instrument()
|
925
914
|
return True
|
926
915
|
except Exception as e:
|
927
916
|
module_logger.error(f"Error initializing Aleph Alpha instrumentor: {e}")
|
928
917
|
return False
|
929
918
|
|
930
919
|
|
931
|
-
def init_marqo_instrumentor(
|
932
|
-
global instrumentors
|
920
|
+
def init_marqo_instrumentor():
|
933
921
|
try:
|
934
922
|
if is_package_installed("marqo") and is_package_installed(
|
935
923
|
"opentelemetry-instrumentation-marqo"
|
@@ -938,16 +926,14 @@ def init_marqo_instrumentor(**kwargs):
|
|
938
926
|
|
939
927
|
instrumentor = MarqoInstrumentor()
|
940
928
|
if not instrumentor.is_instrumented_by_opentelemetry:
|
941
|
-
instrumentor.instrument(
|
942
|
-
instrumentors["marqo"] = instrumentor
|
929
|
+
instrumentor.instrument()
|
943
930
|
return True
|
944
931
|
except Exception as e:
|
945
932
|
module_logger.error(f"Error initializing marqo instrumentor: {e}")
|
946
933
|
return False
|
947
934
|
|
948
935
|
|
949
|
-
def init_lancedb_instrumentor(
|
950
|
-
global instrumentors
|
936
|
+
def init_lancedb_instrumentor():
|
951
937
|
try:
|
952
938
|
if is_package_installed("lancedb") and is_package_installed(
|
953
939
|
"opentelemetry-instrumentation-lancedb"
|
@@ -956,16 +942,13 @@ def init_lancedb_instrumentor(**kwargs):
|
|
956
942
|
|
957
943
|
instrumentor = LanceInstrumentor()
|
958
944
|
if not instrumentor.is_instrumented_by_opentelemetry:
|
959
|
-
instrumentor.instrument(
|
960
|
-
instrumentors["lancedb"] = instrumentor
|
945
|
+
instrumentor.instrument()
|
961
946
|
return True
|
962
947
|
except Exception as e:
|
963
948
|
module_logger.error(f"Error initializing LanceDB instrumentor: {e}")
|
964
|
-
return False
|
965
949
|
|
966
950
|
|
967
|
-
def init_redis_instrumentor(
|
968
|
-
global instrumentors
|
951
|
+
def init_redis_instrumentor():
|
969
952
|
try:
|
970
953
|
if is_package_installed("redis") and is_package_installed(
|
971
954
|
"opentelemetry-instrumentation-redis"
|
@@ -974,16 +957,14 @@ def init_redis_instrumentor(**kwargs):
|
|
974
957
|
|
975
958
|
instrumentor = RedisInstrumentor()
|
976
959
|
if not instrumentor.is_instrumented_by_opentelemetry:
|
977
|
-
instrumentor.instrument(excluded_urls=EXCLUDED_URLS
|
978
|
-
instrumentors["redis"] = instrumentor
|
960
|
+
instrumentor.instrument(excluded_urls=EXCLUDED_URLS)
|
979
961
|
return True
|
980
962
|
except Exception as e:
|
981
963
|
module_logger.error(f"Error initializing redis instrumentor: {e}")
|
982
964
|
return False
|
983
965
|
|
984
966
|
|
985
|
-
def init_groq_instrumentor(
|
986
|
-
global instrumentors
|
967
|
+
def init_groq_instrumentor():
|
987
968
|
try:
|
988
969
|
if is_package_installed("groq") and is_package_installed(
|
989
970
|
"opentelemetry-instrumentation-groq"
|
@@ -992,16 +973,14 @@ def init_groq_instrumentor(**kwargs):
|
|
992
973
|
|
993
974
|
instrumentor = GroqInstrumentor()
|
994
975
|
if not instrumentor.is_instrumented_by_opentelemetry:
|
995
|
-
instrumentor.instrument(
|
996
|
-
instrumentors["groq"] = instrumentor
|
976
|
+
instrumentor.instrument()
|
997
977
|
return True
|
998
978
|
except Exception as e:
|
999
979
|
module_logger.error(f"Error initializing Groq instrumentor: {e}")
|
1000
980
|
return False
|
1001
981
|
|
1002
982
|
|
1003
|
-
def init_sagemaker_instrumentor(should_enrich_metrics: bool
|
1004
|
-
global instrumentors
|
983
|
+
def init_sagemaker_instrumentor(should_enrich_metrics: bool):
|
1005
984
|
try:
|
1006
985
|
if is_package_installed("boto3") and is_package_installed(
|
1007
986
|
"opentelemetry-instrumentation-sagemaker"
|
@@ -1012,8 +991,7 @@ def init_sagemaker_instrumentor(should_enrich_metrics: bool, **kwargs):
|
|
1012
991
|
enrich_token_usage=should_enrich_metrics,
|
1013
992
|
)
|
1014
993
|
if not instrumentor.is_instrumented_by_opentelemetry:
|
1015
|
-
instrumentor.instrument(
|
1016
|
-
instrumentors["sagemaker"] = instrumentor
|
994
|
+
instrumentor.instrument()
|
1017
995
|
return True
|
1018
996
|
except Exception as e:
|
1019
997
|
module_logger.error(f"Error initializing SageMaker instrumentor: {e}")
|