From f5785ae41be4f98a8f615921c393f7a4c7cda279 Mon Sep 17 00:00:00 2001 From: Franklin <5235904+mrFranklin@users.noreply.github.com> Date: Fri, 19 Sep 2025 10:46:09 +0800 Subject: [PATCH] fix: timezone issue of opik --- litellm/integrations/opik/opik.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/litellm/integrations/opik/opik.py b/litellm/integrations/opik/opik.py index 8cbfb9e653..9f90d2384d 100644 --- a/litellm/integrations/opik/opik.py +++ b/litellm/integrations/opik/opik.py @@ -3,6 +3,7 @@ Opik Logger that logs LLM events to an Opik server """ import asyncio +from datetime import timezone import json import traceback from typing import Dict, List @@ -291,8 +292,8 @@ class OpikLogger(CustomBatchLogger): "project_name": project_name, "id": trace_id, "name": trace_name, - "start_time": start_time.isoformat() + "Z", - "end_time": end_time.isoformat() + "Z", + "start_time": start_time.astimezone(timezone.utc).isoformat().replace("+00:00", "Z"), + "end_time": end_time.astimezone(timezone.utc).isoformat().replace("+00:00", "Z"), "input": input_data, "output": output_data, "metadata": metadata, @@ -312,8 +313,8 @@ class OpikLogger(CustomBatchLogger): "parent_span_id": parent_span_id, "name": span_name, "type": "llm", - "start_time": start_time.isoformat() + "Z", - "end_time": end_time.isoformat() + "Z", + "start_time": start_time.astimezone(timezone.utc).isoformat().replace("+00:00", "Z"), + "end_time": end_time.astimezone(timezone.utc).isoformat().replace("+00:00", "Z"), "input": input_data, "output": output_data, "metadata": metadata,