The only tool you need to know what is happening and how to fix it.
Go alertingexception-trackerissue-trackinglogsmetricsmonitoringobservability-platformopen-telemetryotelsession-replaytelemetrytraces
progress
dduxd233f90e6ca7
diff --git a/frontend/src/lib/components/dashboard/metric-card.svelte b/frontend/src/lib/components/dashboard/metric-card.svelteindex b026556e..bac8db02 100644--- a/frontend/src/lib/components/dashboard/metric-card.svelte+++ b/frontend/src/lib/components/dashboard/metric-card.svelte@@ -1,7 +1,7 @@<script lang="ts">import * as Card from '$lib/components/ui/card';import * as Chart from "$lib/components/ui/chart/index.js";- import { LineChart, Points } from 'layerchart';+ import { LineChart, Points, Spline } from 'layerchart';import { scaleUtc } from 'd3-scale';import type { DashboardMetric, MetricTrendPoint, ServerMetricTrend } from '$lib/types/dashboard';import { min, max } from 'd3-array';@@ -206,6 +206,73 @@color: serverColorMap[server.serverName] || 'var(--chart-1)'}));});++ // Per-server gap detection for multi-server charts+ const perServerGapData = $derived(() => {+ if (!hasMultiServerData || !metric.servers) return new Map<string, {+ gapPoints: Set<number>;+ isolatedPoints: { timestamp: Date; value: number }[];+ }>();++ const result = new Map<string, {+ gapPoints: Set<number>;+ isolatedPoints: { timestamp: Date; value: number }[];+ }>();++ for (const server of metric.servers) {+ const trend = server.trend;+ if (trend.length < 2) {+ result.set(server.serverName, {+ gapPoints: new Set(),+ isolatedPoints: trend.map((t: MetricTrendPoint) => ({ timestamp: t.timestamp, value: t.value }))+ });+ continue;+ }++ // Calculate threshold for this server (2x median interval)+ const intervals: number[] = [];+ for (let i = 1; i < Math.min(trend.length, 10); i++) {+ intervals.push(trend[i].timestamp.getTime() - trend[i - 1].timestamp.getTime());+ }+ intervals.sort((a, b) => a - b);+ const threshold = intervals[Math.floor(intervals.length / 2)] * 2;++ // Calculate gap points (timestamps where line should break)+ const serverGapPoints = new Set<number>();+ for (let i = 1; i < trend.length; i++) {+ const gap = trend[i].timestamp.getTime() - trend[i - 1].timestamp.getTime();+ if (gap > threshold) {+ serverGapPoints.add(trend[i].timestamp.getTime());+ }+ }++ // Calculate isolated points (gaps both before AND after)+ const isolated: { timestamp: Date; value: number }[] = [];+ for (let i = 0; i < trend.length; i++) {+ const hasGapBefore = i === 0 ||+ (trend[i].timestamp.getTime() - trend[i - 1].timestamp.getTime() > threshold);+ const hasGapAfter = i === trend.length - 1 ||+ (trend[i + 1].timestamp.getTime() - trend[i].timestamp.getTime() > threshold);+ if (hasGapBefore && hasGapAfter) {+ isolated.push({ timestamp: trend[i].timestamp, value: trend[i].value });+ }+ }++ result.set(server.serverName, { gapPoints: serverGapPoints, isolatedPoints: isolated });+ }++ return result;+ });++ // Helper to get defined function for a specific server+ function getServerDefined(serverName: string) {+ return (d: any) => {+ const gapData = perServerGapData().get(serverName);+ if (!gapData) return true;+ const timestamp = d.timestamp instanceof Date ? d.timestamp.getTime() : d.timestamp;+ return !gapData.gapPoints.has(timestamp);+ };+ }</script><Card.Root class="gap-3 pb-0">@@ -241,13 +308,15 @@toTime={xDomainValue()?.[1] ?? new Date()}{onRangeSelect}data={metric.trend}+ servers={metric.servers}+ {serverColorMap}unit={metric.unit}formatValue={(v) => metric.formatValue ? metric.formatValue(v) : formatMetricValue(v, metric.unit)}><Chart.Container config={chartConfig()}>{#if hasData()}{#if hasMultiServerData}- <!-- Multi-server chart with separate lines per server -->+ <!-- Multi-server chart with per-server gap handling --><LineChartdata={multiServerChartData()}x="timestamp"@@ -256,6 +325,9 @@series={multiServerSeries()}yDomain={[Math.max(0, yMin() - padding), yMax() + padding]}seriesLayout="overlap"+ axis={true}+ rule={true}+ grid={{ x: false, y: true }}props={{xAxis: {format: () => ""@@ -265,7 +337,29 @@}}}tooltip={false}- />+ >+ {#snippet spline({ props, seriesIndex })}+ {@const serverName = multiServerSeries()[seriesIndex]?.key}+ <Spline {...props} defined={getServerDefined(serverName)} />+ {/snippet}++ {#snippet aboveMarks()}+ <!-- Per-server isolated points -->+ {#each metric.servers ?? [] as server}+ {@const gapData = perServerGapData().get(server.serverName)}+ {@const color = serverColorMap[server.serverName] || 'var(--chart-1)'}+ {#if gapData && gapData.isolatedPoints.length > 0}+ <Points+ data={gapData.isolatedPoints}+ x="timestamp"+ y="value"+ r={2}+ fill={color}+ />+ {/if}+ {/each}+ {/snippet}+ </LineChart>{:else}<!-- Single series chart (original behavior) --><LineChart@@ -282,6 +376,9 @@]}yDomain={[Math.max(0, yMin() - padding), yMax() + padding]}seriesLayout="stack"+ axis={true}+ rule={true}+ grid={{ x: false, y: true }}props={{xAxis: {format: () => "",diff --git a/frontend/src/lib/components/dashboard/metric-chart-overlay.svelte b/frontend/src/lib/components/dashboard/metric-chart-overlay.svelteindex 0ba30785..8faf4bc6 100644--- a/frontend/src/lib/components/dashboard/metric-chart-overlay.svelte+++ b/frontend/src/lib/components/dashboard/metric-chart-overlay.svelte@@ -8,6 +8,11 @@value: number;};+ type ServerData = {+ serverName: string;+ trend: DataPoint[];+ };+let {fromTime,toTime,@@ -15,6 +20,8 @@onRangeSelect,chartPadding = { left: 20, right: 4 },data = [],+ servers = [],+ serverColorMap = {},unit = '',formatValue,timezone@@ -25,11 +32,16 @@onRangeSelect?: (from: Date, to: Date) => void;chartPadding?: { left: number; right: number };data?: DataPoint[];+ servers?: ServerData[];+ serverColorMap?: Record<string, string>;unit?: string;formatValue?: (value: number) => string;timezone?: string;}>();+ // Check if we have multi-server data+ const hasMultiServerData = $derived(servers && servers.length > 1);+const tz = $derived(timezone ?? getTimezone());let containerRef = $state<HTMLDivElement | null>(null);@@ -148,13 +160,103 @@return getTimeAtPosition(mouseX);});- // Calculate the value at the current hover position+ // Calculate the value at the current hover position (for single-server)const calculatedValue = $derived(() => {const time = calculatedTime();if (!time) return null;return getValueAtTime(time);});+ // Get value at time for a specific server's data+ function getServerValueAtTime(serverData: DataPoint[], time: Date): { value: number; isInterpolated: boolean } | null {+ if (serverData.length === 0) return null;++ const targetMs = time.getTime();++ // Calculate threshold for this server+ let threshold = 3600000;+ if (serverData.length >= 2) {+ const intervals: number[] = [];+ for (let i = 1; i < Math.min(serverData.length, 10); i++) {+ intervals.push(serverData[i].timestamp.getTime() - serverData[i - 1].timestamp.getTime());+ }+ intervals.sort((a, b) => a - b);+ threshold = intervals[Math.floor(intervals.length / 2)] * 2;+ }++ // Find the bracketing points+ let leftIdx = -1;+ let rightIdx = -1;++ for (let i = 0; i < serverData.length; i++) {+ const pointMs = serverData[i].timestamp.getTime();+ if (pointMs <= targetMs) {+ leftIdx = i;+ }+ if (pointMs >= targetMs && rightIdx === -1) {+ rightIdx = i;+ }+ }++ // If exact match+ if (leftIdx >= 0 && serverData[leftIdx].timestamp.getTime() === targetMs) {+ return { value: serverData[leftIdx].value, isInterpolated: false };+ }++ // If we have both bracketing points+ if (leftIdx >= 0 && rightIdx >= 0 && leftIdx !== rightIdx) {+ const leftPoint = serverData[leftIdx];+ const rightPoint = serverData[rightIdx];+ const gap = rightPoint.timestamp.getTime() - leftPoint.timestamp.getTime();++ if (gap <= threshold) {+ const t = (targetMs - leftPoint.timestamp.getTime()) / gap;+ const interpolatedValue = leftPoint.value + t * (rightPoint.value - leftPoint.value);+ return { value: interpolatedValue, isInterpolated: true };+ }+ }++ // Check if we're close to a single point+ if (leftIdx >= 0) {+ const leftPoint = serverData[leftIdx];+ const distToLeft = targetMs - leftPoint.timestamp.getTime();+ if (distToLeft <= threshold / 2) {+ return { value: leftPoint.value, isInterpolated: false };+ }+ }++ if (rightIdx >= 0) {+ const rightPoint = serverData[rightIdx];+ const distToRight = rightPoint.timestamp.getTime() - targetMs;+ if (distToRight <= threshold / 2) {+ return { value: rightPoint.value, isInterpolated: false };+ }+ }++ return null;+ }++ // Calculate values for all servers at the current hover position+ const calculatedServerValues = $derived(() => {+ const time = calculatedTime();+ if (!time || !hasMultiServerData) return [];++ const results: { serverName: string; value: number; color: string }[] = [];++ for (const server of servers) {+ const valueData = getServerValueAtTime(server.trend, time);+ if (valueData) {+ results.push({+ serverName: server.serverName,+ value: valueData.value,+ color: serverColorMap[server.serverName] || '#888888'+ });+ }+ }++ return results;+ });+// Format value for displayfunction formatDisplayValue(value: number): string {if (formatValue) {@@ -277,7 +379,28 @@></div><!-- Value tooltip at top -->- {#if valueData}+ {#if hasMultiServerData && calculatedServerValues().length > 0}+ <!-- Multi-server tooltip -->+ <div+ class="absolute top-0 -translate-x-1/2 -translate-y-full pointer-events-none"+ style="left: {clampedX}px;"+ >+ <div+ class="bg-foreground text-background rounded px-2 py-1 text-xs font-medium whitespace-nowrap shadow-lg mb-1 flex flex-col gap-0.5"+ >+ {#each calculatedServerValues() as serverValue}+ <div class="flex items-center gap-1.5">+ <span+ class="h-2 w-2 rounded-full flex-shrink-0"+ style="background-color: {serverValue.color};"+ ></span>+ <span>{formatDisplayValue(serverValue.value)}{#if unit}<span class="text-background/70 ml-0.5">{unit}</span>{/if}</span>+ </div>+ {/each}+ </div>+ </div>+ {:else if valueData}+ <!-- Single-server tooltip --><divclass="absolute top-0 -translate-x-1/2 -translate-y-full pointer-events-none"style="left: {clampedX}px;"