Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
93 changes: 93 additions & 0 deletions .github/workflows/pages.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
name: Deploy Trace Viewer Demo

on:
push:
branches: [main]
pull_request:
types: [opened, synchronize, reopened, closed]
branches: [main]

permissions:
contents: write
pull-requests: write

concurrency:
group: pages-${{ github.ref }}
cancel-in-progress: true

jobs:
deploy:
runs-on: ubuntu-latest
if: >-
github.event_name == 'push'
|| (github.event_name == 'pull_request' && github.event.action != 'closed')
steps:
- uses: actions/checkout@v4

- uses: dtolnay/rust-toolchain@stable

- uses: Swatinem/rust-cache@v2

- name: Build demo trace
run: cargo run --example realistic_workload
timeout-minutes: 5

- name: Assemble site
run: |
mkdir -p _site
cp dial9-tokio-telemetry/trace_viewer.html _site/trace_viewer.html
cp realistic_trace.bin _site/demo.bin
cp demo/index.html _site/index.html

- name: Deploy (main)
if: github.ref == 'refs/heads/main'
uses: peaceiris/actions-gh-pages@4f9cc6602d3f66b9c108549d475ec49e8ef4d45e # v4.0.0
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./_site
keep_files: true

- name: Deploy (PR preview)
if: github.event_name == 'pull_request'
uses: peaceiris/actions-gh-pages@4f9cc6602d3f66b9c108549d475ec49e8ef4d45e # v4.0.0
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./_site
destination_dir: pr/${{ github.event.number }}

- name: Comment PR with preview link
if: github.event_name == 'pull_request'
uses: actions/github-script@v7
with:
script: |
const url = `https://${context.repo.owner}.github.io/${context.repo.repo}/pr/${context.issue.number}/`;
const body = `🔍 **Trace Viewer Preview:** ${url}`;
const { data: comments } = await github.rest.issues.listComments({
...context.repo, issue_number: context.issue.number
});
const existing = comments.find(c => c.body.includes('Trace Viewer Preview'));
if (existing) {
await github.rest.issues.updateComment({ ...context.repo, comment_id: existing.id, body });
} else {
await github.rest.issues.createComment({ ...context.repo, issue_number: context.issue.number, body });
}

cleanup-preview:
runs-on: ubuntu-latest
if: github.event_name == 'pull_request' && github.event.action == 'closed'
permissions:
contents: write
steps:
- uses: actions/checkout@v4
with:
ref: gh-pages

- name: Remove PR preview
run: |
if [ -d "pr/${{ github.event.number }}" ]; then
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git rm -rf "pr/${{ github.event.number }}"
git commit -m "Clean up PR #${{ github.event.number }} preview"
git push
fi
3 changes: 3 additions & 0 deletions demo/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<!doctype html>
<meta http-equiv="refresh" content="0;url=trace_viewer.html?trace=demo.bin">
<a href="trace_viewer.html?trace=demo.bin">Open Trace Viewer Demo</a>
15 changes: 15 additions & 0 deletions dial9-tokio-telemetry/trace_viewer.html
Original file line number Diff line number Diff line change
Expand Up @@ -1979,6 +1979,21 @@
if (trace) renderAll();
});

// ── Auto-load trace from ?trace=URL parameter ──
(function autoLoadFromUrl() {
const traceUrl = new URLSearchParams(location.search).get("trace");
if (!traceUrl) return;
dropZone.innerHTML = "Loading trace…";
fetch(traceUrl)
.then(r => { if (!r.ok) throw new Error(r.status); return r.arrayBuffer(); })
.then(buf => {
trace = parseTrace(buf);
processTrace();
showViewer(traceUrl.split("/").pop());
})
.catch(err => { dropZone.innerHTML = "Failed to load trace: " + err.message; });
})();

// ── Legend (inline in toolbar area) ──
(function addLegend() {
const tb = document.getElementById("toolbar");
Expand Down