Skip to content

Same agent Smaller bill. The tools and infrastructure to get more work from your AI. Fewer tokens. Less compute. Lower cost.

[Fix]: Add pydnatic dependency and fix error logging when metric creation fails (#488)

Patcherc4992497429c
diff --git a/sdk/python/pyproject.toml b/sdk/python/pyproject.toml
index 0e327fbb..73c76f17 100644
--- a/sdk/python/pyproject.toml
+++ b/sdk/python/pyproject.toml
@@ -1,6 +1,6 @@
[tool.poetry]
name = "openlit"
-version = "1.27.0"
+version = "1.27.1"
description = "OpenTelemetry-native Auto instrumentation library for monitoring LLM Applications and GPUs, facilitating the integration of observability into your GenAI-driven projects"
authors = ["OpenLIT"]
repository = "https://github.com/openlit/openlit/tree/main/openlit/python"
@@ -13,6 +13,7 @@ python = "^3.7.1"
requests = "^2.26.0"
schedule = "^1.2.2"
tiktoken = "^0.7.0"
+pydantic = "^2.0.0"
gpustat = "^1.1.1"
boto3 = "^1.34.0"
botocore = "^1.34.0"
diff --git a/sdk/python/src/openlit/__init__.py b/sdk/python/src/openlit/__init__.py
index 2cff95c6..c49c6421 100644
--- a/sdk/python/src/openlit/__init__.py
+++ b/sdk/python/src/openlit/__init__.py
@@ -255,7 +255,7 @@ def init(environment="default", application_name="default", tracer=None, otlp_en
return
# Setup meter and receive metrics_dict instead of meter.
- metrics_dict = setup_meter(
+ metrics_dict, err = setup_meter(
application_name=application_name,
environment=environment,
meter=meter,
@@ -263,8 +263,8 @@ def init(environment="default", application_name="default", tracer=None, otlp_en
otlp_headers=otlp_headers,
)
- if not metrics_dict:
- logger.error("openLIT metrics setup failed. Metrics will not be available.")
+ if err:
+ logger.error("OpenLIT metrics setup failed. Metrics will not be available: %s", err)
return
# Update global configuration with the provided settings.
diff --git a/sdk/python/src/openlit/otel/metrics.py b/sdk/python/src/openlit/otel/metrics.py
index e5309798..eeb3ef53 100644
--- a/sdk/python/src/openlit/otel/metrics.py
+++ b/sdk/python/src/openlit/otel/metrics.py
@@ -102,8 +102,8 @@ def setup_meter(application_name, environment, meter, otlp_endpoint, otlp_header
),
}
- return metrics_dict
+ return metrics_dict, None
- # pylint: disable=bare-except
- except:
- return None
+ # pylint: disable=broad-exception-caught
+ except Exception as err:
+ return None, err