fix(datetime): replace deprecated utcnow() with timezone-aware equivalent (#15)
- Replaced datetime.utcnow() with datetime.now(timezone.utc) in router and observability modules - Preserves backwards compatibility with Python 3.10+ - Fixes #14
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
import json
|
import json
|
||||||
import logging
|
import logging
|
||||||
from typing import Dict, Any, Optional
|
from typing import Dict, Any, Optional
|
||||||
import datetime
|
import datetime
|
||||||
@@ -27,7 +27,7 @@ def log_router_event(
|
|||||||
payload = {
|
payload = {
|
||||||
"event": event_name,
|
"event": event_name,
|
||||||
"request_id": request_id,
|
"request_id": request_id,
|
||||||
"timestamp": datetime.datetime.utcnow().isoformat(),
|
"timestamp": datetime.datetime.now(datetime.timezone.utc).isoformat(),
|
||||||
"model": model,
|
"model": model,
|
||||||
"provider": provider,
|
"provider": provider,
|
||||||
"duration_ms": duration_ms,
|
"duration_ms": duration_ms,
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import uuid
|
import uuid
|
||||||
import datetime
|
import datetime
|
||||||
from typing import List, Dict, Any, Optional
|
from typing import List, Dict, Any, Optional
|
||||||
from app.models.schemas import (
|
from app.models.schemas import (
|
||||||
@@ -64,7 +64,7 @@ def route_request(
|
|||||||
) -> RoutingDecision:
|
) -> RoutingDecision:
|
||||||
req_id = request_id or str(uuid.uuid4())
|
req_id = request_id or str(uuid.uuid4())
|
||||||
decision_id = f"dec_{uuid.uuid4().hex[:12]}"
|
decision_id = f"dec_{uuid.uuid4().hex[:12]}"
|
||||||
now_iso = datetime.datetime.utcnow().isoformat()
|
now_iso = datetime.datetime.now(datetime.timezone.utc).isoformat()
|
||||||
|
|
||||||
# 1. Rule evaluation
|
# 1. Rule evaluation
|
||||||
rule_action, rule_target, rule_name = None, None, None
|
rule_action, rule_target, rule_name = None, None, None
|
||||||
|
|||||||
Reference in New Issue
Block a user