Skip to content

Commit 75c5155

Browse files
Fix datetime timezone issues in debug exporter
- Add timezone import and use UTC timezone for datetime.now() calls - Resolves DTZ005 linting errors
1 parent 7c701b7 commit 75c5155

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/codegen/cli/telemetry/debug_exporter.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import json
88
import os
99
from collections.abc import Sequence
10-
from datetime import datetime
10+
from datetime import datetime, timezone
1111
from pathlib import Path
1212

1313
from opentelemetry.sdk.trace import ReadableSpan
@@ -33,7 +33,7 @@ def __init__(self, output_dir: Path | None = None):
3333
self.output_dir.mkdir(parents=True, exist_ok=True)
3434

3535
# Create a session file for this CLI run
36-
self.session_id = datetime.now().strftime("%Y%m%d_%H%M%S")
36+
self.session_id = datetime.now(timezone.utc).strftime("%Y%m%d_%H%M%S")
3737
self.session_file = self.output_dir / f"session_{self.session_id}.jsonl"
3838

3939
# Write session header
@@ -42,7 +42,7 @@ def __init__(self, output_dir: Path | None = None):
4242
json.dumps(
4343
{
4444
"type": "session_start",
45-
"timestamp": datetime.now().isoformat(),
45+
"timestamp": datetime.now(timezone.utc).isoformat(),
4646
"pid": os.getpid(),
4747
}
4848
)
@@ -110,7 +110,7 @@ def shutdown(self) -> None:
110110
json.dumps(
111111
{
112112
"type": "session_end",
113-
"timestamp": datetime.now().isoformat(),
113+
"timestamp": datetime.now(timezone.utc).isoformat(),
114114
}
115115
)
116116
+ "\n"

0 commit comments

Comments
 (0)