openlit 1.33.4__py3-none-any.whl → 1.33.6__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
@@ -152,6 +152,7 @@ class OpenlitConfig:
|
|
152
152
|
cls.trace_content = trace_content
|
153
153
|
cls.disable_metrics = disable_metrics
|
154
154
|
|
155
|
+
|
155
156
|
def module_exists(module_name):
|
156
157
|
"""Check if nested modules exist, addressing the dot notation issue."""
|
157
158
|
parts = module_name.split(".")
|
@@ -160,6 +161,7 @@ def module_exists(module_name):
|
|
160
161
|
return False
|
161
162
|
return True
|
162
163
|
|
164
|
+
|
163
165
|
def instrument_if_available(
|
164
166
|
instrumentor_name,
|
165
167
|
instrumentor_instance,
|
@@ -191,14 +193,29 @@ def instrument_if_available(
|
|
191
193
|
)
|
192
194
|
else:
|
193
195
|
# pylint: disable=line-too-long
|
194
|
-
logger.info(
|
196
|
+
logger.info(
|
197
|
+
"Library for %s (%s) not found. Skipping instrumentation",
|
198
|
+
instrumentor_name,
|
199
|
+
module_name,
|
200
|
+
)
|
195
201
|
except Exception as e:
|
196
202
|
logger.error("Failed to instrument %s: %s", instrumentor_name, e)
|
197
203
|
|
198
204
|
|
199
|
-
def init(
|
200
|
-
|
201
|
-
|
205
|
+
def init(
|
206
|
+
environment="default",
|
207
|
+
application_name="default",
|
208
|
+
tracer=None,
|
209
|
+
otlp_endpoint=None,
|
210
|
+
otlp_headers=None,
|
211
|
+
disable_batch=False,
|
212
|
+
trace_content=True,
|
213
|
+
disabled_instrumentors=None,
|
214
|
+
meter=None,
|
215
|
+
disable_metrics=False,
|
216
|
+
pricing_json=None,
|
217
|
+
collect_gpu_stats=False,
|
218
|
+
):
|
202
219
|
"""
|
203
220
|
Initializes the openLIT configuration and setups tracing.
|
204
221
|
|
@@ -271,7 +288,9 @@ def init(environment="default", application_name="default", tracer=None, otlp_en
|
|
271
288
|
name for name in disabled_instrumentors if name not in module_name_map
|
272
289
|
]
|
273
290
|
for invalid_name in invalid_instrumentors:
|
274
|
-
logger.warning(
|
291
|
+
logger.warning(
|
292
|
+
"Invalid instrumentor name detected and ignored: '%s'", invalid_name
|
293
|
+
)
|
275
294
|
|
276
295
|
try:
|
277
296
|
# Retrieve or create the single configuration instance.
|
@@ -301,7 +320,9 @@ def init(environment="default", application_name="default", tracer=None, otlp_en
|
|
301
320
|
)
|
302
321
|
|
303
322
|
if err:
|
304
|
-
logger.error(
|
323
|
+
logger.error(
|
324
|
+
"OpenLIT metrics setup failed. Metrics will not be available: %s", err
|
325
|
+
)
|
305
326
|
return
|
306
327
|
|
307
328
|
# Update global configuration with the provided settings.
|
@@ -366,8 +387,9 @@ def init(environment="default", application_name="default", tracer=None, otlp_en
|
|
366
387
|
|
367
388
|
# Initialize and instrument only the enabled instrumentors
|
368
389
|
for name, instrumentor in instrumentor_instances.items():
|
369
|
-
instrument_if_available(
|
370
|
-
|
390
|
+
instrument_if_available(
|
391
|
+
name, instrumentor, config, disabled_instrumentors, module_name_map
|
392
|
+
)
|
371
393
|
|
372
394
|
if not disable_metrics and collect_gpu_stats:
|
373
395
|
GPUInstrumentor().instrument(
|
@@ -377,24 +399,33 @@ def init(environment="default", application_name="default", tracer=None, otlp_en
|
|
377
399
|
except Exception as e:
|
378
400
|
logger.error("Error during openLIT initialization: %s", e)
|
379
401
|
|
380
|
-
|
381
|
-
|
402
|
+
|
403
|
+
def get_prompt(
|
404
|
+
url=None,
|
405
|
+
name=None,
|
406
|
+
api_key=None,
|
407
|
+
prompt_id=None,
|
408
|
+
version=None,
|
409
|
+
should_compile=None,
|
410
|
+
variables=None,
|
411
|
+
meta_properties=None,
|
412
|
+
):
|
382
413
|
"""
|
383
414
|
Retrieve and returns the prompt from OpenLIT Prompt Hub
|
384
415
|
"""
|
385
416
|
|
386
417
|
# Validate and set the base URL
|
387
418
|
url = get_env_variable(
|
388
|
-
|
419
|
+
"OPENLIT_URL",
|
389
420
|
url,
|
390
|
-
|
421
|
+
"Missing OpenLIT URL: Provide as arg or set OPENLIT_URL env var.",
|
391
422
|
)
|
392
423
|
|
393
424
|
# Validate and set the API key
|
394
425
|
api_key = get_env_variable(
|
395
|
-
|
426
|
+
"OPENLIT_API_KEY",
|
396
427
|
api_key,
|
397
|
-
|
428
|
+
"Missing API key: Provide as arg or set OPENLIT_API_KEY env var.",
|
398
429
|
)
|
399
430
|
|
400
431
|
# Construct the API endpoint
|
@@ -402,23 +433,20 @@ def get_prompt(url=None, name=None, api_key=None, prompt_id=None,
|
|
402
433
|
|
403
434
|
# Prepare the payload
|
404
435
|
payload = {
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
436
|
+
"name": name,
|
437
|
+
"promptId": prompt_id,
|
438
|
+
"version": version,
|
439
|
+
"shouldCompile": should_compile,
|
440
|
+
"variables": variables,
|
441
|
+
"metaProperties": meta_properties,
|
442
|
+
"source": "python-sdk",
|
412
443
|
}
|
413
444
|
|
414
445
|
# Remove None values from payload
|
415
446
|
payload = {k: v for k, v in payload.items() if v is not None}
|
416
447
|
|
417
448
|
# Prepare headers
|
418
|
-
headers = {
|
419
|
-
'Authorization': f'Bearer {api_key}',
|
420
|
-
'Content-Type': 'application/json'
|
421
|
-
}
|
449
|
+
headers = {"Authorization": f"Bearer {api_key}", "Content-Type": "application/json"}
|
422
450
|
|
423
451
|
try:
|
424
452
|
# Make the POST request to the API with headers
|
@@ -433,6 +461,7 @@ def get_prompt(url=None, name=None, api_key=None, prompt_id=None,
|
|
433
461
|
logger.error("Error fetching prompt: '%s'", error)
|
434
462
|
return None
|
435
463
|
|
464
|
+
|
436
465
|
def get_secrets(url=None, api_key=None, key=None, tags=None, should_set_env=None):
|
437
466
|
"""
|
438
467
|
Retrieve & returns the secrets from OpenLIT Vault & sets all to env is should_set_env is True
|
@@ -440,36 +469,29 @@ def get_secrets(url=None, api_key=None, key=None, tags=None, should_set_env=None
|
|
440
469
|
|
441
470
|
# Validate and set the base URL
|
442
471
|
url = get_env_variable(
|
443
|
-
|
472
|
+
"OPENLIT_URL",
|
444
473
|
url,
|
445
|
-
|
474
|
+
"Missing OpenLIT URL: Provide as arg or set OPENLIT_URL env var.",
|
446
475
|
)
|
447
476
|
|
448
477
|
# Validate and set the API key
|
449
478
|
api_key = get_env_variable(
|
450
|
-
|
479
|
+
"OPENLIT_API_KEY",
|
451
480
|
api_key,
|
452
|
-
|
481
|
+
"Missing API key: Provide as arg or set OPENLIT_API_KEY env var.",
|
453
482
|
)
|
454
483
|
|
455
484
|
# Construct the API endpoint
|
456
485
|
endpoint = url + "/api/vault/get-secrets"
|
457
486
|
|
458
487
|
# Prepare the payload
|
459
|
-
payload = {
|
460
|
-
'key': key,
|
461
|
-
'tags': tags,
|
462
|
-
'source': 'python-sdk'
|
463
|
-
}
|
488
|
+
payload = {"key": key, "tags": tags, "source": "python-sdk"}
|
464
489
|
|
465
490
|
# Remove None values from payload
|
466
491
|
payload = {k: v for k, v in payload.items() if v is not None}
|
467
492
|
|
468
493
|
# Prepare headers
|
469
|
-
headers = {
|
470
|
-
'Authorization': f'Bearer {api_key}',
|
471
|
-
'Content-Type': 'application/json'
|
472
|
-
}
|
494
|
+
headers = {"Authorization": f"Bearer {api_key}", "Content-Type": "application/json"}
|
473
495
|
|
474
496
|
try:
|
475
497
|
# Make the POST request to the API with headers
|
@@ -481,7 +503,7 @@ def get_secrets(url=None, api_key=None, key=None, tags=None, should_set_env=None
|
|
481
503
|
# Return the JSON response
|
482
504
|
vault_response = response.json()
|
483
505
|
|
484
|
-
res = vault_response.get(
|
506
|
+
res = vault_response.get("res", [])
|
485
507
|
|
486
508
|
if should_set_env is True:
|
487
509
|
for token, value in res.items():
|
@@ -491,32 +513,44 @@ def get_secrets(url=None, api_key=None, key=None, tags=None, should_set_env=None
|
|
491
513
|
logger.error("Error fetching secrets: '%s'", error)
|
492
514
|
return None
|
493
515
|
|
516
|
+
|
494
517
|
def trace(wrapped):
|
495
518
|
"""
|
496
519
|
Generates a telemetry wrapper for messages to collect metrics.
|
497
520
|
"""
|
521
|
+
if not callable(wrapped):
|
522
|
+
raise TypeError(
|
523
|
+
f"@trace can only be applied to callable objects, got {type(wrapped).__name__}"
|
524
|
+
)
|
525
|
+
|
526
|
+
try:
|
527
|
+
__trace = t.get_tracer_provider()
|
528
|
+
tracer = __trace.get_tracer(__name__)
|
529
|
+
except Exception as tracer_exception:
|
530
|
+
logging.error(
|
531
|
+
"Failed to initialize tracer: %s", tracer_exception, exc_info=True
|
532
|
+
)
|
533
|
+
raise
|
498
534
|
|
499
535
|
@wraps(wrapped)
|
500
536
|
def wrapper(*args, **kwargs):
|
501
|
-
|
502
|
-
with __trace.get_tracer(__name__).start_as_current_span(
|
537
|
+
with tracer.start_as_current_span(
|
503
538
|
name=wrapped.__name__,
|
504
539
|
kind=SpanKind.CLIENT,
|
505
540
|
) as span:
|
541
|
+
response = None
|
506
542
|
try:
|
507
543
|
response = wrapped(*args, **kwargs)
|
508
544
|
span.set_attribute(
|
509
|
-
SemanticConvetion.GEN_AI_CONTENT_COMPLETION, response
|
545
|
+
SemanticConvetion.GEN_AI_CONTENT_COMPLETION, response or ""
|
510
546
|
)
|
511
547
|
span.set_status(Status(StatusCode.OK))
|
512
|
-
|
513
548
|
except Exception as e:
|
514
|
-
response = None
|
515
549
|
span.record_exception(e)
|
516
|
-
span.set_status(status=Status(StatusCode.ERROR), description=e)
|
550
|
+
span.set_status(status=Status(StatusCode.ERROR), description=str(e))
|
517
551
|
logging.error("Error in %s: %s", wrapped.__name__, e, exc_info=True)
|
552
|
+
raise
|
518
553
|
|
519
|
-
# Adding function arguments as metadata
|
520
554
|
try:
|
521
555
|
span.set_attribute("function.args", str(args))
|
522
556
|
span.set_attribute("function.kwargs", str(kwargs))
|
@@ -527,7 +561,6 @@ def trace(wrapped):
|
|
527
561
|
span.set_attribute(
|
528
562
|
SemanticConvetion.GEN_AI_ENVIRONMENT, OpenlitConfig.environment
|
529
563
|
)
|
530
|
-
|
531
564
|
except Exception as meta_exception:
|
532
565
|
logging.error(
|
533
566
|
"Failed to set metadata for %s: %s",
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.3
|
2
2
|
Name: openlit
|
3
|
-
Version: 1.33.
|
3
|
+
Version: 1.33.6
|
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
|
Keywords: OpenTelemetry,otel,otlp,llm,tracing,openai,anthropic,claude,cohere,llm monitoring,observability,monitoring,gpt,Generative AI,chatGPT,gpu
|
6
6
|
Author: OpenLIT
|
@@ -90,6 +90,7 @@ This project proudly follows and maintains the [Semantic Conventions](https://gi
|
|
90
90
|
| [✅ Prem AI](https://docs.openlit.io/latest/integrations/premai) | | | |
|
91
91
|
| [✅ Assembly AI](https://docs.openlit.io/latest/integrations/assemblyai) | | | |
|
92
92
|
| [✅ Together](https://docs.openlit.io/latest/integrations/together) | | | |
|
93
|
+
| [✅ DeepSeek](https://docs.openlit.io/latest/integrations/deepseek) | | | |
|
93
94
|
|
94
95
|
## Supported Destinations
|
95
96
|
- [✅ OpenTelemetry Collector](https://docs.openlit.io/latest/connections/otelcol)
|
@@ -1,5 +1,5 @@
|
|
1
1
|
openlit/__helpers.py,sha256=bqMxdNndLW5NGO2wwpAoHEOnAFr_mhnmVLua3ifpSEc,6427
|
2
|
-
openlit/__init__.py,sha256=
|
2
|
+
openlit/__init__.py,sha256=mipHMzbi7mEDswpCMXky7WRGN12HlUczNU3HytePOZs,22419
|
3
3
|
openlit/evals/__init__.py,sha256=nJe99nuLo1b5rf7pt9U9BCdSDedzbVi2Fj96cgl7msM,380
|
4
4
|
openlit/evals/all.py,sha256=oWrue3PotE-rB5WePG3MRYSA-ro6WivkclSHjYlAqGs,7154
|
5
5
|
openlit/evals/bias_detection.py,sha256=mCdsfK7x1vX7S3psC3g641IMlZ-7df3h-V6eiICj5N8,8154
|
@@ -116,7 +116,7 @@ openlit/instrumentation/vllm/vllm.py,sha256=lDzM7F5pgxvh8nKL0dcKB4TD0Mc9wXOWeXOs
|
|
116
116
|
openlit/otel/metrics.py,sha256=y7SQDTyfLakMrz0V4DThN-WAeap7YZzyndeYGSP6nVg,4516
|
117
117
|
openlit/otel/tracing.py,sha256=fG3vl-flSZ30whCi7rrG25PlkIhhr8PhnfJYCkZzCD0,3895
|
118
118
|
openlit/semcov/__init__.py,sha256=_kxniPeCdAYC_ZK982gqDR6RwgFCIK8xUPCzotwtt0k,10975
|
119
|
-
openlit-1.33.
|
120
|
-
openlit-1.33.
|
121
|
-
openlit-1.33.
|
122
|
-
openlit-1.33.
|
119
|
+
openlit-1.33.6.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
120
|
+
openlit-1.33.6.dist-info/METADATA,sha256=8LEhtUrvFMrkQR-bfdZRfFC3sOu0oU_8L2nEZhjnoaQ,23354
|
121
|
+
openlit-1.33.6.dist-info/WHEEL,sha256=IYZQI976HJqqOpQU6PHkJ8fb3tMNBFjg-Cn-pwAbaFM,88
|
122
|
+
openlit-1.33.6.dist-info/RECORD,,
|
File without changes
|
File without changes
|