The only tool you need to know what is happening and how to fix it.
Go alertingexception-trackerissue-trackinglogsmetricsmonitoringobservability-platformopen-telemetryotelsession-replaytelemetrytraces
default metrics for go and otel projects added
ddux53f94b82da1a
diff --git a/backend/app/controllers/routes.go b/backend/app/controllers/routes.goindex feac36f4..74ae03c2 100644--- a/backend/app/controllers/routes.go+++ b/backend/app/controllers/routes.go@@ -61,6 +61,7 @@ func RegisterControllers(router *gin.RouterGroup) {// Widget groupsrouter.GET("/widget-groups", middleware.UseAppAuth, middleware.RequireProjectAccess, middleware.Transactional, WidgetGroupController.List)router.POST("/widget-groups", middleware.UseAppAuth, middleware.RequireProjectAccess, middleware.RequireWriteAccess, middleware.Transactional, WidgetGroupController.Create)+ router.POST("/widget-groups/populate-defaults", middleware.UseAppAuth, middleware.RequireProjectAccess, middleware.RequireWriteAccess, middleware.Transactional, WidgetGroupController.PopulateDefaults)router.GET("/widget-groups/:id", middleware.UseAppAuth, middleware.RequireProjectAccess, middleware.Transactional, WidgetGroupController.GetWithWidgets)router.PUT("/widget-groups/:id", middleware.UseAppAuth, middleware.RequireProjectAccess, middleware.RequireWriteAccess, middleware.Transactional, WidgetGroupController.Update)router.DELETE("/widget-groups/:id", middleware.UseAppAuth, middleware.RequireProjectAccess, middleware.RequireWriteAccess, middleware.Transactional, WidgetGroupController.Delete)diff --git a/backend/app/controllers/widget_group.controller.go b/backend/app/controllers/widget_group.controller.goindex bef2a53e..78128656 100644--- a/backend/app/controllers/widget_group.controller.go+++ b/backend/app/controllers/widget_group.controller.go@@ -33,30 +33,56 @@ func (c *widgetGroupController) List(ctx *gin.Context) {ctx.AbortWithError(http.StatusInternalServerError, traceway.NewStackTraceErrorf("failed to list widget groups: %w", err))return}- if len(list) == 0 {- project, err := repositories.ProjectRepository.FindById(tx, projectId)- if err != nil {- ctx.AbortWithError(http.StatusInternalServerError, traceway.NewStackTraceErrorf("failed to find project: %w", err))- return- }- goFrameworks := map[string]bool{- "gin": true, "fiber": true, "chi": true,- "fasthttp": true, "stdlib": true, "custom": true,- }- if project != nil && goFrameworks[project.Framework] {- if err := ensureDefaultWidgetGroups(tx, projectId); err != nil {- ctx.AbortWithError(http.StatusInternalServerError, traceway.NewStackTraceErrorf("failed to create default widget groups: %w", err))- return- }- list, err = repositories.WidgetGroupRepository.FindByProject(tx, projectId)- if err != nil {- ctx.AbortWithError(http.StatusInternalServerError, traceway.NewStackTraceErrorf("failed to list widget groups: %w", err))- return- }- }++ project, err := repositories.ProjectRepository.FindById(tx, projectId)+ if err != nil {+ ctx.AbortWithError(http.StatusInternalServerError, traceway.NewStackTraceErrorf("failed to find project: %w", err))+ return+ }++ framework := ""+ if project != nil {+ framework = project.Framework}- ctx.JSON(http.StatusOK, gin.H{"widgetGroups": list})+ ctx.JSON(http.StatusOK, gin.H{+ "widgetGroups": list,+ "framework": framework,+ "canPopulateDefaults": len(list) == 0,+ })+}++func (c *widgetGroupController) PopulateDefaults(ctx *gin.Context) {+ projectId, err := middleware.GetProjectId(ctx)+ if err != nil {+ ctx.AbortWithError(http.StatusInternalServerError, traceway.NewStackTraceErrorf("RequireProjectAccess middleware must be applied: %w", err))+ return+ }++ tx := middleware.GetTx(ctx)++ existing, err := repositories.WidgetGroupRepository.FindByProject(tx, projectId)+ if err != nil {+ ctx.AbortWithError(http.StatusInternalServerError, traceway.NewStackTraceErrorf("failed to list widget groups: %w", err))+ return+ }+ if len(existing) > 0 {+ ctx.JSON(http.StatusUnprocessableEntity, gin.H{"error": "Project already has widget groups."})+ return+ }++ if err := ensureDefaultWidgetGroups(tx, projectId); err != nil {+ ctx.AbortWithError(http.StatusInternalServerError, traceway.NewStackTraceErrorf("failed to create default widget groups: %w", err))+ return+ }++ list, err := repositories.WidgetGroupRepository.FindByProject(tx, projectId)+ if err != nil {+ ctx.AbortWithError(http.StatusInternalServerError, traceway.NewStackTraceErrorf("failed to list widget groups: %w", err))+ return+ }++ ctx.JSON(http.StatusCreated, gin.H{"widgetGroups": list})}type CreateWidgetGroupRequest struct {@@ -284,7 +310,11 @@ func ensureDefaultWidgetGroups(tx *sql.Tx, projectId uuid.UUID) error {"react": true, "svelte": true, "vuejs": true,"nextjs": true, "nestjs": true, "express": true, "remix": true,}+ otelFrameworks := map[string]bool{+ "opentelemetry": true,+ }isJS := project != nil && jsFrameworks[project.Framework]+ isOtel := project != nil && otelFrameworks[project.Framework]type widgetDef struct {title string@@ -297,35 +327,65 @@ func ensureDefaultWidgetGroups(tx *sql.Tx, projectId uuid.UUID) error {var groupDefs []groupDef- if !isJS {- groupDefs = append(groupDefs, groupDef{- name: "Application",- widgets: []widgetDef{- {"Go Routines", "go.go_routines"},- {"Heap Objects", "go.heap_objects"},- {"GC Cycles", "go.num_gc"},- {"GC Pause", "go.gc_pause"},+ if isOtel {+ groupDefs = append(groupDefs,+ groupDef{+ name: "System",+ widgets: []widgetDef{+ {"CPU Utilization", "system.cpu.utilization"},+ {"Memory Utilization", "system.memory.utilization"},+ {"Memory Usage", "system.memory.usage"},+ {"Load Avg (1m)", "system.cpu.load_average.1m"},+ },},- })- }+ groupDef{+ name: "Disk / Net",+ widgets: []widgetDef{+ {"Disk I/O", "system.disk.io"},+ {"Filesystem Usage", "system.filesystem.usage"},+ {"Network I/O", "system.network.io"},+ {"Open Connections", "system.network.connections"},+ },+ },+ groupDef{+ name: "Process",+ widgets: []widgetDef{+ {"Process CPU Time", "process.cpu.time"},+ {"Process RSS", "process.memory.usage"},+ {"Process Virtual", "process.memory.virtual"},+ },+ },+ )+ } else {+ if !isJS {+ groupDefs = append(groupDefs, groupDef{+ name: "Application",+ widgets: []widgetDef{+ {"Go Routines", "go.go_routines"},+ {"Heap Objects", "go.heap_objects"},+ {"GC Cycles", "go.num_gc"},+ {"GC Pause", "go.gc_pause"},+ },+ })+ }- groupDefs = append(groupDefs,- groupDef{- name: "Stats",- widgets: []widgetDef{- {"Memory Usage", "mem.used"},- {"Memory Used %", "mem.used_pcnt"},- {"Total Memory", "mem.total"},+ groupDefs = append(groupDefs,+ groupDef{+ name: "Stats",+ widgets: []widgetDef{+ {"Memory Usage", "mem.used"},+ {"Total Memory", "mem.total"},+ },},- },- groupDef{- name: "CPU / Mem",- widgets: []widgetDef{- {"CPU Usage", "cpu.used_pcnt"},- {"Memory Usage", "mem.used"},+ groupDef{+ name: "CPU / Mem",+ widgets: []widgetDef{+ {"CPU Usage", "cpu.used_pcnt"},+ {"Memory Usage", "mem.used"},+ },},- },- )+ )+ }now := time.Now().UTC()for _, gd := range groupDefs {diff --git a/frontend/src/lib/utils/metric-format.ts b/frontend/src/lib/utils/metric-format.tsindex de337375..12a01a90 100644--- a/frontend/src/lib/utils/metric-format.ts+++ b/frontend/src/lib/utils/metric-format.ts@@ -1,6 +1,21 @@type FormatResult = { text: string; unit: string };export function formatMetricValue(value: number, unit: string): FormatResult {+ // OTel canonical unit '1' is a dimensionless ratio (0-1) — render as percent.+ if (unit === '1') {+ return formatMetricValue(value * 100, '%');+ }++ // OTel canonical unit 'By' is bytes — normalize to the existing bytes branch.+ if (unit === 'By') {+ return formatMetricValue(value, 'B');+ }++ // OTel annotation units like '{connections}', '{packets}' — treat as raw count.+ if (unit.length > 2 && unit.startsWith('{') && unit.endsWith('}')) {+ return formatMetricValue(value, 'count');+ }+if (unit === '%') {if (value === 0) return { text: '0', unit: '%' };if (Math.abs(value) < 0.1) return { text: value.toFixed(2), unit: '%' };diff --git a/frontend/src/routes/+layout.svelte b/frontend/src/routes/+layout.svelteindex b3231329..4d7eeef7 100644--- a/frontend/src/routes/+layout.svelte+++ b/frontend/src/routes/+layout.svelte@@ -104,7 +104,7 @@class="flex flex-row items-center gap-2 rounded-md px-2 py-1 transition-colors hover:bg-accent hover:text-accent-foreground">{#if projectsState.currentProject}- <FrameworkIcon framework={projectsState.currentProject.framework} />+ <FrameworkIcon framework={projectsState.currentProject.framework} class="size-6 shrink-0" />{/if}<span>{projectsState.currentProject?.name || 'Select Project'}</span><ChevronDown size={16} />diff --git a/frontend/src/routes/metrics/+page.svelte b/frontend/src/routes/metrics/+page.svelteindex 79b62f95..796d0960 100644--- a/frontend/src/routes/metrics/+page.svelte+++ b/frontend/src/routes/metrics/+page.svelte@@ -9,7 +9,7 @@import WidgetGrid from '$lib/components/dashboard/widget-grid.svelte';import WidgetConfigPanel from '$lib/components/dashboard/widget-config-panel.svelte';import { api } from '$lib/api';- import { projectsState } from '$lib/state/projects.svelte';+ import { projectsState, FRAMEWORK_LABELS, type Framework } from '$lib/state/projects.svelte';import { getTimezone } from '$lib/state/timezone.svelte';import { toUTCISO, calendarDateTimeToLuxon, formatDateTime } from '$lib/utils/formatters';import { TimeRangePicker } from '$lib/components/ui/time-range-picker';@@ -22,7 +22,7 @@updateUrl} from '$lib/utils/url-params';import { CalendarDate } from '@internationalized/date';- import { Trash2, Plus, RefreshCw, CircleAlert, EllipsisVertical } from 'lucide-svelte';+ import { Trash2, Plus, RefreshCw, CircleAlert, EllipsisVertical, Sparkles } from 'lucide-svelte';import * as Alert from '$lib/components/ui/alert';import * as DropdownMenu from '$lib/components/ui/dropdown-menu';import { toast } from 'svelte-sonner';@@ -51,6 +51,9 @@};let widgetGroups = $state<WidgetGroup[]>([]);+ let projectFramework = $state<Framework | ''>('');+ let canPopulateDefaults = $state(false);+ let populating = $state(false);let loading = $state(true);let activeTabId = $state<string>('');let activeGroup = $state<WidgetGroupWithWidgets | null>(null);@@ -152,6 +155,8 @@projectId: projectsState.currentProjectId ?? undefined});widgetGroups = response.widgetGroups || [];+ projectFramework = (response.framework as Framework) || '';+ canPopulateDefaults = !!response.canPopulateDefaults;if (widgetGroups.length > 0 && !activeTabId) {activeTabId = String(widgetGroups[0].id);}@@ -162,6 +167,27 @@}}+ async function populateDefaults() {+ populating = true;+ try {+ await api.post(+ '/widget-groups/populate-defaults',+ {},+ { projectId: projectsState.currentProjectId ?? undefined }+ );+ toast.success('Successfully populated default charts', { position: 'top-center' });+ await loadWidgetGroups();+ } catch (e: any) {+ toast.error(e?.message || 'Failed to populate default charts', { position: 'top-center' });+ } finally {+ populating = false;+ }+ }++ const frameworkLabel = $derived(+ projectFramework ? (FRAMEWORK_LABELS[projectFramework] ?? projectFramework) : ''+ );+async function loadGroupWidgets(groupId: string) {loadingGroup = true;try {@@ -416,13 +442,25 @@</div>{:else if widgetGroups.length === 0}<div- class="flex flex-col items-center justify-center rounded-md bg-muted py-20 text-center text-muted-foreground"+ class="flex flex-col items-center justify-center rounded-md bg-muted py-20 text-center">- <p class="mb-4">No widget groups yet. Create one to get started.</p>- <Button onclick={() => (showCreateDialog = true)}>- <Plus class="mr-1 h-4 w-4" />- Create your first Widget Group- </Button>+ <p class="mb-4 text-muted-foreground">No widget groups yet.</p>+ <div class="flex flex-wrap items-center justify-center gap-2">+ {#if canPopulateDefaults}+ <Button onclick={populateDefaults} disabled={populating}>+ <Sparkles class="mr-1 h-4 w-4" />+ {populating+ ? 'Populating...'+ : frameworkLabel+ ? `Populate default charts for ${frameworkLabel}`+ : 'Populate default charts'}+ </Button>+ {/if}+ <Button variant="outline" onclick={() => (showCreateDialog = true)}>+ <Plus class="mr-1 h-4 w-4" />+ Create your own Widget Group+ </Button>+ </div></div>{:else}<Tabs.Root value={activeTabId} onValueChange={handleTabChange}>