Skip to content

Commit e4a5527

Browse files
committed
feat: initial span ui
1 parent 0a2ff02 commit e4a5527

19 files changed

Lines changed: 2094 additions & 503 deletions

src/duron/tracing/_tracer.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import os
55
import threading
66
import time
7-
import uuid
87
from contextvars import ContextVar
98
from dataclasses import dataclass
109
from hashlib import blake2b
@@ -43,7 +42,7 @@ def __init__(
4342
instance_id: str | None = None,
4443
) -> None:
4544
self.trace_id: str = trace_id
46-
self.instance_id: str = instance_id or uuid.uuid4().hex
45+
self.instance_id: str = instance_id or _trace_id()
4746
self._events: list[TraceEvent] = []
4847
self._lock = threading.Lock()
4948

@@ -249,3 +248,12 @@ def _random_id() -> str:
249248

250249
def _derive_id(base: str) -> str:
251250
return blake2b(base.encode(), digest_size=8).hexdigest()
251+
252+
253+
def _trace_id() -> str:
254+
data = bytearray(16)
255+
data[:6] = (time.time_ns() // 1_000_000).to_bytes(6, "big")
256+
data[6:] = os.urandom(10)
257+
data[6] = (data[6] & 0x0F) | 0x70
258+
data[8] = (data[8] & 0x3F) | 0x80
259+
return data.hex()

tools/trace-ui/README.md

Lines changed: 0 additions & 75 deletions
This file was deleted.

tools/trace-ui/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
<html lang="en">
33
<head>
44
<meta charset="UTF-8" />
5+
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
56
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
67
<title>Duron Trace UI</title>
78
</head>

tools/trace-ui/package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
"scripts": {
88
"dev": "vite",
99
"build": "tsc -b && vite build",
10+
"check": "tsc -b",
1011
"lint": "prettier --check . && eslint .",
1112
"format": "prettier --write .",
1213
"preview": "vite preview"
@@ -27,7 +28,7 @@
2728
"@trivago/prettier-plugin-sort-imports": "^5.2.2",
2829
"@types/node": "^24.7.2",
2930
"@types/react": "^19.2.2",
30-
"@types/react-dom": "^19.2.1",
31+
"@types/react-dom": "^19.2.2",
3132
"@vitejs/plugin-react": "^5.0.4",
3233
"babel-plugin-react-compiler": "19.1.0-rc.3",
3334
"eslint": "^9.37.0",
@@ -40,7 +41,7 @@
4041
"tailwindcss": "^4.1.14",
4142
"tw-animate-css": "^1.4.0",
4243
"typescript": "~5.9.3",
43-
"typescript-eslint": "^8.46.0",
44+
"typescript-eslint": "^8.46.1",
4445
"vite": "^7.1.9"
4546
}
4647
}

0 commit comments

Comments
 (0)