Add telemetry framework
- Add shared telemetry module - Add common telemetry helpers - Ignore Python cache files
This commit is contained in:
@@ -1,3 +1,5 @@
|
|||||||
*.backup
|
*.backup
|
||||||
*.backup-*
|
*.backup-*
|
||||||
config/mail-status.json
|
config/mail-status.json
|
||||||
|
config/mail-status.json
|
||||||
|
telemetry/__pycache__/
|
||||||
|
|||||||
@@ -0,0 +1,18 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
|
from pathlib import Path
|
||||||
|
from datetime import datetime, timezone
|
||||||
|
import json
|
||||||
|
|
||||||
|
def timestamp():
|
||||||
|
return datetime.now(timezone.utc).isoformat()
|
||||||
|
|
||||||
|
def write_json(path, payload):
|
||||||
|
path = Path(path)
|
||||||
|
path.parent.mkdir(parents=True, exist_ok=True)
|
||||||
|
|
||||||
|
payload["generated_at"] = timestamp()
|
||||||
|
|
||||||
|
tmp = path.with_suffix(".tmp")
|
||||||
|
tmp.write_text(json.dumps(payload, indent=2) + "\n")
|
||||||
|
tmp.replace(path)
|
||||||
Reference in New Issue
Block a user