import { h } from 'preact' import type { TraceMessage } from '../hooks/useConnection' import MetricCard from './MetricCard' interface TraceDetailProps { readonly trace: TraceMessage | undefined } function formatDuration(ms: number): string { if (ms >= 1000) { return `${(ms / 1000).toFixed(2)}s` } return `${ms.toFixed(2)}ms` } function outcomeColor(outcome: string): string { if (outcome === 'render') { return 'var(--color-success)' } if (outcome === 'error') { return 'var(--color-error)' } return 'var(--accent)' } function capitalize(value: string): string { return value.charAt(0).toUpperCase() + value.slice(1) } export default function TraceDetail({ trace }: TraceDetailProps) { if (!trace) { return
Select a trace to view details
} const phaseNames = trace.trace.phases.map(p => p.phase).join(', ') return (
{trace.method} {trace.pathname}
{trace.route.stepTitle &&
{trace.route.stepTitle}
}
{trace.nodeId}
{trace.trace.error && (
{trace.trace.error.status !== undefined && ( {trace.trace.error.status} )} {trace.trace.error.message}
{trace.trace.error.stack && (
Stack trace
{trace.trace.error.stack}
)}
)}
Package
{trace.route.journeyTitle}
{trace.route.formattedDslPath && (
DSL Path
{trace.route.formattedDslPath}
)}
Route
{trace.route.routeTemplatePath}
{trace.trace.redirect && (
Redirect
{trace.trace.redirect.target}
)}
) }