openlit 1.22.0__py3-none-any.whl → 1.22.3__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.
openlit/__init__.py CHANGED
@@ -130,6 +130,13 @@ class OpenlitConfig:
130
130
  cls.trace_content = trace_content
131
131
  cls.disable_metrics = disable_metrics
132
132
 
133
+ def module_exists(module_name):
134
+ """Check if nested modules exist, addressing the dot notation issue."""
135
+ parts = module_name.split(".")
136
+ for i in range(1, len(parts) + 1):
137
+ if find_spec(".".join(parts[:i])) is None:
138
+ return False
139
+ return True
133
140
 
134
141
  def instrument_if_available(
135
142
  instrumentor_name,
@@ -140,12 +147,17 @@ def instrument_if_available(
140
147
  ):
141
148
  """Instruments the specified instrumentor if its library is available."""
142
149
  if instrumentor_name in disabled_instrumentors:
150
+ logger.info("Instrumentor %s is disabled", instrumentor_name)
143
151
  return
144
152
 
145
153
  module_name = module_name_map.get(instrumentor_name)
146
154
 
147
- if not module_name or find_spec(module_name) is not None:
148
- try:
155
+ if not module_name:
156
+ logger.error("No module mapping for %s", instrumentor_name)
157
+ return
158
+
159
+ try:
160
+ if module_exists(module_name):
149
161
  instrumentor_instance.instrument(
150
162
  environment=config.environment,
151
163
  application_name=config.application_name,
@@ -155,10 +167,13 @@ def instrument_if_available(
155
167
  metrics_dict=config.metrics_dict,
156
168
  disable_metrics=config.disable_metrics,
157
169
  )
170
+ logger.info("Instrumented %s", instrumentor_name)
171
+ else:
172
+ # pylint: disable=line-too-long
173
+ logger.info("Library for %s (%s) not found. Skipping instrumentation", instrumentor_name, module_name)
174
+ except Exception as e:
175
+ logger.error("Failed to instrument %s: %s", instrumentor_name, e)
158
176
 
159
- # pylint: disable=broad-exception-caught
160
- except Exception as e:
161
- logger.error("Failed to instrument %s: %s", instrumentor_name, e)
162
177
 
163
178
  def init(environment="default", application_name="default", tracer=None, otlp_endpoint=None,
164
179
  otlp_headers=None, disable_batch=False, trace_content=True, disabled_instrumentors=None,
@@ -184,7 +199,7 @@ def init(environment="default", application_name="default", tracer=None, otlp_en
184
199
  collect_gpu_stats (bool): Flag to enable or disable GPU metrics collection.
185
200
  """
186
201
  disabled_instrumentors = disabled_instrumentors if disabled_instrumentors else []
187
- # Check for invalid instrumentor names
202
+ logger.info("Starting openLIT initialization...")
188
203
 
189
204
  module_name_map = {
190
205
  "openai": "openai",
@@ -215,9 +230,7 @@ def init(environment="default", application_name="default", tracer=None, otlp_en
215
230
  name for name in disabled_instrumentors if name not in module_name_map
216
231
  ]
217
232
  for invalid_name in invalid_instrumentors:
218
- logger.warning(
219
- "Invalid instrumentor name detected and ignored: '%s'", invalid_name
220
- )
233
+ logger.warning("Invalid instrumentor name detected and ignored: '%s'", invalid_name)
221
234
 
222
235
  try:
223
236
  # Retrieve or create the single configuration instance.
@@ -237,7 +250,7 @@ def init(environment="default", application_name="default", tracer=None, otlp_en
237
250
  logger.error("openLIT tracing setup failed. Tracing will not be available.")
238
251
  return
239
252
 
240
- # Setup meter and receive metrics_dict instead of meter
253
+ # Setup meter and receive metrics_dict instead of meter.
241
254
  metrics_dict = setup_meter(
242
255
  application_name=application_name,
243
256
  environment=environment,
@@ -293,14 +306,13 @@ def init(environment="default", application_name="default", tracer=None, otlp_en
293
306
  # Initialize and instrument only the enabled instrumentors
294
307
  for name, instrumentor in instrumentor_instances.items():
295
308
  instrument_if_available(name, instrumentor, config,
296
- disabled_instrumentors, module_name_map)
309
+ disabled_instrumentors, module_name_map)
297
310
 
298
- if (disable_metrics is False) and (collect_gpu_stats is True):
311
+ if not disable_metrics and collect_gpu_stats:
299
312
  NvidiaGPUInstrumentor().instrument(
300
313
  environment=config.environment,
301
314
  application_name=config.application_name,
302
315
  )
303
-
304
316
  except Exception as e:
305
317
  logger.error("Error during openLIT initialization: %s", e)
306
318
 
@@ -481,8 +481,8 @@ def chat(gen_ai_endpoint, version, environment, application_name,
481
481
  response = wrapped(*args, **kwargs)
482
482
 
483
483
  try:
484
- input_tokens = response.response_metadata["prompt_eval_count"] or 0
485
- output_tokens = response.response_metadata["eval_count"] or 0
484
+ input_tokens = response.response_metadata.get("prompt_eval_count", 0)
485
+ output_tokens = response.response_metadata.get("eval_count", 0)
486
486
 
487
487
  # Calculate cost of the operation
488
488
  cost = get_chat_model_cost(
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: openlit
3
- Version: 1.22.0
3
+ Version: 1.22.3
4
4
  Summary: OpenTelemetry-native Auto instrumentation library for monitoring LLM Applications and GPUs, facilitating the integration of observability into your GenAI-driven projects
5
5
  Home-page: https://github.com/openlit/openlit/tree/main/openlit/python
6
6
  Keywords: OpenTelemetry,otel,otlp,llm,tracing,openai,anthropic,claude,cohere,llm monitoring,observability,monitoring,gpt,Generative AI,chatGPT,gpu
@@ -73,6 +73,7 @@ This project adheres to the [Semantic Conventions](https://github.com/open-telem
73
73
  | [✅ vLLM](https://docs.openlit.io/latest/integrations/vllm) | | | |
74
74
  | [✅ OLA Krutrim](https://docs.openlit.io/latest/integrations/krutrim) | | | |
75
75
  | [✅ Google AI Studio](https://docs.openlit.io/latest/integrations/google-ai-studio) | | | |
76
+ | [✅ NVIDIA NIM](https://docs.openlit.io/latest/integrations/nvidia-nim) | | | |
76
77
 
77
78
  ## Supported Destinations
78
79
  - [✅ OpenTelemetry Collector](https://docs.openlit.io/latest/connections/otelcol)
@@ -1,5 +1,5 @@
1
1
  openlit/__helpers.py,sha256=lrn4PBs9owDudiCY2NBoVbAi7AU_HtUpyOj0oqPBsPY,5545
2
- openlit/__init__.py,sha256=w3xpFptltMR5TgYWz3ADfvWGpIH32CdBBbcIFFGc8vc,15498
2
+ openlit/__init__.py,sha256=iuYE-acp7ScvxzA9P3f8obfOLLLrNMYkLbyKRz8Liec,16049
3
3
  openlit/instrumentation/anthropic/__init__.py,sha256=oaU53BOPyfUKbEzYvLr1DPymDluurSnwo4Hernf2XdU,1955
4
4
  openlit/instrumentation/anthropic/anthropic.py,sha256=y7CEGhKOGHWt8G_5Phr4qPJTfPGRJIAr9Yk6nM3CcvM,16775
5
5
  openlit/instrumentation/anthropic/async_anthropic.py,sha256=Zz1KRKIG9wGn0quOoLvjORC-49IvHQpJ6GBdB-4PfCQ,16816
@@ -29,7 +29,7 @@ openlit/instrumentation/groq/groq.py,sha256=m4gFPbYzjUUIgjXZ0Alu2Zy1HcO5takCFA2X
29
29
  openlit/instrumentation/haystack/__init__.py,sha256=QK6XxxZUHX8vMv2Crk7rNBOc64iOOBLhJGL_lPlAZ8s,1758
30
30
  openlit/instrumentation/haystack/haystack.py,sha256=oQIZiDhdp3gnJnhYQ1OouJMc9YT0pQ-_31cmNuopa68,3891
31
31
  openlit/instrumentation/langchain/__init__.py,sha256=0AI2Dnqw81IcJw3jM--gGkv_HRh2GtosOGJjvOpw7Zk,3431
32
- openlit/instrumentation/langchain/langchain.py,sha256=7K-m35sS3yTu9IklRo6n9LCcymeg6OyIYKrMzMG_uDQ,35730
32
+ openlit/instrumentation/langchain/langchain.py,sha256=s8vZZxhHfDANeisqIyNvsd5BPcHbc-LNFKDXS5hiEfA,35734
33
33
  openlit/instrumentation/llamaindex/__init__.py,sha256=vPtK65G6b-TwJERowVRUVl7f_nBSlFdwPBtpg8dOGos,1977
34
34
  openlit/instrumentation/llamaindex/llamaindex.py,sha256=uiIigbwhonSbJWA7LpgOVI1R4kxxPODS1K5wyHIQ4hM,4048
35
35
  openlit/instrumentation/milvus/__init__.py,sha256=qi1yfmMrvkDtnrN_6toW8qC9BRL78bq7ayWpObJ8Bq4,2961
@@ -59,7 +59,7 @@ openlit/instrumentation/vllm/vllm.py,sha256=lDzM7F5pgxvh8nKL0dcKB4TD0Mc9wXOWeXOs
59
59
  openlit/otel/metrics.py,sha256=O7NoaDz0bY19mqpE4-0PcKwEe-B-iJFRgOCaanAuZAc,4291
60
60
  openlit/otel/tracing.py,sha256=vL1ifMbARPBpqK--yXYsCM6y5dSu5LFIKqkhZXtYmUc,3712
61
61
  openlit/semcov/__init__.py,sha256=wpAarrnkndbgvP8VSudi8IRInYtD02hkewqjyiC0dMk,7614
62
- openlit-1.22.0.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
63
- openlit-1.22.0.dist-info/METADATA,sha256=rSCNSQss7NahZ5Vnq028vzvKxmhsXuOxGvQt5n5Ock0,15489
64
- openlit-1.22.0.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
65
- openlit-1.22.0.dist-info/RECORD,,
62
+ openlit-1.22.3.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
63
+ openlit-1.22.3.dist-info/METADATA,sha256=0F7-sbMG7ctUtCaCNZsxsjUzSZJeqnfgXjzFc7D8Ico,15710
64
+ openlit-1.22.3.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
65
+ openlit-1.22.3.dist-info/RECORD,,