-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
241 additions
and
191 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { For, Show } from "solid-js"; | ||
|
||
type Props = { | ||
args: string[]; | ||
}; | ||
|
||
export function SpanDetailArgs(props: Props) { | ||
return ( | ||
<For each={props.args}> | ||
{(arg) => { | ||
return ( | ||
<For each={Object.entries(JSON.parse(arg))}> | ||
{([k, v]) => ( | ||
<Show | ||
when={ | ||
!["cmd", "callback", "error", "__tauriModule"].includes(k) | ||
} | ||
> | ||
<tr class="even:bg-nearly-invisible"> | ||
<td class="py-1 px-4 font-bold">{k}</td> | ||
<td class="py-1 px-4"> | ||
{typeof v === "object" ? JSON.stringify(v) : String(v)} | ||
</td> | ||
</tr> | ||
</Show> | ||
)} | ||
</For> | ||
); | ||
}} | ||
</For> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { For } from "solid-js"; | ||
import { UiSpan } from "~/lib/span/format-spans-for-ui"; | ||
|
||
export function SpanDetailTrace(props: { span: UiSpan }) { | ||
return ( | ||
<tr class="even:bg-nearly-invisible cursor-pointer hover:bg-[#ffffff05] even:hover:bg-[#ffffff10]"> | ||
<td class="py-1 px-4">{props.span.name}</td> | ||
<td class="py-1 px-4 relative w-[60%]"> | ||
<div class="relative w-[90%]"> | ||
<div class="bg-gray-800 w-full absolute rounded-sm h-2" /> | ||
<div class="relative h-2" style={props.span.waterfall}> | ||
{/* Slices is "time slices" as in multiple entry points to a given span */} | ||
<For each={props.span.slices}> | ||
{(slice) => ( | ||
<div | ||
class="absolute bg-teal-500 top-0 left-0 h-full" | ||
style={slice} | ||
/> | ||
)} | ||
</For> | ||
</div> | ||
</div> | ||
</td> | ||
</tr> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
import { useSearchParams } from "@solidjs/router"; | ||
import { For } from "solid-js"; | ||
import type { UiSpan, formatSpansForUi } from "~/lib/span/format-spans-for-ui"; | ||
import { getColumnDirection } from "~/lib/span/get-column-direction"; | ||
import { resolveColumnAlias } from "~/lib/span/resolve-column-alias"; | ||
import { SortCaret } from "./sort-caret"; | ||
import { getTime } from "~/lib/formatters"; | ||
import clsx from "clsx"; | ||
|
||
export type SortDirection = "asc" | "desc"; | ||
export type SortableColumn = keyof ReturnType<typeof formatSpansForUi>[-1]; | ||
export type ColumnSort = { | ||
name: SortableColumn; | ||
direction: SortDirection; | ||
}; | ||
|
||
type Props = { | ||
spans: UiSpan[]; | ||
columnSort: ColumnSort; | ||
setColumnSort: (columnSort: ColumnSort) => void; | ||
}; | ||
|
||
export function SpanList(props: Props) { | ||
const columns = () => | ||
[...Object.keys(props.spans?.[0] ?? {})].filter((k) => | ||
["name", "initiated", "time", "waterfall"].includes(k) | ||
); | ||
const [, setSearchParams] = useSearchParams(); | ||
|
||
const sortColumn = (name: SortableColumn) => { | ||
props.setColumnSort({ | ||
name, | ||
direction: getColumnDirection(props.columnSort, name), | ||
}); | ||
}; | ||
|
||
return ( | ||
<table class="w-full table-fixed"> | ||
<thead> | ||
<tr class="text-left"> | ||
<For each={columns()}> | ||
{(column) => { | ||
const resolvedColumn = resolveColumnAlias( | ||
column as SortableColumn | ||
); | ||
return ( | ||
<th | ||
tabIndex={0} | ||
onKeyDown={(e) => { | ||
if ([" ", "Enter"].includes(e.key)) { | ||
sortColumn(resolvedColumn); | ||
} | ||
}} | ||
onClick={() => sortColumn(resolvedColumn)} | ||
class="p-1 cursor-pointer hover:bg-[#ffffff09]" | ||
> | ||
<div class="flex uppercase select-none items-center gap-2"> | ||
{column} | ||
{props.columnSort.name === resolvedColumn && ( | ||
<SortCaret direction={props.columnSort.direction} /> | ||
)} | ||
</div> | ||
</th> | ||
); | ||
}} | ||
</For> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<For each={props.spans}> | ||
{(span) => { | ||
return ( | ||
<tr | ||
onClick={() => setSearchParams({ span: span.id })} | ||
class="even:bg-nearly-invisible cursor-pointer hover:bg-[#ffffff05] even:hover:bg-[#ffffff10]" | ||
> | ||
<td class="p-1">{span.name}</td> | ||
<td class="p-1">{getTime(new Date(span.initiated))}</td> | ||
<td class="p-1">{span.time.toFixed(2)}ms</td> | ||
<td class="p-1 relative"> | ||
<div class="relative w-[90%]"> | ||
<div class="bg-gray-800 w-full absolute rounded-sm h-2" /> | ||
<div | ||
class={clsx( | ||
"relative rounded-sm h-2", | ||
span.colorClassName | ||
)} | ||
style={span.waterfall} | ||
> | ||
<For each={span.slices}> | ||
{(slice) => ( | ||
<div | ||
class="absolute top-0 left-0 bg-black bg-opacity-10 h-full" | ||
style={slice} | ||
/> | ||
)} | ||
</For> | ||
</div> | ||
</div> | ||
</td> | ||
</tr> | ||
); | ||
}} | ||
</For> | ||
</tbody> | ||
</table> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { Tooltip } from "@kobalte/core"; | ||
import { Show } from "solid-js"; | ||
|
||
type Props = { | ||
granularity: number; | ||
setGranularity: (granularity: number) => void; | ||
totalDuration: number; | ||
}; | ||
|
||
export function SpanScaleSlider(props: Props) { | ||
return ( | ||
<div class="flex items-center gap-2"> | ||
<Tooltip.Root> | ||
<Tooltip.Trigger> | ||
<span class="flex items-center gap-1"> | ||
Scale Spans | ||
<Show when={props.granularity > 1}> | ||
<span>ⓘ</span> | ||
</Show> | ||
</span> | ||
</Tooltip.Trigger> | ||
<Tooltip.Content> | ||
<div class="rounded p-2 bg-black shadow"> | ||
Concurrency may appear skewed when spans are scaled. | ||
</div> | ||
</Tooltip.Content> | ||
</Tooltip.Root> | ||
<input | ||
type="range" | ||
min={1} | ||
max={props.totalDuration} | ||
value={props.granularity} | ||
onInput={(e) => props.setGranularity(Number(e.currentTarget.value))} | ||
/> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.