Skip to content

Commit 72f7b59

Browse files
authored
Tracing dashboard (#237)
* Implemented tracing using OpenTelemetryTracer ; updated docs * Update docs * tracing dashboard * tracing dashboard improvements * dashboard backend simplification + test isolation + docs alignment * including haystack traces * traces buffer cap * payload values * iteration: add slowest component ; fix layout * updated docs * Implemented tracing using OpenTelemetryTracer ; updated docs * Update docs * update favicon * lint * fix types * fix types ; fix relevant bugs ; refactoring * update docs * add custom tracing example * Update fonts * Update font ; Refactor to useState/setState * Lint * HAYHOOKS_DASHBOARD_TRACE_INCLUDE_HAYSTACK_SPANS is true by default * Refactoring * Lint * add force_sync_callbacks for async_streaming_generator for Pipeline ; refactoring (#239) * using design advisor * cleanup * cleanup + refactoring * Fix CI * Last nits * cleanup * update demo script * Updated docs * Updated docs * Iteration * Lint * Applying last iteration fixes * lint * run dashboard tests on /dashboard changes * update lock * update lock * show component name beside haystack.component.run
1 parent 8202902 commit 72f7b59

101 files changed

Lines changed: 15762 additions & 36 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/tests.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ env:
1414
HATCH_VERSION: "1.16.5"
1515
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
1616

17+
permissions:
18+
contents: read
19+
pull-requests: read
20+
1721
jobs:
1822
tests:
1923
runs-on: ubuntu-latest
@@ -50,3 +54,32 @@ jobs:
5054

5155
- name: Ty - check types
5256
run: hatch run test:types
57+
58+
dashboard-tests:
59+
runs-on: ubuntu-latest
60+
steps:
61+
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
62+
63+
- uses: dorny/paths-filter@6852f92c20ea7fd3b0c25de3b5112db3a98da050 # v3
64+
id: changes
65+
with:
66+
filters: |
67+
dashboard:
68+
- "dashboard/**"
69+
70+
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
71+
if: steps.changes.outputs.dashboard == 'true'
72+
with:
73+
node-version: "22"
74+
cache: npm
75+
cache-dependency-path: dashboard/package-lock.json
76+
77+
- name: Install dashboard dependencies
78+
if: steps.changes.outputs.dashboard == 'true'
79+
working-directory: dashboard
80+
run: npm ci
81+
82+
- name: Run dashboard frontend tests
83+
if: steps.changes.outputs.dashboard == 'true'
84+
working-directory: dashboard
85+
run: npm run test

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ cover/
5454

5555
!docs/**/*.png
5656
!src/hayhooks/server/chainlit_app/public/*.png
57+
!dashboard/src/assets/*.png
58+
!dashboard/src/lib/
5759

5860
# Translations
5961
*.mo

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ With Hayhooks, you can:
99
- 💬 **Integrate your Haystack pipelines and agents with [Open WebUI](https://openwebui.com)** as OpenAI-compatible chat completion backends with streaming support.
1010
- 🖥️ **Embed a [Chainlit](https://chainlit.io/) chat UI** directly in Hayhooks with `pip install "hayhooks[chainlit]"` and `hayhooks run --with-chainlit` -- zero-configuration frontend with streaming, pipeline selection, and custom UI widgets.
1111
- 🕹️ **Control Hayhooks core API endpoints through chat** - deploy, undeploy, list, or run Haystack pipelines and agents by chatting with [Claude Desktop](https://claude.ai/download), [Cursor](https://cursor.com), or any other MCP client.
12-
- 📈 **Trace Hayhooks lifecycle actions with OpenTelemetry** (`pip install "hayhooks[tracing]"`) for deploy/run/undeploy visibility across REST and MCP.
12+
- 📈 **Trace Hayhooks lifecycle actions with OpenTelemetry** (`pip install "hayhooks[tracing]"`) for deploy/run/undeploy visibility across REST and MCP, with a `/dashboard` UI via `hayhooks run --with-tracing-dashboard` (backed by a local live trace buffer).
1313

1414
[![PyPI - Version](https://img.shields.io/pypi/v/hayhooks.svg)](https://pypi.org/project/hayhooks)
1515
[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/hayhooks.svg)](https://pypi.org/project/hayhooks)
@@ -157,6 +157,7 @@ Or chat with it in the [embedded Chainlit UI](docs/features/chainlit-integration
157157
- [Quick Start Guide](docs/getting-started/quick-start.md) - Get started with Hayhooks
158158
- [Installation](docs/getting-started/installation.md) - Install Hayhooks and dependencies
159159
- [Configuration](docs/getting-started/configuration.md) - Configure Hayhooks for your needs
160+
- [Tracing Dashboard Frontend](dashboard/README.md) - Local dashboard setup and frontend development commands
160161
- [Examples](docs/examples/overview.md) - Explore example implementations
161162

162163
## Community & Support

dashboard/.gitignore

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Logs
2+
logs
3+
*.log
4+
npm-debug.log*
5+
yarn-debug.log*
6+
yarn-error.log*
7+
pnpm-debug.log*
8+
lerna-debug.log*
9+
10+
node_modules
11+
dist
12+
dist-ssr
13+
*.local
14+
15+
# Editor directories and files
16+
.vscode/*
17+
!.vscode/extensions.json
18+
.idea
19+
.DS_Store
20+
*.suo
21+
*.ntvs*
22+
*.njsproj
23+
*.sln
24+
*.sw?

dashboard/README.md

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
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)

dashboard/components.json

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"$schema": "https://ui.shadcn.com/schema.json",
3+
"style": "base-nova",
4+
"rsc": false,
5+
"tsx": true,
6+
"tailwind": {
7+
"config": "",
8+
"css": "src/index.css",
9+
"baseColor": "neutral",
10+
"cssVariables": true,
11+
"prefix": ""
12+
},
13+
"iconLibrary": "lucide",
14+
"rtl": false,
15+
"aliases": {
16+
"components": "@/components",
17+
"utils": "@/lib/utils",
18+
"ui": "@/components/ui",
19+
"lib": "@/lib",
20+
"hooks": "@/hooks"
21+
},
22+
"menuColor": "default",
23+
"menuAccent": "subtle",
24+
"registries": {}
25+
}

dashboard/eslint.config.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import js from '@eslint/js'
2+
import globals from 'globals'
3+
import reactHooks from 'eslint-plugin-react-hooks'
4+
import reactRefresh from 'eslint-plugin-react-refresh'
5+
import tseslint from 'typescript-eslint'
6+
import { defineConfig, globalIgnores } from 'eslint/config'
7+
8+
export default defineConfig([
9+
globalIgnores(['dist']),
10+
{
11+
files: ['**/*.{ts,tsx}'],
12+
extends: [
13+
js.configs.recommended,
14+
tseslint.configs.recommended,
15+
reactHooks.configs.flat.recommended,
16+
reactRefresh.configs.vite,
17+
],
18+
languageOptions: {
19+
ecmaVersion: 2020,
20+
globals: globals.browser,
21+
},
22+
},
23+
{
24+
files: ['src/components/ui/**/*.{ts,tsx}'],
25+
rules: {
26+
'react-refresh/only-export-components': 'off',
27+
},
28+
},
29+
])

dashboard/index.html

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<!doctype html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<link rel="icon" type="image/png" href="./src/assets/haystack-icon.png" />
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
7+
<title>dashboard</title>
8+
</head>
9+
<body>
10+
<div id="root"></div>
11+
<script type="module" src="/src/main.tsx"></script>
12+
</body>
13+
</html>

0 commit comments

Comments
 (0)