effect-start 0.30.1 → 0.32.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Fetch.d.ts +1 -1
- package/dist/Fetch.d.ts.map +1 -1
- package/dist/Fetch.js +1 -1
- package/dist/Fetch.js.map +1 -1
- package/dist/GlobalLayer.d.ts.map +1 -1
- package/dist/GlobalLayer.js.map +1 -1
- package/dist/Html.js +3 -3
- package/dist/Html.js.map +1 -1
- package/dist/Password.d.ts +26 -0
- package/dist/Password.d.ts.map +1 -0
- package/dist/Password.js +83 -0
- package/dist/Password.js.map +1 -0
- package/dist/Route.d.ts.map +1 -1
- package/dist/Route.js +1 -1
- package/dist/Route.js.map +1 -1
- package/dist/RouteBody.d.ts +10 -5
- package/dist/RouteBody.d.ts.map +1 -1
- package/dist/RouteBody.js +6 -2
- package/dist/RouteBody.js.map +1 -1
- package/dist/RouteHttp.d.ts.map +1 -1
- package/dist/RouteHttp.js +10 -3
- package/dist/RouteHttp.js.map +1 -1
- package/dist/RouteSse.d.ts +3 -4
- package/dist/RouteSse.d.ts.map +1 -1
- package/dist/RouteSse.js +3 -3
- package/dist/RouteSse.js.map +1 -1
- package/dist/RouteTree.d.ts +20 -5
- package/dist/RouteTree.d.ts.map +1 -1
- package/dist/RouteTree.js +172 -40
- package/dist/RouteTree.js.map +1 -1
- package/dist/StaticFiles.d.ts +23 -0
- package/dist/StaticFiles.d.ts.map +1 -0
- package/dist/StaticFiles.js +74 -0
- package/dist/StaticFiles.js.map +1 -0
- package/dist/_Mime.d.ts +2 -0
- package/dist/_Mime.d.ts.map +1 -0
- package/dist/_Mime.js +33 -0
- package/dist/_Mime.js.map +1 -0
- package/dist/_PathPattern.js +4 -4
- package/dist/_PathPattern.js.map +1 -1
- package/dist/_StreamExtra.d.ts.map +1 -1
- package/dist/_StreamExtra.js +0 -1
- package/dist/_StreamExtra.js.map +1 -1
- package/dist/bun/BunRoute.d.ts.map +1 -1
- package/dist/bun/BunRoute.js +6 -0
- package/dist/bun/BunRoute.js.map +1 -1
- package/dist/bun/BunServer.d.ts +2 -0
- package/dist/bun/BunServer.d.ts.map +1 -1
- package/dist/bun/BunServer.js +18 -7
- package/dist/bun/BunServer.js.map +1 -1
- package/dist/studio/Studio.d.ts +1 -1
- package/dist/studio/Studio.d.ts.map +1 -1
- package/dist/studio/Studio.js +5 -4
- package/dist/studio/Studio.js.map +1 -1
- package/dist/studio/StudioErrors.d.ts.map +1 -1
- package/dist/studio/StudioErrors.js +2 -2
- package/dist/studio/StudioErrors.js.map +1 -1
- package/dist/studio/StudioLogger.d.ts.map +1 -1
- package/dist/studio/StudioLogger.js +1 -3
- package/dist/studio/StudioLogger.js.map +1 -1
- package/dist/studio/StudioStore.d.ts +23 -17
- package/dist/studio/StudioStore.d.ts.map +1 -1
- package/dist/studio/StudioStore.js +48 -44
- package/dist/studio/StudioStore.js.map +1 -1
- package/dist/studio/StudioTracer.d.ts.map +1 -1
- package/dist/studio/StudioTracer.js +10 -4
- package/dist/studio/StudioTracer.js.map +1 -1
- package/dist/studio/routes/errors/route.d.ts +2 -2
- package/dist/studio/routes/errors/route.d.ts.map +1 -1
- package/dist/studio/routes/errors/route.js +2 -2
- package/dist/studio/routes/errors/route.js.map +1 -1
- package/dist/studio/routes/fiberDetail.d.ts +1 -1
- package/dist/studio/routes/fiberDetail.js +4 -4
- package/dist/studio/routes/fiberDetail.js.map +1 -1
- package/dist/studio/routes/fibers/route.d.ts +3 -3
- package/dist/studio/routes/fibers/route.js +4 -4
- package/dist/studio/routes/fibers/route.js.map +1 -1
- package/dist/studio/routes/logs/route.d.ts +2 -2
- package/dist/studio/routes/logs/route.d.ts.map +1 -1
- package/dist/studio/routes/logs/route.js +2 -2
- package/dist/studio/routes/logs/route.js.map +1 -1
- package/dist/studio/routes/metrics/route.d.ts +1 -1
- package/dist/studio/routes/system/route.d.ts +1 -1
- package/dist/studio/routes/traceDetail.d.ts +1 -1
- package/dist/studio/routes/traceDetail.js +1 -1
- package/dist/studio/routes/traceDetail.js.map +1 -1
- package/dist/studio/routes/traces/route.d.ts +3 -3
- package/dist/studio/routes/traces/route.js +5 -5
- package/dist/studio/routes/traces/route.js.map +1 -1
- package/dist/studio/routes/tree.d.ts +14 -14
- package/dist/studio/ui/Traces.d.ts +1 -0
- package/dist/studio/ui/Traces.d.ts.map +1 -1
- package/dist/studio/ui/Traces.js +32 -11
- package/dist/studio/ui/Traces.js.map +1 -1
- package/package.json +2 -2
- package/src/Fetch.ts +2 -2
- package/src/GlobalLayer.ts +1 -3
- package/src/Html.ts +3 -3
- package/src/Password.ts +130 -0
- package/src/Route.ts +10 -12
- package/src/RouteBody.ts +36 -14
- package/src/RouteHttp.ts +14 -3
- package/src/RouteSse.ts +10 -10
- package/src/RouteTree.ts +252 -61
- package/src/StaticFiles.ts +112 -0
- package/src/_Mime.ts +33 -0
- package/src/_PathPattern.ts +4 -4
- package/src/_StreamExtra.ts +0 -1
- package/src/bun/BunRoute.ts +10 -0
- package/src/bun/BunServer.ts +33 -7
- package/src/studio/Studio.ts +6 -5
- package/src/studio/StudioErrors.ts +2 -3
- package/src/studio/StudioLogger.ts +2 -3
- package/src/studio/StudioStore.ts +159 -115
- package/src/studio/StudioTracer.ts +11 -5
- package/src/studio/routes/errors/route.tsx +4 -5
- package/src/studio/routes/fiberDetail.tsx +4 -4
- package/src/studio/routes/fibers/route.tsx +4 -4
- package/src/studio/routes/logs/route.tsx +3 -1
- package/src/studio/routes/traceDetail.tsx +1 -1
- package/src/studio/routes/traces/route.tsx +8 -8
- package/src/studio/ui/Traces.tsx +41 -13
|
@@ -12,7 +12,7 @@ export default Route.get(
|
|
|
12
12
|
Route.html(function* (ctx) {
|
|
13
13
|
const url = new URL(ctx.request.url)
|
|
14
14
|
const search = url.searchParams.get("traceSearch") || ""
|
|
15
|
-
const allSpans = yield* StudioStore.allSpans(
|
|
15
|
+
const allSpans = yield* StudioStore.allSpans()
|
|
16
16
|
const names = Array.from(new Set(allSpans.map((s) => s.name))).sort()
|
|
17
17
|
let spans = allSpans
|
|
18
18
|
if (search) {
|
|
@@ -52,17 +52,17 @@ export default Route.get(
|
|
|
52
52
|
}),
|
|
53
53
|
Route.sse(
|
|
54
54
|
Stream.fromPubSub(StudioStore.store.events).pipe(
|
|
55
|
-
Stream.filter((e) => e._tag === "
|
|
56
|
-
Stream.mapEffect(() =>
|
|
55
|
+
Stream.filter((e) => e._tag === "TraceEnd"),
|
|
56
|
+
Stream.mapEffect((e) =>
|
|
57
57
|
Effect.gen(function* () {
|
|
58
|
-
const
|
|
59
|
-
const
|
|
60
|
-
|
|
61
|
-
"",
|
|
58
|
+
const traceSpans = yield* StudioStore.spansByTraceId(e.traceId)
|
|
59
|
+
const traceHtml = Html.renderToString(
|
|
60
|
+
<Traces.TraceGroup id={e.traceId} spans={traceSpans} />,
|
|
62
61
|
)
|
|
62
|
+
|
|
63
63
|
return {
|
|
64
64
|
event: "datastar-patch-elements",
|
|
65
|
-
data: `selector
|
|
65
|
+
data: `selector .tl-header\nmode after\nelements ${traceHtml}`,
|
|
66
66
|
}
|
|
67
67
|
}),
|
|
68
68
|
),
|
package/src/studio/ui/Traces.tsx
CHANGED
|
@@ -47,6 +47,20 @@ interface TreeSpan {
|
|
|
47
47
|
ancestorHasNextSibling: Array<boolean>
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
+
function sortByStartTime(a: StudioStore.StudioSpan, b: StudioStore.StudioSpan): number {
|
|
51
|
+
if (a.startTime < b.startTime) return -1
|
|
52
|
+
if (a.startTime > b.startTime) return 1
|
|
53
|
+
return 0
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function pickRootSpan(spans: Array<StudioStore.StudioSpan>): StudioStore.StudioSpan {
|
|
57
|
+
const spanIds = new Set(spans.map((span) => span.spanId))
|
|
58
|
+
return (
|
|
59
|
+
spans.find((span) => !span.parentSpanId || !spanIds.has(span.parentSpanId)) ??
|
|
60
|
+
spans.slice().sort(sortByStartTime)[0]
|
|
61
|
+
)
|
|
62
|
+
}
|
|
63
|
+
|
|
50
64
|
function buildSpanTree(spans: Array<StudioStore.StudioSpan>): Array<TreeSpan> {
|
|
51
65
|
const byId = new Map<bigint, StudioStore.StudioSpan>()
|
|
52
66
|
const childrenOf = new Map<bigint, Array<StudioStore.StudioSpan>>()
|
|
@@ -69,23 +83,31 @@ function buildSpanTree(spans: Array<StudioStore.StudioSpan>): Array<TreeSpan> {
|
|
|
69
83
|
}
|
|
70
84
|
}
|
|
71
85
|
|
|
72
|
-
|
|
73
|
-
Number(a.startTime - b.startTime)
|
|
74
|
-
|
|
75
|
-
roots.sort(sortByStart)
|
|
86
|
+
roots.sort(sortByStartTime)
|
|
76
87
|
for (const children of childrenOf.values()) {
|
|
77
|
-
children.sort(
|
|
88
|
+
children.sort(sortByStartTime)
|
|
78
89
|
}
|
|
79
90
|
|
|
80
91
|
const result: Array<TreeSpan> = []
|
|
92
|
+
const visited = new Set<bigint>()
|
|
81
93
|
|
|
82
94
|
function walk(
|
|
83
95
|
span: StudioStore.StudioSpan,
|
|
84
96
|
depth: number,
|
|
85
97
|
isLast: boolean,
|
|
86
98
|
ancestors: Array<boolean>,
|
|
99
|
+
lineage: Set<bigint>,
|
|
87
100
|
) {
|
|
88
|
-
|
|
101
|
+
if (lineage.has(span.spanId) || visited.has(span.spanId)) return
|
|
102
|
+
|
|
103
|
+
const nextLineage = new Set(lineage)
|
|
104
|
+
nextLineage.add(span.spanId)
|
|
105
|
+
|
|
106
|
+
const children = (childrenOf.get(span.spanId) ?? []).filter(
|
|
107
|
+
(child) => !nextLineage.has(child.spanId) && !visited.has(child.spanId),
|
|
108
|
+
)
|
|
109
|
+
|
|
110
|
+
visited.add(span.spanId)
|
|
89
111
|
result.push({
|
|
90
112
|
span,
|
|
91
113
|
depth,
|
|
@@ -94,12 +116,18 @@ function buildSpanTree(spans: Array<StudioStore.StudioSpan>): Array<TreeSpan> {
|
|
|
94
116
|
ancestorHasNextSibling: [...ancestors],
|
|
95
117
|
})
|
|
96
118
|
for (let i = 0; i < children.length; i++) {
|
|
97
|
-
walk(children[i], depth + 1, i === children.length - 1, [...ancestors, !isLast])
|
|
119
|
+
walk(children[i], depth + 1, i === children.length - 1, [...ancestors, !isLast], nextLineage)
|
|
98
120
|
}
|
|
99
121
|
}
|
|
100
122
|
|
|
101
123
|
for (let i = 0; i < roots.length; i++) {
|
|
102
|
-
walk(roots[i], 0, i === roots.length - 1, [])
|
|
124
|
+
walk(roots[i], 0, i === roots.length - 1, [], new Set())
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
const remaining = spans.filter((span) => !visited.has(span.spanId)).sort(sortByStartTime)
|
|
128
|
+
|
|
129
|
+
for (let i = 0; i < remaining.length; i++) {
|
|
130
|
+
walk(remaining[i], 0, i === remaining.length - 1, [], new Set())
|
|
103
131
|
}
|
|
104
132
|
|
|
105
133
|
return result
|
|
@@ -225,17 +253,17 @@ export function groupByTraceId(
|
|
|
225
253
|
return groups
|
|
226
254
|
}
|
|
227
255
|
|
|
228
|
-
export function TraceGroup(options: { spans: Array<StudioStore.StudioSpan> }) {
|
|
256
|
+
export function TraceGroup(options: { id?: bigint; spans: Array<StudioStore.StudioSpan> }) {
|
|
229
257
|
if (options.spans.length === 0) return null
|
|
230
|
-
const root = options.spans
|
|
231
|
-
const traceId = root.traceId
|
|
258
|
+
const root = pickRootSpan(options.spans)
|
|
259
|
+
const traceId = options.id ?? root.traceId
|
|
232
260
|
const totalMs = root.durationMs ?? 0
|
|
233
261
|
const rootStart = root.startTime
|
|
234
262
|
const hasError = options.spans.some((s) => s.status === "error")
|
|
235
263
|
const status = hasError ? "error" : root.status
|
|
236
264
|
|
|
237
265
|
return (
|
|
238
|
-
<details class="tl-row">
|
|
266
|
+
<details id={`trace-${traceId}`} class="tl-row">
|
|
239
267
|
<summary class="tl-summary tl-cols">
|
|
240
268
|
<span class="tl-cell tl-cell-status">
|
|
241
269
|
<span
|
|
@@ -324,7 +352,7 @@ export function TraceDetail(options: { prefix: string; spans: Array<StudioStore.
|
|
|
324
352
|
if (options.spans.length === 0) {
|
|
325
353
|
return <div class="empty">Trace not found</div>
|
|
326
354
|
}
|
|
327
|
-
const root = options.spans
|
|
355
|
+
const root = pickRootSpan(options.spans)
|
|
328
356
|
const traceId = root.traceId
|
|
329
357
|
const totalMs = root.durationMs ?? 0
|
|
330
358
|
const rootStart = root.startTime
|