Skip to content

The only tool you need to know what is happening and how to fix it.

update

ddux91219cf66e26
diff --git a/backend/app/controllers/transaction_detail.controller.go b/backend/app/controllers/transaction_detail.controller.go
index b7ac3fc6..3320b1ae 100644
--- a/backend/app/controllers/transaction_detail.controller.go
+++ b/backend/app/controllers/transaction_detail.controller.go
@@ -14,10 +14,17 @@ type TransactionDetailRequest struct {
ProjectId string `json:"projectId"`
}
+type ExceptionInfo struct {
+ ExceptionHash string `json:"exceptionHash"`
+ StackTrace string `json:"stackTrace"`
+ RecordedAt string `json:"recordedAt"`
+}
+
type TransactionDetailResponse struct {
Transaction *models.Transaction `json:"transaction"`
Segments []models.Segment `json:"segments"`
HasSegments bool `json:"hasSegments"`
+ Exception *ExceptionInfo `json:"exception,omitempty"`
}
func (c transactionDetailController) GetTransactionDetail(ctx *gin.Context) {
@@ -46,10 +53,25 @@ func (c transactionDetailController) GetTransactionDetail(ctx *gin.Context) {
panic(err)
}
+ // Get linked exception if any
+ var exceptionInfo *ExceptionInfo
+ exception, err := repositories.ExceptionStackTraceRepository.FindByTransactionId(ctx, request.ProjectId, transactionId)
+ if err != nil {
+ panic(err)
+ }
+ if exception != nil {
+ exceptionInfo = &ExceptionInfo{
+ ExceptionHash: exception.ExceptionHash,
+ StackTrace: exception.StackTrace,
+ RecordedAt: exception.RecordedAt.Format("2006-01-02T15:04:05Z07:00"),
+ }
+ }
+
ctx.JSON(http.StatusOK, TransactionDetailResponse{
Transaction: transaction,
Segments: segments,
HasSegments: len(segments) > 0,
+ Exception: exceptionInfo,
})
}
diff --git a/backend/app/repositories/exception_stack_trace.repository.go b/backend/app/repositories/exception_stack_trace.repository.go
index 7fd77443..858da060 100644
--- a/backend/app/repositories/exception_stack_trace.repository.go
+++ b/backend/app/repositories/exception_stack_trace.repository.go
@@ -299,4 +299,35 @@ func (e *exceptionStackTraceRepository) IsArchived(ctx context.Context, projectI
return count > 0, nil
}
+// FindByTransactionId returns the exception associated with a specific transaction
+func (e *exceptionStackTraceRepository) FindByTransactionId(ctx context.Context, projectId string, transactionId string) (*models.ExceptionStackTrace, error) {
+ var est models.ExceptionStackTrace
+ var scopeJSON string
+ var isMessage uint8
+
+ err := (*chdb.Conn).QueryRow(ctx,
+ `SELECT project_id, transaction_id, exception_hash, stack_trace, recorded_at, scope, app_version, server_name, is_message
+ FROM exception_stack_traces
+ WHERE project_id = ? AND transaction_id = ?
+ LIMIT 1`,
+ projectId, transactionId).Scan(
+ &est.ProjectId, &est.TransactionId, &est.ExceptionHash, &est.StackTrace,
+ &est.RecordedAt, &scopeJSON, &est.AppVersion, &est.ServerName, &isMessage)
+
+ if err != nil {
+ // No exception found for this transaction
+ return nil, nil
+ }
+
+ est.IsMessage = isMessage == 1
+ // Parse scope JSON
+ if scopeJSON != "" && scopeJSON != "{}" {
+ if err := json.Unmarshal([]byte(scopeJSON), &est.Scope); err != nil {
+ est.Scope = nil
+ }
+ }
+
+ return &est, nil
+}
+
var ExceptionStackTraceRepository = exceptionStackTraceRepository{}
diff --git a/frontend/src/lib/components/issues/event-card.svelte b/frontend/src/lib/components/issues/event-card.svelte
new file mode 100644
index 00000000..6a20c3bd
--- /dev/null
+++ b/frontend/src/lib/components/issues/event-card.svelte
@@ -0,0 +1,113 @@
+<script lang="ts">
+ import { goto } from '$app/navigation';
+ import { Button } from "$lib/components/ui/button";
+ import * as Card from "$lib/components/ui/card";
+ import { ArrowRight } from "lucide-svelte";
+ import type { ExceptionOccurrence, LinkedTransaction } from '$lib/types/exceptions';
+
+ interface Props {
+ occurrence: ExceptionOccurrence;
+ linkedTransaction: LinkedTransaction | null;
+ title?: string;
+ description?: string;
+ }
+
+ let {
+ occurrence,
+ linkedTransaction,
+ title = "Event",
+ description = "Details for this specific occurrence"
+ }: Props = $props();
+
+ function formatDuration(nanoseconds: number): string {
+ const ms = nanoseconds / 1_000_000;
+ if (ms < 1) {
+ return `${(nanoseconds / 1000).toFixed(0)}us`;
+ } else if (ms < 1000) {
+ return `${ms.toFixed(0)}ms`;
+ } else {
+ return `${(ms / 1000).toFixed(1)}s`;
+ }
+ }
+
+ function getStatusColor(statusCode: number): string {
+ if (statusCode >= 200 && statusCode < 300) return 'text-green-500';
+ if (statusCode >= 300 && statusCode < 400) return 'text-blue-500';
+ if (statusCode >= 400 && statusCode < 500) return 'text-yellow-500';
+ return 'text-red-500';
+ }
+</script>
+
+<Card.Root>
+ <Card.Header>
+ <Card.Title>{title}</Card.Title>
+ <Card.Description>{description}</Card.Description>
+ </Card.Header>
+ <Card.Content class="space-y-6">
+ <!-- Event Details -->
+ <div class="grid grid-cols-2 gap-4 md:grid-cols-4">
+ <div class="space-y-1">
+ <p class="text-sm text-muted-foreground">Recorded At</p>
+ <p class="font-mono text-sm">{new Date(occurrence.recordedAt).toLocaleString()}</p>
+ </div>
+ <div class="space-y-1">
+ <p class="text-sm text-muted-foreground">Server</p>
+ <p class="font-mono text-sm">{occurrence.serverName || '-'}</p>
+ </div>
+ <div class="space-y-1">
+ <p class="text-sm text-muted-foreground">Version</p>
+ <p class="font-mono text-sm">{occurrence.appVersion || '-'}</p>
+ </div>
+ <div class="space-y-1">
+ <p class="text-sm text-muted-foreground">Transaction</p>
+ <p class="font-mono text-sm">{occurrence.transactionId || '-'}</p>
+ </div>
+ </div>
+
+ <!-- Context -->
+ {#if occurrence.scope && Object.keys(occurrence.scope).length > 0}
+ <hr class="border-border" />
+ <div>
+ <p class="text-sm font-medium mb-3">Context</p>
+ <div class="grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 gap-3">
+ {#each Object.entries(occurrence.scope).sort((a, b) => a[0].localeCompare(b[0])) as [key, value]}
+ <div class="flex flex-col gap-1 p-3 rounded-md bg-muted">
+ <span class="text-xs font-medium text-muted-foreground">{key}</span>
+ <span class="text-sm font-mono break-all">{value}</span>
+ </div>
+ {/each}
+ </div>
+ </div>
+ {/if}
+
+ <!-- Related Transaction -->
+ {#if linkedTransaction}
+ <hr class="border-border" />
+ <div>
+ <p class="text-sm font-medium mb-3">Related Transaction</p>
+ <div class="grid grid-cols-2 gap-4 md:grid-cols-4 mb-4">
+ <div class="space-y-1">
+ <p class="text-sm text-muted-foreground">Endpoint</p>
+ <p class="font-mono text-sm truncate" title={linkedTransaction.endpoint}>{linkedTransaction.endpoint}</p>
+ </div>
+ <div class="space-y-1">
+ <p class="text-sm text-muted-foreground">Status</p>
+ <p class="font-mono {getStatusColor(linkedTransaction.statusCode)}">{linkedTransaction.statusCode}</p>
+ </div>
+ <div class="space-y-1">
+ <p class="text-sm text-muted-foreground">Duration</p>
+ <p class="font-mono">{formatDuration(linkedTransaction.duration)}</p>
+ </div>
+ <div class="space-y-1">
+ <p class="text-sm text-muted-foreground">Recorded</p>
+ <p class="font-mono text-sm">{new Date(linkedTransaction.recordedAt).toLocaleString()}</p>
+ </div>
+ </div>
+ <Button variant="outline" size="sm" onclick={() => goto(`/transactions/${encodeURIComponent(linkedTransaction.endpoint)}/${linkedTransaction.id}?preset=24h`)}>
+ View Transaction Details
+ <ArrowRight class="ml-2 h-4 w-4" />
+ </Button>
+ </div>
+ {/if}
+ </Card.Content>
+</Card.Root>
diff --git a/frontend/src/lib/components/issues/events-table.svelte b/frontend/src/lib/components/issues/events-table.svelte
new file mode 100644
index 00000000..956966c7
--- /dev/null
+++ b/frontend/src/lib/components/issues/events-table.svelte
@@ -0,0 +1,131 @@
+<script lang="ts">
+ import { createRowClickHandler } from '$lib/utils/navigation';
+ import * as Card from "$lib/components/ui/card";
+ import * as Table from "$lib/components/ui/table";
+ import * as Tooltip from "$lib/components/ui/tooltip";
+ import { ArrowRight, CircleHelp } from "lucide-svelte";
+ import type { ExceptionOccurrence } from '$lib/types/exceptions';
+
+ interface Props {
+ occurrences: ExceptionOccurrence[];
+ exceptionHash: string;
+ total: number;
+ hasMore?: boolean;
+ showViewAll?: boolean;
+ currentRecordedAt?: string;
+ }
+
+ let {
+ occurrences,
+ exceptionHash,
+ total,
+ hasMore = false,
+ showViewAll = true,
+ currentRecordedAt
+ }: Props = $props();
+
+ function getRowUrl(occurrence: ExceptionOccurrence): string {
+ return `/issues/${exceptionHash}/${encodeURIComponent(occurrence.recordedAt)}`;
+ }
+
+ function isCurrentEvent(occurrence: ExceptionOccurrence): boolean {
+ return currentRecordedAt !== undefined && occurrence.recordedAt === currentRecordedAt;
+ }
+</script>
+
+<Card.Root>
+ <Card.Header>
+ <Card.Title>Events</Card.Title>
+ <Card.Description>All occurrences of this exception ({total} total)</Card.Description>
+ </Card.Header>
+ <Card.Content>
+ <div class="rounded-md border overflow-hidden">
+ <Table.Root>
+ {#if occurrences.length > 0}
+ <Table.Header>
+ <Table.Row>
+ <Table.Head>
+ <span class="flex items-center gap-1.5">
+ Recorded At
+ <Tooltip.Root>
+ <Tooltip.Trigger>
+ <CircleHelp class="h-3.5 w-3.5 text-muted-foreground/60" />
+ </Tooltip.Trigger>
+ <Tooltip.Content>
+ <p class="text-xs">When this occurrence was recorded</p>
+ </Tooltip.Content>
+ </Tooltip.Root>
+ </span>
+ </Table.Head>
+ <Table.Head>
+ <span class="flex items-center gap-1.5">
+ Server
+ <Tooltip.Root>
+ <Tooltip.Trigger>
+ <CircleHelp class="h-3.5 w-3.5 text-muted-foreground/60" />
+ </Tooltip.Trigger>
+ <Tooltip.Content>
+ <p class="text-xs">Server instance where error occurred</p>
+ </Tooltip.Content>
+ </Tooltip.Root>
+ </span>
+ </Table.Head>
+ <Table.Head>
+ <span class="flex items-center gap-1.5">
+ Transaction
+ <Tooltip.Root>
+ <Tooltip.Trigger>
+ <CircleHelp class="h-3.5 w-3.5 text-muted-foreground/60" />
+ </Tooltip.Trigger>
+ <Tooltip.Content>
+ <p class="text-xs">Transaction ID if this occurred during a request</p>
+ </Tooltip.Content>
+ </Tooltip.Root>
+ </span>
+ </Table.Head>
+ </Table.Row>
+ </Table.Header>
+ {/if}
+ <Table.Body>
+ {#if occurrences.length === 0}
+ <Table.Row>
+ <Table.Cell colspan={3} class="h-24 text-center">
+ No occurrences found.
+ </Table.Cell>
+ </Table.Row>
+ {:else}
+ {#each occurrences as occurrence}
+ <Table.Row
+ class="cursor-pointer hover:bg-muted/50 {isCurrentEvent(occurrence) ? 'bg-muted' : ''}"
+ onclick={createRowClickHandler(getRowUrl(occurrence))}
+ >
+ <Table.Cell>
+ {new Date(occurrence.recordedAt).toLocaleString()}
+ {#if isCurrentEvent(occurrence)}
+ <span class="ml-2 text-xs text-muted-foreground">(current)</span>
+ {/if}
+ </Table.Cell>
+ <Table.Cell class="font-mono text-sm text-muted-foreground">
+ {occurrence.serverName || '-'}
+ </Table.Cell>
+ <Table.Cell class="font-mono text-sm">
+ {occurrence.transactionId || '-'}
+ </Table.Cell>
+ </Table.Row>
+ {/each}
+ {#if hasMore && showViewAll}
+ <Table.Row
+ class="cursor-pointer bg-muted/50 hover:bg-muted"
+ onclick={createRowClickHandler(`/issues/${exceptionHash}/events`)}
+ >
+ <Table.Cell colspan={3} class="py-2 text-center text-sm text-muted-foreground">
+ View all {total} events <ArrowRight class="inline h-3.5 w-3.5" />
+ </Table.Cell>
+ </Table.Row>
+ {/if}
+ {/if}
+ </Table.Body>
+ </Table.Root>
+ </div>
+ </Card.Content>
+</Card.Root>
diff --git a/frontend/src/lib/components/issues/index.ts b/frontend/src/lib/components/issues/index.ts
new file mode 100644
index 00000000..b764a56d
--- /dev/null
+++ b/frontend/src/lib/components/issues/index.ts
@@ -0,0 +1,4 @@
+export { default as StackTraceCard } from './stack-trace-card.svelte';
+export { default as EventCard } from './event-card.svelte';
+export { default as EventsTable } from './events-table.svelte';
+export { default as PageHeader } from './page-header.svelte';
diff --git a/frontend/src/lib/components/issues/page-header.svelte b/frontend/src/lib/components/issues/page-header.svelte
new file mode 100644
index 00000000..dcb3cad1
--- /dev/null
+++ b/frontend/src/lib/components/issues/page-header.svelte
@@ -0,0 +1,25 @@
+<script lang="ts">
+ import { goto } from '$app/navigation';
+ import { Button } from "$lib/components/ui/button";
+ import { ArrowLeft } from "lucide-svelte";
+
+ interface Props {
+ title: string;
+ subtitle: string;
+ backHref: string;
+ }
+
+ let { title, subtitle, backHref }: Props = $props();
+</script>
+
+<div class="flex items-center gap-4">
+ <Button variant="ghost" size="sm" onclick={() => goto(backHref)} class="h-8 w-8 p-0">
+ <ArrowLeft class="h-4 w-4" />
+ </Button>
+ <div>
+ <h2 class="font-mono text-2xl font-bold tracking-tight">
+ {title}
+ </h2>
+ <p class="text-muted-foreground text-sm">{subtitle}</p>
+ </div>
+</div>
diff --git a/frontend/src/lib/components/issues/stack-trace-card.svelte b/frontend/src/lib/components/issues/stack-trace-card.svelte
new file mode 100644
index 00000000..ad9092f0
--- /dev/null
+++ b/frontend/src/lib/components/issues/stack-trace-card.svelte
@@ -0,0 +1,40 @@
+<script lang="ts">
+ import * as Card from "$lib/components/ui/card";
+
+ interface Props {
+ stackTrace: string;
+ isMessage?: boolean;
+ firstSeen?: string;
+ lastSeen?: string;
+ totalCount?: number;
+ }
+
+ let { stackTrace, isMessage = false, firstSeen, lastSeen, totalCount }: Props = $props();
+
+ const showStats = $derived(firstSeen && lastSeen && totalCount !== undefined);
+</script>
+
+<Card.Root>
+ <Card.Header>
+ <div class="flex items-center gap-2">
+ <Card.Title>Stack Trace</Card.Title>
+ {#if isMessage}
+ <span class="inline-flex items-center rounded-md bg-blue-50 dark:bg-blue-900/30 px-2 py-1 text-xs font-medium text-blue-700 dark:text-blue-300 ring-1 ring-inset ring-blue-700/10 dark:ring-blue-400/30">
+ Message
+ </span>
+ {/if}
+ </div>
+ {#if showStats}
+ <Card.Description>
+ First seen: {new Date(firstSeen!).toLocaleString()} ·
+ Last seen: {new Date(lastSeen!).toLocaleString()} ·
+ Total occurrences: {totalCount}
+ </Card.Description>
+ {/if}
+ </Card.Header>
+ <Card.Content>
+ <div class="rounded-md bg-muted p-4 overflow-x-auto">
+ <pre class="text-sm whitespace-pre-wrap font-mono">{stackTrace}</pre>
+ </div>
+ </Card.Content>
+</Card.Root>
diff --git a/frontend/src/lib/types/exceptions.ts b/frontend/src/lib/types/exceptions.ts
new file mode 100644
index 00000000..794ef080
--- /dev/null
+++ b/frontend/src/lib/types/exceptions.ts
@@ -0,0 +1,27 @@
+export type ExceptionGroup = {
+ exceptionHash: string;
+ stackTrace: string;
+ lastSeen: string;
+ firstSeen: string;
+ count: number;
+};
+
+export type ExceptionOccurrence = {
+ transactionId: string | null;
+ exceptionHash: string;
+ stackTrace: string;
+ recordedAt: string;
+ scope: Record<string, string> | null;
+ appVersion: string;
+ serverName: string;
+ isMessage: boolean;
+ endpoint: string;
+};
+
+export type LinkedTransaction = {
+ id: string;
+ endpoint: string;
+ duration: number;
+ statusCode: number;
+ recordedAt: string;
+};
diff --git a/frontend/src/lib/types/segments.ts b/frontend/src/lib/types/segments.ts
index 9528d2ba..9e92b5a1 100644
--- a/frontend/src/lib/types/segments.ts
+++ b/frontend/src/lib/types/segments.ts
@@ -22,8 +22,15 @@ export type TransactionDetail = {
serverName: string;
};
+export type ExceptionInfo = {
+ exceptionHash: string;
+ stackTrace: string;
+ recordedAt: string;
+};
+
export type TransactionDetailResponse = {
transaction: TransactionDetail;
segments: Segment[];
hasSegments: boolean;
+ exception?: ExceptionInfo;
};
diff --git a/frontend/src/routes/+error.svelte b/frontend/src/routes/+error.svelte
new file mode 100644
index 00000000..1b6c4534
--- /dev/null
+++ b/frontend/src/routes/+error.svelte
@@ -0,0 +1,17 @@
+<script lang="ts">
+ import { page } from '$app/state';
+ import { ErrorDisplay } from '$lib/components/ui/error-display';
+
+ const status = $derived(page.status);
+ const errorMessage = $derived(page.error?.message);
+</script>
+
+<ErrorDisplay
+ {status}
+ title={status === 404 ? 'Page Not Found' : 'Something Went Wrong'}
+ description={errorMessage || (status === 404
+ ? "The page you're looking for doesn't exist or may have been moved."
+ : 'An unexpected error occurred. Please try again.')}
+ backHref="/"
+ backLabel="Go to Dashboard"
+/>
diff --git a/frontend/src/routes/+page.svelte b/frontend/src/routes/+page.svelte
index ff496917..6c00e172 100644
--- a/frontend/src/routes/+page.svelte
+++ b/frontend/src/routes/+page.svelte
@@ -213,7 +213,7 @@
{@const impactLevel = getImpactLevel(endpoint.count, endpoint.p50Duration, endpoint.p95Duration)}
<Table.Row
class="cursor-pointer hover:bg-muted/50"
- onclick={createRowClickHandler(`/transactions/${encodeURIComponent(endpoint.endpoint)}`)}
+ onclick={createRowClickHandler(`/transactions/${encodeURIComponent(endpoint.endpoint)}?preset=24h`)}
>
<Table.Cell class="py-3 font-mono text-sm truncate max-w-[300px]" title={endpoint.endpoint}>
{endpoint.endpoint}
diff --git a/frontend/src/routes/issues/[exceptionHash]/+page.svelte b/frontend/src/routes/issues/[exceptionHash]/+page.svelte
index 47b63a7a..e10da26b 100644
--- a/frontend/src/routes/issues/[exceptionHash]/+page.svelte
+++ b/frontend/src/routes/issues/[exceptionHash]/+page.svelte
@@ -1,37 +1,12 @@
<script lang="ts">
import { onMount } from 'svelte';
import { page } from '$app/state';
- import { goto } from '$app/navigation';
- import { createRowClickHandler } from '$lib/utils/navigation';
import { api } from '$lib/api';
- import { Button } from "$lib/components/ui/button";
- import * as Card from "$lib/components/ui/card";
- import * as Table from "$lib/components/ui/table";
import { Skeleton } from "$lib/components/ui/skeleton";
import { ErrorDisplay } from "$lib/components/ui/error-display";
import { projectsState } from '$lib/state/projects.svelte';
- import { ArrowRight, CircleHelp } from "lucide-svelte";
- import * as Tooltip from "$lib/components/ui/tooltip";
-
- type ExceptionGroup = {
- exceptionHash: string;
- stackTrace: string;
- lastSeen: string;
- firstSeen: string;
- count: number;
- };
-
- type ExceptionOccurrence = {
- transactionId: string | null;
- exceptionHash: string;
- stackTrace: string;
- recordedAt: string;
- scope: Record<string, string> | null;
- appVersion: string;
- serverName: string;
- isMessage: boolean;
- endpoint: string;
- };
+ import { StackTraceCard, EventCard, EventsTable, PageHeader } from '$lib/components/issues';
+ import type { ExceptionGroup, ExceptionOccurrence, LinkedTransaction } from '$lib/types/exceptions';
let group = $state<ExceptionGroup | null>(null);
let occurrences = $state<ExceptionOccurrence[]>([]);
@@ -39,18 +14,19 @@
let error = $state('');
let notFound = $state(false);
let total = $state(0);
+ let linkedTransaction = $state<LinkedTransaction | null>(null);
- // Get scope from the most recent occurrence for display
- const latestScope = $derived(occurrences[0]?.scope);
- const latestAppVersion = $derived(occurrences[0]?.appVersion);
- const latestServerName = $derived(occurrences[0]?.serverName);
- const isMessage = $derived(occurrences[0]?.isMessage ?? false);
+ const exceptionHash = $derived(page.params.exceptionHash ?? '');
+ const latestOccurrence = $derived(occurrences[0]);
+ const isMessage = $derived(latestOccurrence?.isMessage ?? false);
const hasMoreOccurrences = $derived(total > 10);
+ const firstLineOfStackTrace = $derived(group?.stackTrace.split('\n')[0] || 'Exception');
async function loadData() {
loading = true;
error = '';
notFound = false;
+ linkedTransaction = null;
try {
const exceptionHash = page.params.exceptionHash;
@@ -64,6 +40,29 @@
group = response.group;
occurrences = response.occurrences || [];
total = response.pagination.total;
+
+ // Load linked transaction if the latest occurrence has a transactionId
+ const firstOccurrence = occurrences[0];
+ if (firstOccurrence?.transactionId) {
+ try {
+ const txResponse = await api.post(
+ `/transactions/${firstOccurrence.transactionId}`,
+ {},
+ { projectId: projectsState.currentProjectId ?? undefined }
+ );
+ if (txResponse.transaction) {
+ linkedTransaction = {
+ id: txResponse.transaction.id,
+ endpoint: txResponse.transaction.endpoint,
+ duration: txResponse.transaction.duration,
+ statusCode: txResponse.transaction.statusCode,
+ recordedAt: txResponse.transaction.recordedAt
+ };
+ }
+ } catch (txError) {
+ console.warn('Could not load linked transaction:', txError);
+ }
+ }
} catch (e: any) {
console.error(e);
if (e.status === 404) {
@@ -76,48 +75,24 @@
}
}
- function formatRelativeTime(dateStr: string): string {
- const date = new Date(dateStr);
- const now = new Date();
- const diffMs = now.getTime() - date.getTime();
- const diffMins = Math.floor(diffMs / 60000);
- const diffHours = Math.floor(diffMs / 3600000);
- const diffDays = Math.floor(diffMs / 86400000);
-
- if (diffMins < 1) return 'just now';
- if (diffMins < 60) return `${diffMins}m ago`;
- if (diffHours < 24) return `${diffHours}h ago`;
- return `${diffDays}d ago`;
- }
-
onMount(() => {
loadData();
});
</script>
<div class="space-y-6">
- <!-- Header -->
- <div class="flex items-center gap-4">
- <Button variant="outline" size="sm" onclick={() => goto('/issues')}>
- <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="mr-2">
- <path d="m12 19-7-7 7-7"/><path d="M19 12H5"/>
- </svg>
- Back to Issues
- </Button>
- </div>
+ <PageHeader
+ title={firstLineOfStackTrace}
+ subtitle="Exception Hash: {exceptionHash}"
+ backHref="/issues"
+ />
{#if loading && !group}
- <!-- Loading skeleton -->
- <Card.Root>
- <Card.Header>
- <Skeleton class="h-6 w-48" />
- </Card.Header>
- <Card.Content>
- <Skeleton class="h-4 w-full mb-2" />
- <Skeleton class="h-4 w-3/4 mb-2" />
- <Skeleton class="h-4 w-1/2" />
- </Card.Content>
- </Card.Root>
+ <div class="space-y-4">
+ <Skeleton class="h-48 w-full" />
+ <Skeleton class="h-64 w-full" />
+ <Skeleton class="h-48 w-full" />
+ </div>
{:else if notFound}
<ErrorDisplay
status={404}
@@ -126,7 +101,7 @@
backHref="/issues"
backLabel="Back to Issues"
onRetry={() => loadData()}
- identifier={page.params.exceptionHash}
+ identifier={exceptionHash}
/>
{:else if error}
<ErrorDisplay
@@ -138,163 +113,29 @@
onRetry={() => loadData()}
/>
{:else if group}
- <!-- Summary Card -->
- <Card.Root>
- <Card.Header>
- <div class="flex items-center gap-2">
- <Card.Title>Exception Details</Card.Title>
- {#if isMessage}
- <span class="inline-flex items-center rounded-md bg-blue-50 dark:bg-blue-900/30 px-2 py-1 text-xs font-medium text-blue-700 dark:text-blue-300 ring-1 ring-inset ring-blue-700/10 dark:ring-blue-400/30">
- Message
- </span>
- {/if}
- </div>
- <Card.Description>
- First seen: {new Date(group.firstSeen).toLocaleString()} ·
- Last seen: {new Date(group.lastSeen).toLocaleString()} ·
- Occurrences: {group.count}
- {#if latestAppVersion}
- · Version: {latestAppVersion}
- {/if}
- {#if latestServerName}
- · Server: {latestServerName}
- {/if}
- </Card.Description>
- </Card.Header>
- <Card.Content>
- <div class="rounded-md bg-muted p-4 overflow-x-auto">
- <pre class="text-sm whitespace-pre-wrap font-mono">{group.stackTrace}</pre>
- </div>
- </Card.Content>
- </Card.Root>
+ <StackTraceCard
+ stackTrace={group.stackTrace}
+ {isMessage}
+ firstSeen={group.firstSeen}
+ lastSeen={group.lastSeen}
+ totalCount={group.count}
+ />
- <!-- Context Card -->
- {#if latestScope && Object.keys(latestScope).length > 0}
- <Card.Root>
- <Card.Header>
- <Card.Title>Context</Card.Title>
- <Card.Description>Additional context captured with this exception (from most recent occurrence)</Card.Description>
- </Card.Header>
- <Card.Content>
- <div class="grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 gap-3">
- {#each Object.entries(latestScope).sort((a, b) => a[0].localeCompare(b[0])) as [key, value]}
- <div class="flex flex-col gap-1 p-3 rounded-md bg-muted">
- <span class="text-xs font-medium text-muted-foreground">{key}</span>
- <span class="text-sm font-mono break-all">{value}</span>
- </div>
- {/each}
- </div>
- </Card.Content>
- </Card.Root>
+ {#if latestOccurrence}
+ <EventCard
+ occurrence={latestOccurrence}
+ {linkedTransaction}
+ title="Last Event"
+ description="Details from the most recent occurrence of this exception"
+ />
{/if}
- <!-- Occurrences Table -->
- <Card.Root>
- <Card.Header>
- <Card.Title>Occurrences</Card.Title>
- <Card.Description>When this exception happened ({total} total)</Card.Description>
- </Card.Header>
- <Card.Content>
- <div class="rounded-md border overflow-hidden">
- <Table.Root>
- {#if occurrences.length > 0}
- <Table.Header>
- <Table.Row>
- <Table.Head>
- <span class="flex items-center gap-1.5">
- Recorded At
- <Tooltip.Root>
- <Tooltip.Trigger>
- <CircleHelp class="h-3.5 w-3.5 text-muted-foreground/60" />
- </Tooltip.Trigger>
- <Tooltip.Content>
- <p class="text-xs">When this occurrence was recorded</p>
- </Tooltip.Content>
- </Tooltip.Root>
- </span>
- </Table.Head>
- <Table.Head>
- <span class="flex items-center gap-1.5">
- Server
- <Tooltip.Root>
- <Tooltip.Trigger>
- <CircleHelp class="h-3.5 w-3.5 text-muted-foreground/60" />
- </Tooltip.Trigger>
- <Tooltip.Content>
- <p class="text-xs">Server instance where error occurred</p>
- </Tooltip.Content>
- </Tooltip.Root>
- </span>
- </Table.Head>
- <Table.Head>
- <span class="flex items-center gap-1.5">
- Version
- <Tooltip.Root>
- <Tooltip.Trigger>
- <CircleHelp class="h-3.5 w-3.5 text-muted-foreground/60" />
- </Tooltip.Trigger>
- <Tooltip.Content>
- <p class="text-xs">Application version when error occurred</p>
- </Tooltip.Content>
- </Tooltip.Root>
- </span>
- </Table.Head>
- <Table.Head>
- <span class="flex items-center gap-1.5">
- Endpoint
- <Tooltip.Root>
- <Tooltip.Trigger>
- <CircleHelp class="h-3.5 w-3.5 text-muted-foreground/60" />
- </Tooltip.Trigger>
- <Tooltip.Content>
- <p class="text-xs">The API route where this error occurred</p>
- </Tooltip.Content>
- </Tooltip.Root>
- </span>
- </Table.Head>
- </Table.Row>
- </Table.Header>
- {/if}
- <Table.Body>
- {#if occurrences.length === 0}
- <Table.Row>
- <Table.Cell colspan={4} class="h-24 text-center">
- No occurrences found.
- </Table.Cell>
- </Table.Row>
- {:else}
- {#each occurrences as occurrence}
- <Table.Row
- class={occurrence.endpoint ? "cursor-pointer hover:bg-muted/50" : ""}
- onclick={occurrence.endpoint ? createRowClickHandler(`/transactions/${encodeURIComponent(occurrence.endpoint)}`) : undefined}
- >
- <Table.Cell>{new Date(occurrence.recordedAt).toLocaleString()}</Table.Cell>
- <Table.Cell class="font-mono text-sm text-muted-foreground">
- {occurrence.serverName || '-'}
- </Table.Cell>
- <Table.Cell class="font-mono text-sm text-muted-foreground">
- {occurrence.appVersion || '-'}
- </Table.Cell>
- <Table.Cell class="font-mono text-sm">
- {occurrence.endpoint || '-'}
- </Table.Cell>
- </Table.Row>
- {/each}
- {#if hasMoreOccurrences}
- <Table.Row
- class="cursor-pointer bg-muted/50 hover:bg-muted"
- onclick={createRowClickHandler(`/issues/${page.params.exceptionHash}/events`)}
- >
- <Table.Cell colspan={4} class="py-2 text-center text-sm text-muted-foreground">
- View all {total} events <ArrowRight class="inline h-3.5 w-3.5" />
- </Table.Cell>
- </Table.Row>
- {/if}
- {/if}
- </Table.Body>
- </Table.Root>
- </div>
- </Card.Content>
- </Card.Root>
+ <EventsTable
+ {occurrences}
+ {exceptionHash}
+ {total}
+ hasMore={hasMoreOccurrences}
+ showViewAll={true}
+ />
{/if}
</div>
diff --git a/frontend/src/routes/issues/[exceptionHash]/[recordedAt]/+page.svelte b/frontend/src/routes/issues/[exceptionHash]/[recordedAt]/+page.svelte
new file mode 100644
index 00000000..016e4dbd
--- /dev/null
+++ b/frontend/src/routes/issues/[exceptionHash]/[recordedAt]/+page.svelte
@@ -0,0 +1,143 @@
+<script lang="ts">
+ import { onMount } from 'svelte';
+ import { api } from '$lib/api';
+ import { Skeleton } from "$lib/components/ui/skeleton";
+ import { ErrorDisplay } from "$lib/components/ui/error-display";
+ import { projectsState } from '$lib/state/projects.svelte';
+ import { StackTraceCard, EventCard, EventsTable, PageHeader } from '$lib/components/issues';
+ import type { ExceptionGroup, ExceptionOccurrence, LinkedTransaction } from '$lib/types/exceptions';
+
+ let { data } = $props();
+
+ let group = $state<ExceptionGroup | null>(null);
+ let occurrence = $state<ExceptionOccurrence | null>(null);
+ let allOccurrences = $state<ExceptionOccurrence[]>([]);
+ let loading = $state(true);
+ let error = $state('');
+ let notFound = $state(false);
+ let total = $state(0);
+ let linkedTransaction = $state<LinkedTransaction | null>(null);
+
+ const isMessage = $derived(occurrence?.isMessage ?? false);
+ const firstLineOfStackTrace = $derived(group?.stackTrace.split('\n')[0] || 'Exception');
+ const hasMoreOccurrences = $derived(total > 10);
+
+ async function loadData() {
+ loading = true;
+ error = '';
+ notFound = false;
+ linkedTransaction = null;
+
+ try {
+ // Load all occurrences for this hash
+ const response = await api.post(`/exception-stack-traces/${data.exceptionHash}`, {
+ pagination: {
+ page: 1,
+ pageSize: 10
+ }
+ }, { projectId: projectsState.currentProjectId ?? undefined });
+
+ group = response.group;
+ allOccurrences = response.occurrences || [];
+ total = response.pagination.total;
+
+ // Find the specific occurrence by recordedAt
+ occurrence = allOccurrences.find(o => o.recordedAt === data.recordedAt) || null;
+
+ if (!occurrence) {
+ notFound = true;
+ return;
+ }
+
+ // Load linked transaction if this occurrence has a transactionId
+ if (occurrence.transactionId) {
+ try {
+ const txResponse = await api.post(
+ `/transactions/${occurrence.transactionId}`,
+ {},
+ { projectId: projectsState.currentProjectId ?? undefined }
+ );
+ if (txResponse.transaction) {
+ linkedTransaction = {
+ id: txResponse.transaction.id,
+ endpoint: txResponse.transaction.endpoint,
+ duration: txResponse.transaction.duration,
+ statusCode: txResponse.transaction.statusCode,
+ recordedAt: txResponse.transaction.recordedAt
+ };
+ }
+ } catch (txError) {
+ console.warn('Could not load linked transaction:', txError);
+ }
+ }
+ } catch (e: any) {
+ console.error(e);
+ if (e.status === 404) {
+ notFound = true;
+ } else {
+ error = e.message || 'Failed to load exception details';
+ }
+ } finally {
+ loading = false;
+ }
+ }
+
+ onMount(() => {
+ loadData();
+ });
+</script>
+
+<div class="space-y-6">
+ <PageHeader
+ title={firstLineOfStackTrace}
+ subtitle="Event from {new Date(data.recordedAt).toLocaleString()}"
+ backHref="/issues/{data.exceptionHash}"
+ />
+
+ {#if loading && !group}
+ <div class="space-y-4">
+ <Skeleton class="h-48 w-full" />
+ <Skeleton class="h-64 w-full" />
+ <Skeleton class="h-48 w-full" />
+ </div>
+ {:else if notFound}
+ <ErrorDisplay
+ status={404}
+ title="Event Not Found"
+ description="The specific event you're looking for doesn't exist or may have been removed."
+ backHref="/issues/{data.exceptionHash}"
+ backLabel="Back to Exception"
+ onRetry={() => loadData()}
+ />
+ {:else if error}
+ <ErrorDisplay
+ status={400}
+ title="Something Went Wrong"
+ description={error}
+ backHref="/issues/{data.exceptionHash}"
+ backLabel="Back to Exception"
+ onRetry={() => loadData()}
+ />
+ {:else if group && occurrence}
+ <StackTraceCard
+ stackTrace={group.stackTrace}
+ {isMessage}
+ />
+
+ <EventCard
+ {occurrence}
+ {linkedTransaction}
+ title="Event"
+ description="Details for this specific occurrence"
+ />
+
+ <EventsTable
+ occurrences={allOccurrences}
+ exceptionHash={data.exceptionHash}
+ {total}
+ hasMore={hasMoreOccurrences}
+ showViewAll={true}
+ currentRecordedAt={data.recordedAt}
+ />
+ {/if}
+</div>
diff --git a/frontend/src/routes/issues/[exceptionHash]/[recordedAt]/+page.ts b/frontend/src/routes/issues/[exceptionHash]/[recordedAt]/+page.ts
new file mode 100644
index 00000000..441906a1
--- /dev/null
+++ b/frontend/src/routes/issues/[exceptionHash]/[recordedAt]/+page.ts
@@ -0,0 +1,8 @@
+export const prerender = false;
+
+export function load({ params }) {
+ return {
+ exceptionHash: params.exceptionHash,
+ recordedAt: decodeURIComponent(params.recordedAt)
+ };
+}
diff --git a/frontend/src/routes/issues/[exceptionHash]/events/+page.svelte b/frontend/src/routes/issues/[exceptionHash]/events/+page.svelte
index 7db2e6d8..31faab19 100644
--- a/frontend/src/routes/issues/[exceptionHash]/events/+page.svelte
+++ b/frontend/src/routes/issues/[exceptionHash]/events/+page.svelte
@@ -196,26 +196,13 @@
</Table.Head>
<Table.Head>
<span class="flex items-center gap-1.5">
- Version
+ Transaction
<Tooltip.Root>
<Tooltip.Trigger>
<CircleHelp class="h-3.5 w-3.5 text-muted-foreground/60" />
</Tooltip.Trigger>
<Tooltip.Content>
- <p class="text-xs">Application version when error occurred</p>
- </Tooltip.Content>
- </Tooltip.Root>
- </span>
- </Table.Head>
- <Table.Head>
- <span class="flex items-center gap-1.5">
- Endpoint
- <Tooltip.Root>
- <Tooltip.Trigger>
- <CircleHelp class="h-3.5 w-3.5 text-muted-foreground/60" />
- </Tooltip.Trigger>
- <Tooltip.Content>
- <p class="text-xs">The API route where this error occurred</p>
+ <p class="text-xs">Transaction ID if this occurred during a request</p>
</Tooltip.Content>
</Tooltip.Root>
</span>
@@ -229,31 +216,27 @@
<Table.Row>
<Table.Cell><Skeleton class="h-4 w-[150px]" /></Table.Cell>
<Table.Cell><Skeleton class="h-4 w-[100px]" /></Table.Cell>
- <Table.Cell><Skeleton class="h-4 w-[80px]" /></Table.Cell>
- <Table.Cell><Skeleton class="h-4 w-[200px]" /></Table.Cell>
+ <Table.Cell><Skeleton class="h-4 w-[280px]" /></Table.Cell>
</Table.Row>
{/each}
{:else if occurrences.length === 0}
<Table.Row>
- <Table.Cell colspan={4} class="h-24 text-center">
+ <Table.Cell colspan={3} class="h-24 text-center">
No events found.
</Table.Cell>
</Table.Row>
{:else}
{#each occurrences as occurrence}
<Table.Row
- class={occurrence.endpoint ? "cursor-pointer hover:bg-muted/50" : ""}
- onclick={occurrence.endpoint ? createRowClickHandler(`/transactions/${encodeURIComponent(occurrence.endpoint)}`) : undefined}
+ class="cursor-pointer hover:bg-muted/50"
+ onclick={createRowClickHandler(`/issues/${page.params.exceptionHash}/${encodeURIComponent(occurrence.recordedAt)}`)}
>
<Table.Cell>{new Date(occurrence.recordedAt).toLocaleString()}</Table.Cell>
<Table.Cell class="font-mono text-sm text-muted-foreground">
{occurrence.serverName || '-'}
</Table.Cell>
- <Table.Cell class="font-mono text-sm text-muted-foreground">
- {occurrence.appVersion || '-'}
- </Table.Cell>
<Table.Cell class="font-mono text-sm">
- {occurrence.endpoint || '-'}
+ {occurrence.transactionId || '-'}
</Table.Cell>
</Table.Row>
{/each}
diff --git a/frontend/src/routes/metrics/+page.svelte b/frontend/src/routes/metrics/+page.svelte
index 98153996..c55bfdf5 100644
--- a/frontend/src/routes/metrics/+page.svelte
+++ b/frontend/src/routes/metrics/+page.svelte
@@ -223,32 +223,35 @@
// Transform the API response to match the DashboardData type
// Convert timestamp strings to Date objects
- const metrics: DashboardMetric[] = response.metrics.map((m: any) => ({
- id: m.id,
- name: m.name,
- value: m.value,
- unit: m.unit,
- trend: m.trend.map((t: any) => ({
- timestamp: new Date(t.timestamp),
- value: t.value
- })),
- change24h: m.change24h,
- status: m.status,
- // Include per-server data if available
- servers: m.servers?.map((s: any): ServerMetricTrend => ({
- serverName: s.serverName,
- value: s.value,
- trend: s.trend.map((t: any): MetricTrendPoint => ({
+ // Handle case where metrics might be null/undefined (no data)
+ const metrics: DashboardMetric[] = (response.metrics && Array.isArray(response.metrics))
+ ? response.metrics.map((m: any) => ({
+ id: m.id,
+ name: m.name,
+ value: m.value,
+ unit: m.unit,
+ trend: (m.trend || []).map((t: any) => ({
timestamp: new Date(t.timestamp),
value: t.value
+ })),
+ change24h: m.change24h,
+ status: m.status,
+ // Include per-server data if available
+ servers: m.servers?.map((s: any): ServerMetricTrend => ({
+ serverName: s.serverName,
+ value: s.value,
+ trend: (s.trend || []).map((t: any): MetricTrendPoint => ({
+ timestamp: new Date(t.timestamp),
+ value: t.value
+ }))
}))
}))
- }));
+ : [];
dashboardData = {
metrics,
- lastUpdated: new Date(response.lastUpdated),
- availableServers: response.availableServers
+ lastUpdated: response.lastUpdated ? new Date(response.lastUpdated) : new Date(),
+ availableServers: response.availableServers || []
};
} catch (e: any) {
errorStatus = e.status || 0;
diff --git a/frontend/src/routes/transactions/[endpoint]/[transactionId]/+page.svelte b/frontend/src/routes/transactions/[endpoint]/[transactionId]/+page.svelte
index cbaddfb6..09a26c32 100644
--- a/frontend/src/routes/transactions/[endpoint]/[transactionId]/+page.svelte
+++ b/frontend/src/routes/transactions/[endpoint]/[transactionId]/+page.svelte
@@ -7,7 +7,7 @@
import { Skeleton } from '$lib/components/ui/skeleton';
import { ErrorDisplay } from '$lib/components/ui/error-display';
import { projectsState } from '$lib/state/projects.svelte';
- import { ArrowLeft } from 'lucide-svelte';
+ import { ArrowLeft, ArrowRight, TriangleAlert } from 'lucide-svelte';
import SegmentWaterfall from '$lib/components/segments/segment-waterfall.svelte';
import SegmentEmptyState from '$lib/components/segments/segment-empty-state.svelte';
import type { TransactionDetailResponse } from '$lib/types/segments';
@@ -180,6 +180,28 @@
</Card.Content>
</Card.Root>
+ <!-- Exception Card (if exception exists) -->
+ {#if response.exception}
+ <Card.Root class="border-red-500/30 bg-red-500/5">
+ <Card.Header>
+ <div class="flex items-center gap-2">
+ <TriangleAlert class="h-5 w-5 text-red-500" />
+ <Card.Title class="text-red-600 dark:text-red-400">Exception Occurred</Card.Title>
+ </div>
+ <Card.Description>This transaction resulted in an exception</Card.Description>
+ </Card.Header>
+ <Card.Content>
+ <div class="bg-muted rounded-md p-3 overflow-x-auto max-h-32 mb-4">
+ <pre class="text-sm font-mono whitespace-pre-wrap">{response.exception.stackTrace.split('\n').slice(0, 4).join('\n')}{response.exception.stackTrace.split('\n').length > 4 ? '\n...' : ''}</pre>
+ </div>
+ <Button variant="outline" size="sm" onclick={() => goto(`/issues/${response!.exception!.exceptionHash}`)}>
+ View Full Exception
+ <ArrowRight class="ml-2 h-4 w-4" />
+ </Button>
+ </Card.Content>
+ </Card.Root>
+ {/if}
+
<!-- Segments Section -->
<Card.Root>
<Card.Header>