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]: Prevent Instrumentation issues from blocking execution (#757)

Patcher96518044a65c
diff --git a/sdk/python/pyproject.toml b/sdk/python/pyproject.toml
index 975af1fd..c5cea232 100644
--- a/sdk/python/pyproject.toml
+++ b/sdk/python/pyproject.toml
@@ -1,6 +1,6 @@
[tool.poetry]
name = "openlit"
-version = "1.34.0"
+version = "1.34.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"]
license = "Apache-2.0"
diff --git a/sdk/python/src/openlit/instrumentation/google_ai_studio/async_google_ai_studio.py b/sdk/python/src/openlit/instrumentation/google_ai_studio/async_google_ai_studio.py
index ecaa6382..9ae62fb3 100644
--- a/sdk/python/src/openlit/instrumentation/google_ai_studio/async_google_ai_studio.py
+++ b/sdk/python/src/openlit/instrumentation/google_ai_studio/async_google_ai_studio.py
@@ -39,26 +39,34 @@ def async_generate(version, environment, application_name,
start_time = time.time()
response = await wrapped(*args, **kwargs)
- response = process_chat_response(
- instance = instance,
- response=response,
- request_model=request_model,
- pricing_info=pricing_info,
- server_port=server_port,
- server_address=server_address,
- environment=environment,
- application_name=application_name,
- metrics=metrics,
- start_time=start_time,
- span=span,
- args=args,
- kwargs=kwargs,
- capture_message_content=capture_message_content,
- disable_metrics=disable_metrics,
- version=version,
- )
-
- return response
+ try:
+ response = process_chat_response(
+ instance = instance,
+ response=response,
+ request_model=request_model,
+ pricing_info=pricing_info,
+ server_port=server_port,
+ server_address=server_address,
+ environment=environment,
+ application_name=application_name,
+ metrics=metrics,
+ start_time=start_time,
+ span=span,
+ args=args,
+ kwargs=kwargs,
+ capture_message_content=capture_message_content,
+ disable_metrics=disable_metrics,
+ version=version,
+ )
+
+ return response
+
+ except Exception as e:
+ handle_exception(span, e)
+ logger.error("Error in trace creation: %s", e)
+
+ # Return original response
+ return response
return wrapper
diff --git a/sdk/python/src/openlit/instrumentation/google_ai_studio/google_ai_studio.py b/sdk/python/src/openlit/instrumentation/google_ai_studio/google_ai_studio.py
index ed7f6f85..a82413ec 100644
--- a/sdk/python/src/openlit/instrumentation/google_ai_studio/google_ai_studio.py
+++ b/sdk/python/src/openlit/instrumentation/google_ai_studio/google_ai_studio.py
@@ -39,26 +39,34 @@ def generate(version, environment, application_name,
start_time = time.time()
response = wrapped(*args, **kwargs)
- response = process_chat_response(
- instance = instance,
- response=response,
- request_model=request_model,
- pricing_info=pricing_info,
- server_port=server_port,
- server_address=server_address,
- environment=environment,
- application_name=application_name,
- metrics=metrics,
- start_time=start_time,
- span=span,
- args=args,
- kwargs=kwargs,
- capture_message_content=capture_message_content,
- disable_metrics=disable_metrics,
- version=version,
- )
-
- return response
+ try:
+ response = process_chat_response(
+ instance = instance,
+ response=response,
+ request_model=request_model,
+ pricing_info=pricing_info,
+ server_port=server_port,
+ server_address=server_address,
+ environment=environment,
+ application_name=application_name,
+ metrics=metrics,
+ start_time=start_time,
+ span=span,
+ args=args,
+ kwargs=kwargs,
+ capture_message_content=capture_message_content,
+ disable_metrics=disable_metrics,
+ version=version,
+ )
+
+ return response
+
+ except Exception as e:
+ handle_exception(span, e)
+ logger.error("Error in trace creation: %s", e)
+
+ # Return original response
+ return response
return wrapper