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]: Attributes in OpenTelemetry Instrumentations (#859)

Patcher1cf2083eec34
diff --git a/sdk/python/pyproject.toml b/sdk/python/pyproject.toml
index 2fecfe7d..17aec540 100644
--- a/sdk/python/pyproject.toml
+++ b/sdk/python/pyproject.toml
@@ -1,6 +1,6 @@
[tool.poetry]
name = "openlit"
-version = "1.35.1"
+version = "1.35.2"
description = "OpenTelemetry-native Auto instrumentation library for monitoring LLM Applications and GPUs, facilitating the integration of observability into your GenAI-driven projects"
authors = ["OpenLIT"]
license = "Apache-2.0"
diff --git a/sdk/python/src/openlit/__helpers.py b/sdk/python/src/openlit/__helpers.py
index 820d96b9..b47911ac 100644
--- a/sdk/python/src/openlit/__helpers.py
+++ b/sdk/python/src/openlit/__helpers.py
@@ -209,6 +209,29 @@ def create_metrics_attributes(
}
+def create_db_metrics_attributes(
+ service_name: str,
+ deployment_environment: str,
+ db_system: str,
+ db_operation: str,
+ server_address: str,
+ server_port: int,
+) -> Dict[Any, Any]:
+ """
+ Returns OTel metrics attributes for database operations
+ """
+
+ return {
+ TELEMETRY_SDK_NAME: "openlit",
+ SERVICE_NAME: service_name,
+ DEPLOYMENT_ENVIRONMENT: deployment_environment,
+ SemanticConvention.DB_SYSTEM_NAME: db_system,
+ SemanticConvention.DB_OPERATION_NAME: db_operation,
+ SemanticConvention.SERVER_ADDRESS: server_address,
+ SemanticConvention.SERVER_PORT: server_port,
+ }
+
+
def set_server_address_and_port(
client_instance: Any, default_server_address: str, default_server_port: int
) -> Tuple[str, int]:
@@ -802,20 +825,19 @@ def record_db_metrics(
application_name,
start_time,
end_time,
+ db_operation,
):
"""
Record database-specific metrics for the operation.
"""
- attributes = create_metrics_attributes(
- operation=SemanticConvention.GEN_AI_OPERATION_TYPE_VECTORDB,
- system=db_system,
- request_model=db_system,
- server_address=server_address,
- server_port=server_port,
- response_model=db_system,
+ attributes = create_db_metrics_attributes(
service_name=application_name,
deployment_environment=environment,
+ db_system=db_system,
+ db_operation=db_operation,
+ server_address=server_address,
+ server_port=server_port,
)
metrics["db_requests"].add(1, attributes)
metrics["db_client_operation_duration"].record(end_time - start_time, attributes)
diff --git a/sdk/python/src/openlit/instrumentation/astra/utils.py b/sdk/python/src/openlit/instrumentation/astra/utils.py
index 04cc29a6..1bcbdb01 100644
--- a/sdk/python/src/openlit/instrumentation/astra/utils.py
+++ b/sdk/python/src/openlit/instrumentation/astra/utils.py
@@ -303,6 +303,7 @@ def common_astra_logic(
application_name,
scope._start_time,
scope._end_time,
+ scope._db_operation,
)
diff --git a/sdk/python/src/openlit/instrumentation/chroma/utils.py b/sdk/python/src/openlit/instrumentation/chroma/utils.py
index 68a4d764..e2c1a04f 100644
--- a/sdk/python/src/openlit/instrumentation/chroma/utils.py
+++ b/sdk/python/src/openlit/instrumentation/chroma/utils.py
@@ -337,6 +337,7 @@ def common_vectordb_logic(
application_name,
scope._start_time,
scope._end_time,
+ scope._db_operation,
)
diff --git a/sdk/python/src/openlit/instrumentation/milvus/utils.py b/sdk/python/src/openlit/instrumentation/milvus/utils.py
index 28f8fde6..66c444bd 100644
--- a/sdk/python/src/openlit/instrumentation/milvus/utils.py
+++ b/sdk/python/src/openlit/instrumentation/milvus/utils.py
@@ -306,6 +306,7 @@ def common_milvus_logic(
application_name,
scope._start_time,
scope._end_time,
+ scope._db_operation,
)
diff --git a/sdk/python/src/openlit/instrumentation/pinecone/utils.py b/sdk/python/src/openlit/instrumentation/pinecone/utils.py
index 183c815f..aadafb9f 100644
--- a/sdk/python/src/openlit/instrumentation/pinecone/utils.py
+++ b/sdk/python/src/openlit/instrumentation/pinecone/utils.py
@@ -283,6 +283,7 @@ def common_vectordb_logic(
application_name,
scope._start_time,
scope._end_time,
+ scope._db_operation,
)
diff --git a/sdk/python/src/openlit/instrumentation/qdrant/utils.py b/sdk/python/src/openlit/instrumentation/qdrant/utils.py
index 35f32223..4e2bcceb 100644
--- a/sdk/python/src/openlit/instrumentation/qdrant/utils.py
+++ b/sdk/python/src/openlit/instrumentation/qdrant/utils.py
@@ -413,6 +413,7 @@ def common_qdrant_logic(
application_name,
scope._start_time,
scope._end_time,
+ scope._db_operation,
)
diff --git a/sdk/python/src/openlit/semcov/__init__.py b/sdk/python/src/openlit/semcov/__init__.py
index 51c0342b..36dccfab 100644
--- a/sdk/python/src/openlit/semcov/__init__.py
+++ b/sdk/python/src/openlit/semcov/__init__.py
@@ -353,7 +353,7 @@ class SemanticConvention:
DB_OPERATION_UPSERT = "UPSERT"
DB_OPERATION_GET = "GET"
DB_OPERATION_ADD = "ADD"
- DB_OPERATION_PEEK = "peePEEKk"
+ DB_OPERATION_PEEK = "PEEK"
DB_ID_COUNT = "db.ids_count"
DB_VECTOR_COUNT = "db.vector.count"
DB_METADATA = "db.metadata"