Skip to content

feat(dashboard): log-tracing hub with RealUnit + All-Logs views#1113

Merged
TaprootFreak merged 9 commits into
developfrom
feature/realunit-tracing-time-chart
Jun 1, 2026
Merged

feat(dashboard): log-tracing hub with RealUnit + All-Logs views#1113
TaprootFreak merged 9 commits into
developfrom
feature/realunit-tracing-time-chart

Conversation

@TaprootFreak

@TaprootFreak TaprootFreak commented May 23, 2026

Copy link
Copy Markdown
Collaborator

Summary

Restructures the tracing dashboard into a hub URL with two sub-views, on top of the existing RealUnit tracing screen + calls-over-time chart.

New URL structure

  • /dashboard/log-tracing — hub screen with two cards (dark-themed, matches financial overview):
    • RealUnit/dashboard/log-tracing/realunit
    • All Logs/dashboard/log-tracing/all
  • /dashboard/log-tracing/realunit — the existing RealUnit tracing screen, URL-renamed only (no logic change)
  • /dashboard/log-tracing/allnew generic-logs view: 4 summary cards (Total / Errors / Warnings / Info), 50-row Recent Entries table with severity badge, context, and message (truncated to 240 chars). 1h / 6h / 24h ranges, 60s refresh.

The /dashboard hub card previously labelled RealUnit Tracing is now Log Tracing and points at /dashboard/log-tracing.

Hook expansion

src/hooks/log-tracing.hook.ts (renamed from realunit-tracing.hook.ts):

  • adds getAllTraces(hours) fetching the new all-traces template
  • adds GenericTrace interface + parseGenericTrace() that extracts the [Context] prefix and message remainder

Backend prerequisite

This screen depends on the all-traces log template, added in DFXswiss/api#3757. The /all view only works once that PR is deployed.

File renames (all via git mv, history preserved)

  • src/screens/dashboard-realunit-tracing.screen.tsx -> src/screens/dashboard-log-tracing-realunit.screen.tsx
  • src/hooks/realunit-tracing.hook.ts -> src/hooks/log-tracing.hook.ts
  • src/components/dashboard/realunit-trace-time-chart.tsx -> src/components/dashboard/log-trace-time-chart.tsx

Identifier renames

  • useRealunitTracing -> useLogTracing
  • RealUnitTraceTimeChart -> LogTraceTimeChart
  • DashboardRealunitTracingScreen -> DashboardLogTracingRealunitScreen
  • getRealunitTraces stays (still the RealUnit-specific fetcher)

Drive-by review fixes

  • Chart animations re-enabled (the previous 5s-refresh rationale no longer applies; refresh is 60s and smooth transitions feel right).
  • Added a 2-line comment above useAdminGuard() documenting why admin-only is the right gate (backend /gs/debug/logs is RoleGuard(DEBUG) + ADMIN/SUPER_ADMIN via additionalRoles, not REALUNIT).

Test plan

  • tsc --noEmit clean for changed paths
  • eslint clean for changed files
  • npm run build:dev succeeds
  • Login as admin -> /dashboard -> Log Tracing card visible, navigates to /dashboard/log-tracing
  • Hub shows two cards; clicking RealUnit navigates to /dashboard/log-tracing/realunit and shows the unchanged tracing screen
  • Clicking All Logs navigates to /dashboard/log-tracing/all and renders summary cards + recent entries (requires feat(gs): add ALL_TRACES template for generic log queries api#3757 deployed)
  • Switch time ranges (1h / 6h / 24h) on /all -> table reloads and refresh indicator updates
  • Severity badges color-coded (verbose/info gray, warn orange, error/critical red)
  • During live refresh on RealUnit screen, chart animates smoothly between updates

Adds a stacked area chart binning trace counts into time buckets
(2xx/3xx green, 4xx/5xx red). Bin width scales with the selected
range: 30 s for 15 min, 1 min for 1 h, 5 min for 6 h, 15 min for 24 h.
Uses ApexCharts via the existing react-apexcharts integration, same
pattern as dashboard-financial-* charts. Animations are disabled
because the chart re-renders every 5 s with the dashboard refresh.
- useMemo deps reference props directly (windowMs/endTime/binMs), with
  startTime derived inside the memo bodies — cleaner intent than
  listing a derived value in the dep array.
- Drop the Date.now() fallback in the screen; render the chart only
  once lastFetched is set.
Switches the RealUnit tracing dashboard to the dark dfxBlue palette
to match dashboard/financial/overview:

- container: bg-dfxBlue-800, white text
- cards: bg-dfxBlue-700 (reusing the shared SummaryCard with dark prop)
- range buttons: blue (#3b82f6) for selected, dark navy (#082948) otherwise
- table borders and labels: #0A355C / #9AA5B8
- area chart: theme.mode='dark' + matching grid color
- the chart's own wrapper is dropped; the screen now wraps it so the
  border-radius/padding stays consistent with the other dark cards.
At 5s the dashboard generates ~720 /gs/debug/logs audit-log entries
per hour, each of which matches `message contains "RealUnitTrace"`
(the messageFilter is embedded verbatim in the audit) and crowds
real traces out of the 200-row TRACES_BY_MESSAGE response. Polling
at 60s reduces that to ~60/h, well below the real-trace volume —
no API-side filter needed.
Restructure file naming ahead of adding generic log views:
- src/screens/dashboard-realunit-tracing.screen.tsx
    -> src/screens/dashboard-log-tracing-realunit.screen.tsx
- src/hooks/realunit-tracing.hook.ts -> src/hooks/log-tracing.hook.ts
- src/components/dashboard/realunit-trace-time-chart.tsx
    -> src/components/dashboard/log-trace-time-chart.tsx

Identifier renames:
- useRealunitTracing -> useLogTracing
- RealUnitTraceTimeChart -> LogTraceTimeChart
- DashboardRealunitTracingScreen -> DashboardLogTracingRealunitScreen

getRealunitTraces stays — it remains the RealUnit-specific fetcher.
Restructure the tracing dashboard around a hub URL with two sub-views:
- /dashboard/log-tracing — hub screen with two cards (RealUnit, All Logs)
- /dashboard/log-tracing/realunit — existing RealUnit tracing screen
- /dashboard/log-tracing/all — new view over all API trace entries

Hook expansion in log-tracing.hook.ts:
- getAllTraces(hours) — fetches the 'all-traces' template
- GenericTrace interface + parseGenericTrace() — extracts [Context] prefix
  and severity from generic trace rows

The All-Logs screen mirrors the RealUnit screen's container, toolbar, and
refresh patterns (60s refresh, cancellable, dark theme); time ranges
limited to 1h/6h/24h, and the view shows 4 summary cards plus a 50-row
recent-entries table grouped by severity and context.

The /dashboard hub card 'RealUnit Tracing' is renamed to 'Log Tracing'
and now navigates to the new hub URL.
…ly guard

The 5s-refresh cadence the disable-animations note referred to no longer
exists — the chart now refreshes every 60s, so smooth transitions feel
correct and aren't perceived as jitter.

Document the choice of useAdminGuard() in the RealUnit screen: backend
/gs/debug/logs is RoleGuard(DEBUG), and additionalRoles only grants
ADMIN+SUPER_ADMIN — not REALUNIT — so admin-only matches the API gate.
@TaprootFreak TaprootFreak changed the title feat(dashboard): RealUnit tracing calls-over-time chart feat(dashboard): log-tracing hub with RealUnit + All-Logs views May 23, 2026
The /gs/debug/logs all-traces template projects the column as
operation_Id (snake_case), but the screen was looking it up as
operationId. Made every GenericTrace silently empty for that field.
@TaprootFreak TaprootFreak marked this pull request as ready for review May 23, 2026 17:09
@TaprootFreak TaprootFreak requested a review from davidleomay as a code owner May 23, 2026 17:09
…aming

- Adds /dashboard/log-tracing, /log-tracing/realunit, /log-tracing/all
  that this PR introduces.
- Adds /dashboard/financial/overview that was missing pre-existing.
- Renames the "Financial Dashboard" section to "Dashboard" since it
  now covers non-financial sub-pages.
- Cross-checked against App.tsx; flags any other gaps in the output.
@TaprootFreak TaprootFreak merged commit 683c399 into develop Jun 1, 2026
6 checks passed
@TaprootFreak TaprootFreak deleted the feature/realunit-tracing-time-chart branch June 1, 2026 20:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants