|
| 1 | +# Hayhooks Tracing Dashboard Frontend |
| 2 | + |
| 3 | +This directory contains the React + TypeScript frontend for the Hayhooks tracing dashboard. |
| 4 | + |
| 5 | +When you run: |
| 6 | + |
| 7 | +```bash |
| 8 | +hayhooks run --with-tracing-dashboard |
| 9 | +``` |
| 10 | + |
| 11 | +Hayhooks serves this app at `/dashboard` and uses it to visualize live trace activity. |
| 12 | +The dashboard API reads traces from Hayhooks' in-process live trace buffer. |
| 13 | + |
| 14 | +## What This Dashboard Shows |
| 15 | + |
| 16 | +- Live trace feed with freshness highlights and new-trace animations |
| 17 | +- Ongoing vs completed traces |
| 18 | +- Kind badges (run, openai, deploy, undeploy, mcp) for at-a-glance classification |
| 19 | +- Streaming indicator for SSE/streaming requests |
| 20 | +- Failure highlighting with expandable error details and copyable stack traces |
| 21 | +- Pipeline filtering via sidebar |
| 22 | +- Span waterfall with duration bars, per-span tags, and slowest-component highlighting |
| 23 | +- Basic trace stats (count, failures, avg duration with sparkline, last trace time) |
| 24 | +- Dark mode toggle |
| 25 | +- Trace buffer clear with confirmation dialog |
| 26 | + |
| 27 | +## Prerequisites |
| 28 | + |
| 29 | +- Node.js + npm (required for local frontend development/build) |
| 30 | +- A running Hayhooks backend (default: `http://localhost:1416`) |
| 31 | + |
| 32 | +## Local Development |
| 33 | + |
| 34 | +1. Start Hayhooks in another terminal: |
| 35 | + |
| 36 | + ```bash |
| 37 | + hayhooks run --with-tracing-dashboard |
| 38 | + ``` |
| 39 | + |
| 40 | +2. Install frontend dependencies: |
| 41 | + |
| 42 | + ```bash |
| 43 | + cd dashboard |
| 44 | + npm install |
| 45 | + ``` |
| 46 | + |
| 47 | +3. Start Vite dev server: |
| 48 | + |
| 49 | + ```bash |
| 50 | + npm run dev |
| 51 | + ``` |
| 52 | + |
| 53 | +4. Open the local frontend (usually `http://localhost:5173`). |
| 54 | + |
| 55 | +By default, local dev assumes the backend API at `http://localhost:1416/dashboard/api`. |
| 56 | +If your backend runs elsewhere, set `VITE_HAYHOOKS_DASHBOARD_API_BASE`: |
| 57 | + |
| 58 | +```bash |
| 59 | +VITE_HAYHOOKS_DASHBOARD_API_BASE="http://localhost:1416/dashboard/api" npm run dev |
| 60 | +``` |
| 61 | + |
| 62 | +## Useful Commands |
| 63 | + |
| 64 | +Run these from `dashboard/`: |
| 65 | + |
| 66 | +```bash |
| 67 | +# Start dev server (HMR) |
| 68 | +npm run dev |
| 69 | + |
| 70 | +# Run tests once |
| 71 | +npm run test |
| 72 | + |
| 73 | +# Run tests in watch mode |
| 74 | +npm run test:watch |
| 75 | + |
| 76 | +# Lint |
| 77 | +npm run lint |
| 78 | + |
| 79 | +# Build production assets to dist/ |
| 80 | +npm run build |
| 81 | + |
| 82 | +# Preview production build |
| 83 | +npm run preview |
| 84 | +``` |
| 85 | + |
| 86 | +Common pre-PR check: |
| 87 | + |
| 88 | +```bash |
| 89 | +npm run lint && npm run test && npm run build |
| 90 | +``` |
| 91 | + |
| 92 | +## Production/Runtime Notes |
| 93 | + |
| 94 | +- `hayhooks run --with-tracing-dashboard` builds and serves static assets from `dashboard/dist`. |
| 95 | +- You can override where Hayhooks reads built assets with `HAYHOOKS_DASHBOARD_DIST_DIR`. |
| 96 | +- The dashboard trace API (`/dashboard/api/traces`) is local-buffer only (no direct Jaeger/SigNoz fetch mode). |
| 97 | +- Dashboard traces are process-local. With multiple server workers (`hayhooks run --workers >1`), each worker has |
| 98 | + its own trace buffer, so `/dashboard` may show only a subset of traces and clear is worker-local. |
| 99 | +- For consistent dashboard behavior, run with a single worker (`--workers 1`) when relying on the built-in live dashboard. |
| 100 | + |
| 101 | +## Related Documentation |
| 102 | + |
| 103 | +- [`docs/reference/tracing.md`](../docs/reference/tracing.md) — includes demo script (`scripts/demo_dashboard_traces.sh`) for generating representative traces |
| 104 | +- [`docs/reference/environment-variables.md`](../docs/reference/environment-variables.md) |
0 commit comments