Skip to content

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

Metric and ui fixes

ddux98340123ae7b
diff --git a/clients/go-client/metrics/mem/mem_darwin.go b/clients/go-client/metrics/mem/mem_darwin.go
index 137eb43a..c097dbd8 100644
--- a/clients/go-client/metrics/mem/mem_darwin.go
+++ b/clients/go-client/metrics/mem/mem_darwin.go
@@ -9,13 +9,9 @@ import (
"unsafe"
)
-func GetMemoryUsedPercent() (float64, error) {
- mem, err := getTotalVirtualMemory()
- if err != nil {
- return 0, err
- }
-
- return float64(mem) / 1024 / 1024, nil
+// GetTotalMemory returns total physical memory in bytes
+func GetTotalMemory() (uint64, error) {
+ return getTotalVirtualMemory()
}
func getTotalVirtualMemory() (uint64, error) {
diff --git a/clients/go-client/metrics/mem/mem_linux.go b/clients/go-client/metrics/mem/mem_linux.go
index 5a1dc4e6..d9361aec 100644
--- a/clients/go-client/metrics/mem/mem_linux.go
+++ b/clients/go-client/metrics/mem/mem_linux.go
@@ -9,30 +9,24 @@ import (
"strings"
)
-// TODO: TEST LINUX MEMORY READING
-
-// Linux: read /proc/meminfo
-func GetMemoryUsedPercent() (float64, error) {
+// GetTotalMemory returns total physical memory in bytes
+func GetTotalMemory() (uint64, error) {
file, err := os.Open("/proc/meminfo")
if err != nil {
return 0, err
}
defer file.Close()
- var total, available uint64
scanner := bufio.NewScanner(file)
for scanner.Scan() {
fields := strings.Fields(scanner.Text())
if len(fields) < 2 {
continue
}
- val, _ := strconv.ParseUint(fields[1], 10, 64)
- switch fields[0] {
- case "MemTotal:":
- total = val
- case "MemAvailable:":
- available = val
+ if fields[0] == "MemTotal:" {
+ val, _ := strconv.ParseUint(fields[1], 10, 64)
+ return val * 1024, nil // Convert from KB to bytes
}
}
- return float64(total-available) / float64(total) * 100, nil
+ return 0, nil
}
diff --git a/clients/go-client/metrics/mem/mem_windows.go b/clients/go-client/metrics/mem/mem_windows.go
index 592b8f37..8330078e 100644
--- a/clients/go-client/metrics/mem/mem_windows.go
+++ b/clients/go-client/metrics/mem/mem_windows.go
@@ -5,10 +5,8 @@ import (
"unsafe"
)
-// TODO: TEST WINDOWS MEMORY READING
-
-// Windows: call GlobalMemoryStatusEx
-func GetMemoryUsedPercent() (float64, error) {
+// GetTotalMemory returns total physical memory in bytes
+func GetTotalMemory() (uint64, error) {
kernel32 := syscall.NewLazyDLL("kernel32.dll")
proc := kernel32.NewProc("GlobalMemoryStatusEx")
@@ -25,5 +23,5 @@ func GetMemoryUsedPercent() (float64, error) {
if ret == 0 {
return 0, err
}
- return float64(mem.dwMemoryLoad), nil // Windows gives us the percentage directly
+ return mem.ullTotalPhys, nil
}
diff --git a/clients/go-client/traceway.go b/clients/go-client/traceway.go
index 27893a0b..1a8ccf39 100644
--- a/clients/go-client/traceway.go
+++ b/clients/go-client/traceway.go
@@ -357,18 +357,19 @@ func (s *CollectionFrameStore) safeProcessMetrics() {
}
}
- memPercent, err := mem.GetMemoryUsedPercent()
- if err == nil {
+ var m runtime.MemStats
+ runtime.ReadMemStats(&m)
+ CaptureMetric(MetricNameMemoryUsage, float64(m.Alloc)/1024/1024)
+
+ totalMem, err := mem.GetTotalMemory()
+ if err == nil && totalMem > 0 {
+ memPercent := (float64(m.Alloc) / float64(totalMem)) * 100
CaptureMetric(MetricNameMemoryUsagePcnt, memPercent)
} else {
if s.debug {
- log.Println("Traceway mem not read", err)
+ log.Println("Traceway total mem not read", err)
}
}
-
- var m runtime.MemStats
- runtime.ReadMemStats(&m)
- CaptureMetric(MetricNameMemoryUsage, float64(m.Alloc)/1024/1024)
CaptureMetric(MetricNameGoRoutines, float64(runtime.NumGoroutine()))
CaptureMetric(MetricNameHeapObjects, float64(m.HeapObjects))
CaptureMetric(MetricNameNumGC, float64(m.NumGC))
diff --git a/frontend/src/lib/components/ui/badge/badge.svelte b/frontend/src/lib/components/ui/badge/badge.svelte
new file mode 100644
index 00000000..e3164ba7
--- /dev/null
+++ b/frontend/src/lib/components/ui/badge/badge.svelte
@@ -0,0 +1,50 @@
+<script lang="ts" module>
+ import { type VariantProps, tv } from "tailwind-variants";
+
+ export const badgeVariants = tv({
+ base: "focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive inline-flex w-fit shrink-0 items-center justify-center gap-1 overflow-hidden rounded-full border px-2 py-0.5 text-xs font-medium whitespace-nowrap transition-[color,box-shadow] focus-visible:ring-[3px] [&>svg]:pointer-events-none [&>svg]:size-3",
+ variants: {
+ variant: {
+ default:
+ "bg-primary text-primary-foreground [a&]:hover:bg-primary/90 border-transparent",
+ secondary:
+ "bg-secondary text-secondary-foreground [a&]:hover:bg-secondary/90 border-transparent",
+ destructive:
+ "bg-destructive [a&]:hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/70 border-transparent text-white",
+ outline: "text-foreground [a&]:hover:bg-accent [a&]:hover:text-accent-foreground",
+ },
+ },
+ defaultVariants: {
+ variant: "default",
+ },
+ });
+
+ export type BadgeVariant = VariantProps<typeof badgeVariants>["variant"];
+</script>
+
+<script lang="ts">
+ import type { HTMLAnchorAttributes } from "svelte/elements";
+ import { cn, type WithElementRef } from "$lib/utils.js";
+
+ let {
+ ref = $bindable(null),
+ href,
+ class: className,
+ variant = "default",
+ children,
+ ...restProps
+ }: WithElementRef<HTMLAnchorAttributes> & {
+ variant?: BadgeVariant;
+ } = $props();
+</script>
+
+<svelte:element
+ this={href ? "a" : "span"}
+ bind:this={ref}
+ data-slot="badge"
+ {href}
+ class={cn(badgeVariants({ variant }), className)}
+ {...restProps}
+>
+ {@render children?.()}
+</svelte:element>
diff --git a/frontend/src/lib/components/ui/badge/index.ts b/frontend/src/lib/components/ui/badge/index.ts
new file mode 100644
index 00000000..64e0aa9b
--- /dev/null
+++ b/frontend/src/lib/components/ui/badge/index.ts
@@ -0,0 +1,2 @@
+export { default as Badge } from "./badge.svelte";
+export { badgeVariants, type BadgeVariant } from "./badge.svelte";
diff --git a/frontend/src/lib/components/ui/tooltip/tooltip-content.svelte b/frontend/src/lib/components/ui/tooltip/tooltip-content.svelte
index 788ec34d..2f938067 100644
--- a/frontend/src/lib/components/ui/tooltip/tooltip-content.svelte
+++ b/frontend/src/lib/components/ui/tooltip/tooltip-content.svelte
@@ -27,7 +27,7 @@
{sideOffset}
{side}
class={cn(
- "bg-foreground text-background animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-end-2 data-[side=right]:slide-in-from-start-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-fit origin-(--bits-tooltip-content-transform-origin) rounded-md px-3 py-1.5 text-xs text-balance",
+ "bg-white text-foreground shadow-[0_0_12px_rgba(0,0,0,0.15)] dark:bg-foreground dark:text-background animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-end-2 data-[side=right]:slide-in-from-start-2 data-[side=top]:slide-in-from-bottom-2 z-50 max-w-[220px] origin-(--bits-tooltip-content-transform-origin) rounded-sm px-3 py-2 text-xs",
className
)}
{...restProps}
@@ -37,7 +37,7 @@
{#snippet child({ props })}
<div
class={cn(
- "bg-primary z-50 size-2.5 rotate-45 rounded-[2px]",
+ "bg-white dark:bg-foreground z-50 size-2.5 rotate-45 rounded-[2px]",
"data-[side=top]:translate-x-1/2 data-[side=top]:translate-y-[calc(-50%_+_2px)]",
"data-[side=bottom]:-translate-x-1/2 data-[side=bottom]:-translate-y-[calc(-50%_+_1px)]",
"data-[side=right]:translate-x-[calc(50%_+_2px)] data-[side=right]:translate-y-1/2",
diff --git a/frontend/src/routes/+page.svelte b/frontend/src/routes/+page.svelte
index 37f2750c..d07538f4 100644
--- a/frontend/src/routes/+page.svelte
+++ b/frontend/src/routes/+page.svelte
@@ -4,7 +4,7 @@
import { Skeleton } from '$lib/components/ui/skeleton';
import * as Table from '$lib/components/ui/table';
import * as Tooltip from '$lib/components/ui/tooltip';
- import { ArrowRight, CircleHelp, Gauge, Bug } from 'lucide-svelte';
+ import { ArrowRight, Info, Gauge, Bug, CircleQuestionMark } from 'lucide-svelte';
import { api } from '$lib/api';
import { ErrorDisplay } from '$lib/components/ui/error-display';
import { projectsState } from '$lib/state/projects.svelte';
@@ -139,6 +139,15 @@
<Gauge class="h-5 w-5 text-chart-1" />
</div>
<h2 class="text-2xl font-bold tracking-tight">Endpoints</h2>
+ <Tooltip.Root>
+ <Tooltip.Trigger>
+
+ <CircleQuestionMark class="h-3.5 w-3.5 text-muted-foreground/60" />
+ </Tooltip.Trigger>
+ <Tooltip.Content>
+ <p>Most impactful endpoints to optimize based on traffic and response time variance</p>
+ </Tooltip.Content>
+ </Tooltip.Root>
</div>
<div class="rounded-md border overflow-hidden">
<Table.Root>
@@ -149,7 +158,7 @@
Endpoint
<Tooltip.Root>
<Tooltip.Trigger>
- <CircleHelp class="h-3.5 w-3.5 text-muted-foreground/60" />
+ <CircleQuestionMark class="h-3.5 w-3.5 text-muted-foreground/60" />
</Tooltip.Trigger>
<Tooltip.Content>
<p class="text-xs">The API route or page being accessed</p>
@@ -162,7 +171,7 @@
Calls
<Tooltip.Root>
<Tooltip.Trigger>
- <CircleHelp class="h-3.5 w-3.5 text-muted-foreground/60" />
+ <CircleQuestionMark class="h-3.5 w-3.5 text-muted-foreground/60" />
</Tooltip.Trigger>
<Tooltip.Content>
<p class="text-xs">Total number of requests</p>
@@ -175,7 +184,7 @@
Typical
<Tooltip.Root>
<Tooltip.Trigger>
- <CircleHelp class="h-3.5 w-3.5 text-muted-foreground/60" />
+ <CircleQuestionMark class="h-3.5 w-3.5 text-muted-foreground/60" />
</Tooltip.Trigger>
<Tooltip.Content>
<p class="text-xs">Median response time (P50)</p>
@@ -188,7 +197,7 @@
Slow
<Tooltip.Root>
<Tooltip.Trigger>
- <CircleHelp class="h-3.5 w-3.5 text-muted-foreground/60" />
+ <CircleQuestionMark class="h-3.5 w-3.5 text-muted-foreground/60" />
</Tooltip.Trigger>
<Tooltip.Content>
<p class="text-xs">95th percentile - slowest 5%</p>
@@ -201,7 +210,7 @@
Impact
<Tooltip.Root>
<Tooltip.Trigger>
- <CircleHelp class="h-3.5 w-3.5 text-muted-foreground/60" />
+ <CircleQuestionMark class="h-3.5 w-3.5 text-muted-foreground/60" />
</Tooltip.Trigger>
<Tooltip.Content>
<p class="text-xs">Priority based on traffic × variance</p>
@@ -273,6 +282,16 @@
<Bug class="h-5 w-5 text-destructive" />
</div>
<h2 class="text-2xl font-bold tracking-tight">Issues</h2>
+ <Tooltip.Root>
+ <Tooltip.Trigger>
+ <div class="flex h-4 w-4 items-center justify-center rounded-full bg-muted-foreground/20">
+ <CircleQuestionMark class="h-3.5 w-3.5 text-muted-foreground/60" />
+ </div>
+ </Tooltip.Trigger>
+ <Tooltip.Content>
+ <p>Latest exceptions and errors to address from the last 24 hours</p>
+ </Tooltip.Content>
+ </Tooltip.Root>
</div>
<div class="rounded-md border overflow-hidden">
<Table.Root>
@@ -283,7 +302,7 @@
Issue
<Tooltip.Root>
<Tooltip.Trigger>
- <CircleHelp class="h-3.5 w-3.5 text-muted-foreground/60" />
+ <CircleQuestionMark class="h-3.5 w-3.5 text-muted-foreground/60" />
</Tooltip.Trigger>
<Tooltip.Content>
<p class="text-xs">The error message or exception that occurred</p>
@@ -296,7 +315,7 @@
Count
<Tooltip.Root>
<Tooltip.Trigger>
- <CircleHelp class="h-3.5 w-3.5 text-muted-foreground/60" />
+ <CircleQuestionMark class="h-3.5 w-3.5 text-muted-foreground/60" />
</Tooltip.Trigger>
<Tooltip.Content>
<p class="text-xs">Number of times this issue occurred</p>
@@ -309,7 +328,7 @@
When
<Tooltip.Root>
<Tooltip.Trigger>
- <CircleHelp class="h-3.5 w-3.5 text-muted-foreground/60" />
+ <CircleQuestionMark class="h-3.5 w-3.5 text-muted-foreground/60" />
</Tooltip.Trigger>
<Tooltip.Content>
<p class="text-xs">When this issue last occurred</p>