The only tool you need to know what is happening and how to fix it.
Go alertingexception-trackerissue-trackinglogsmetricsmonitoringobservability-platformopen-telemetryotelsession-replaytelemetrytraces
bug fix + docker file for testing nestjs
ddux148ae29486ec
diff --git a/frontend/src/routes/issues/+page.svelte b/frontend/src/routes/issues/+page.svelteindex bebeaf6e..005a2149 100644--- a/frontend/src/routes/issues/+page.svelte+++ b/frontend/src/routes/issues/+page.svelte@@ -32,6 +32,7 @@handleSortClick,type SortDirection} from '$lib/utils/sort-storage';+ import Button from '$lib/components/ui/button/button.svelte';const timezone = $derived(getTimezone());diff --git a/frontend/src/routes/metrics/+page.svelte b/frontend/src/routes/metrics/+page.svelteindex d697d9cb..aff5deb8 100644--- a/frontend/src/routes/metrics/+page.svelte+++ b/frontend/src/routes/metrics/+page.svelte@@ -2,7 +2,8 @@import { onMount } from 'svelte';import { browser } from '$app/environment';import { Button } from '$lib/components/ui/button';- import { RefreshCw, Code } from 'lucide-svelte';+ import { RefreshCw, Code, Info } from 'lucide-svelte';+ import * as Alert from '$lib/components/ui/alert';import ServerFilter from '$lib/components/dashboard/server-filter.svelte';import MetricsTabContent from '$lib/components/dashboard/metrics-tab-content.svelte';import * as Tabs from '$lib/components/ui/tabs';@@ -16,7 +17,7 @@ServerMetricsData} from '$lib/types/dashboard';import { api } from '$lib/api';- import { projectsState } from '$lib/state/projects.svelte';+ import { projectsState, isJsFramework } 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';@@ -34,6 +35,10 @@const timezone = $derived(getTimezone());+ const hideApplicationTab = $derived(+ projectsState.currentProject ? isJsFramework(projectsState.currentProject.framework) : false+ );+// Tab statelet activeTab = $state<MetricsTab>('application');@@ -58,8 +63,8 @@// Merge available servers from all endpointsconst availableServers = $derived(() => {const servers = new Set<string>();- applicationData?.availableServers?.forEach(s => servers.add(s));- serverData?.availableServers?.forEach(s => servers.add(s));+ applicationData?.availableServers?.forEach((s) => servers.add(s));+ serverData?.availableServers?.forEach((s) => servers.add(s));return Array.from(servers).sort();});@@ -81,9 +86,13 @@const tabParam = params.get('tab') as MetricsTab | null;const servers = serversParam ? serversParam.split(',').filter((s) => s.length > 0) : [];- const tab: MetricsTab = tabParam && ['application', 'stats', 'server'].includes(tabParam)- ? tabParam- : 'application';+ const defaultTab: MetricsTab = hideApplicationTab ? 'stats' : 'application';+ const tab: MetricsTab =+ tabParam && ['application', 'stats', 'server'].includes(tabParam)+ ? tabParam === 'application' && hideApplicationTab+ ? 'stats'+ : tabParam+ : defaultTab;const timeParams = parseTimeRangeFromUrl(timezone);return { ...timeParams, servers, tab };@@ -145,13 +154,19 @@function getFromDateTimeUTC(): string {const [hour, minute] = (fromTime || '00:00').split(':').map(Number);- const dt = calendarDateTimeToLuxon({ year: fromDate.year, month: fromDate.month, day: fromDate.day, hour, minute }, timezone);+ const dt = calendarDateTimeToLuxon(+ { year: fromDate.year, month: fromDate.month, day: fromDate.day, hour, minute },+ timezone+ );return toUTCISO(dt);}function getToDateTimeUTC(): string {const [hour, minute] = (toTime || '23:59').split(':').map(Number);- const dt = calendarDateTimeToLuxon({ year: toDate.year, month: toDate.month, day: toDate.day, hour, minute }, timezone);+ const dt = calendarDateTimeToLuxon(+ { year: toDate.year, month: toDate.month, day: toDate.day, hour, minute },+ timezone+ );return toUTCISO(dt);}@@ -274,6 +289,7 @@break;case 'stats':if (!statsData) loadStatsMetrics();+ if (!serverData) loadServerMetrics();break;case 'server':if (!serverData) loadServerMetrics();@@ -291,9 +307,16 @@// Load the active tabswitch (activeTab) {- case 'application': loadApplicationMetrics(); break;- case 'stats': loadStatsMetrics(); break;- case 'server': loadServerMetrics(); break;+ case 'application':+ loadApplicationMetrics();+ break;+ case 'stats':+ loadStatsMetrics();+ loadServerMetrics();+ break;+ case 'server':+ loadServerMetrics();+ break;}}@@ -337,26 +360,32 @@// Get last updated time for current tabconst lastUpdated = $derived(() => {switch (activeTab) {- case 'application': return applicationData?.lastUpdated;- case 'stats': return statsData?.lastUpdated;- case 'server': return serverData?.lastUpdated;- default: return undefined;+ case 'application':+ return applicationData?.lastUpdated;+ case 'stats':+ return statsData?.lastUpdated;+ case 'server':+ return serverData?.lastUpdated;+ default:+ return undefined;}});const lastUpdatedFormatted = $derived(- lastUpdated()- ? formatDateTime(lastUpdated()!, { timezone, format: 'time' })- : ''+ lastUpdated() ? formatDateTime(lastUpdated()!, { timezone, format: 'time' }) : '');// Check if current tab is loadingconst isCurrentTabLoading = $derived(() => {switch (activeTab) {- case 'application': return loadingApplication;- case 'stats': return loadingStats;- case 'server': return loadingServer;- default: return false;+ case 'application':+ return loadingApplication;+ case 'stats':+ return loadingStats;+ case 'server':+ return loadingServer;+ default:+ return false;}});@@ -390,7 +419,9 @@<div class="flex flex-wrap items-center justify-between gap-2"><div class="flex flex-wrap items-center gap-2"><Tabs.List>- <Tabs.Trigger value="application">Application</Tabs.Trigger>+ {#if !hideApplicationTab}+ <Tabs.Trigger value="application">Application</Tabs.Trigger>+ {/if}<Tabs.Trigger value="stats">Stats</Tabs.Trigger><Tabs.Trigger value="server">CPU / Mem</Tabs.Trigger><Tabs.Trigger value="custom">Custom</Tabs.Trigger>@@ -408,11 +439,16 @@{#if lastUpdated()}<div class="flex items-center gap-1">- <span class="text-sm text-muted-foreground whitespace-nowrap">+ <span class="text-sm whitespace-nowrap text-muted-foreground">Updated: {lastUpdatedFormatted}</span>- <Button variant="ghost" size="sm" onclick={() => reloadActiveTab()} disabled={isCurrentTabLoading()}>+ <Button+ variant="ghost"+ size="sm"+ onclick={() => reloadActiveTab()}+ disabled={isCurrentTabLoading()}+ ><RefreshCw class="h-4 w-4 {isCurrentTabLoading() ? 'animate-spin' : ''}" /></Button></div>@@ -437,6 +473,17 @@<!-- Stats Tab --><Tabs.Content value="stats">+ {#if availableServers().length > 1}+ <Alert.Root+ class="mt-2 mb-2 border-none"+ style="background: color-mix(in srgb, var(--sidebar-accent) 8%, transparent);"+ >+ <Info class="h-4 w-4" style="color: var(--sidebar-accent);" />+ <Alert.Description style="color: var(--sidebar-accent);">+ Stats are aggregated across all servers. Switch to CPU / Mem for per-server breakdowns.+ </Alert.Description>+ </Alert.Root>+ {/if}<MetricsTabContentmetrics={statsData?.metrics ?? null}loading={loadingStats}@@ -470,12 +517,13 @@<!-- Custom Tab --><Tabs.Content value="custom"><div class="flex flex-col items-center justify-center py-8 text-center">- <div class="bg-muted mb-4 rounded-full p-3">- <Code class="text-muted-foreground h-6 w-6" />+ <div class="mb-4 rounded-full bg-muted p-3">+ <Code class="h-6 w-6 text-muted-foreground" /></div><h3 class="mb-2 text-lg font-semibold">Custom Metrics not supported</h3>- <p class="text-muted-foreground mb-4 max-w-md text-sm">- Custom Metrics are not currently supported, but we're working on it and hope to have them supported soon.+ <p class="mb-4 max-w-md text-sm text-muted-foreground">+ Custom Metrics are not currently supported, but we're working on it and hope to have them+ supported soon.</p></div></Tabs.Content>diff --git a/testing/devtesting-nestjs/.dockerignore b/testing/devtesting-nestjs/.dockerignorenew file mode 100644index 00000000..0ca39c00--- /dev/null+++ b/testing/devtesting-nestjs/.dockerignore@@ -0,0 +1,3 @@+node_modules+dist+.DS_Storediff --git a/testing/devtesting-nestjs/Dockerfile b/testing/devtesting-nestjs/Dockerfilenew file mode 100644index 00000000..4199f785--- /dev/null+++ b/testing/devtesting-nestjs/Dockerfile@@ -0,0 +1,49 @@+FROM node:20-alpine AS builder++WORKDIR /app++COPY tracewayapp-core.tgz tracewayapp-backend.tgz tracewayapp-nestjs.tgz ./++COPY package.json ./+RUN node -e " \+ const pkg = JSON.parse(require('fs').readFileSync('package.json', 'utf8')); \+ pkg.dependencies['@tracewayapp/core'] = 'file:./tracewayapp-core.tgz'; \+ pkg.dependencies['@tracewayapp/backend'] = 'file:./tracewayapp-backend.tgz'; \+ pkg.dependencies['@tracewayapp/nestjs'] = 'file:./tracewayapp-nestjs.tgz'; \+ require('fs').writeFileSync('package.json', JSON.stringify(pkg, null, 2)); \+"++RUN npm install++COPY tsconfig.json nest-cli.json ./+COPY src/ ./src/++RUN npm run build++# ---++FROM node:20-alpine++RUN npm install -g pm2++WORKDIR /app++COPY tracewayapp-core.tgz tracewayapp-backend.tgz tracewayapp-nestjs.tgz ./++COPY package.json ./+RUN node -e " \+ const pkg = JSON.parse(require('fs').readFileSync('package.json', 'utf8')); \+ pkg.dependencies['@tracewayapp/core'] = 'file:./tracewayapp-core.tgz'; \+ pkg.dependencies['@tracewayapp/backend'] = 'file:./tracewayapp-backend.tgz'; \+ pkg.dependencies['@tracewayapp/nestjs'] = 'file:./tracewayapp-nestjs.tgz'; \+ require('fs').writeFileSync('package.json', JSON.stringify(pkg, null, 2)); \+"++RUN npm install --omit=dev++COPY --from=builder /app/dist ./dist+COPY ecosystem.config.js ./++EXPOSE 3001++CMD ["pm2-runtime", "ecosystem.config.js"]diff --git a/testing/devtesting-nestjs/README.md b/testing/devtesting-nestjs/README.mdindex 1665ddd7..ee70127e 100644--- a/testing/devtesting-nestjs/README.md+++ b/testing/devtesting-nestjs/README.md@@ -18,6 +18,30 @@ The app starts on port **3001** by default (configurable via `PORT` env var).| `PORT` | `3001` | Server port || `TRACEWAY_ENDPOINT` | `default_token_change_me@http://localhost:8082/api/report` | Traceway connection string |+## Docker (PM2 cluster mode)++Runs 4 instances of the app via PM2 in cluster mode.++### Build++```bash+./docker-build.sh+```++This packs the local `@tracewayapp/*` packages into tarballs, builds the Docker image, then cleans up.++### Run++```bash+docker run -p 3001:3001 \+ -e TRACEWAY_ENDPOINT="ed37c05e51c54f1db721f6fc59994e9b@http://host.docker.internal:8082/api/report" \+ devtesting-nestjs+```++`host.docker.internal` resolves to the host machine's localhost, so the app inside Docker can reach the Traceway backend running on your local port 8082.++The NestJS app is exposed on `http://localhost:3001` as usual.+## SDK IntegrationAll `@tracewayapp/nestjs` integration points are used correctly:diff --git a/testing/devtesting-nestjs/docker-build.sh b/testing/devtesting-nestjs/docker-build.shnew file mode 100755index 00000000..1cce7ef9--- /dev/null+++ b/testing/devtesting-nestjs/docker-build.sh@@ -0,0 +1,30 @@+#!/bin/bash+set -e++SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"+JS_CLIENT="$SCRIPT_DIR/../../../js-client"++echo "Packing @tracewayapp packages..."++cd "$JS_CLIENT/packages/core"+npm pack --pack-destination "$SCRIPT_DIR" 2>/dev/null+mv "$SCRIPT_DIR"/tracewayapp-core-*.tgz "$SCRIPT_DIR/tracewayapp-core.tgz"++cd "$JS_CLIENT/packages/backend"+npm pack --pack-destination "$SCRIPT_DIR" 2>/dev/null+mv "$SCRIPT_DIR"/tracewayapp-backend-*.tgz "$SCRIPT_DIR/tracewayapp-backend.tgz"++cd "$JS_CLIENT/packages/nestjs"+npm pack --pack-destination "$SCRIPT_DIR" 2>/dev/null+mv "$SCRIPT_DIR"/tracewayapp-nestjs-*.tgz "$SCRIPT_DIR/tracewayapp-nestjs.tgz"++echo "Building Docker image..."+cd "$SCRIPT_DIR"+docker build -t devtesting-nestjs .++echo "Cleaning up tarballs..."+rm -f "$SCRIPT_DIR"/tracewayapp-*.tgz++echo ""+echo "Done! Run with:"+echo ' docker run -p 3001:3001 -e TRACEWAY_ENDPOINT="your-token@http://host.docker.internal:8082/api/report" devtesting-nestjs'diff --git a/testing/devtesting-nestjs/ecosystem.config.js b/testing/devtesting-nestjs/ecosystem.config.jsnew file mode 100644index 00000000..9d944fe9--- /dev/null+++ b/testing/devtesting-nestjs/ecosystem.config.js@@ -0,0 +1,10 @@+module.exports = {+ apps: [+ {+ name: "devtesting-nestjs",+ script: "dist/main.js",+ instances: 4,+ exec_mode: "cluster",+ },+ ],+};