Skip to content

Add dashboard diagnostics#56

Merged
Kirari04 merged 1 commit into
devfrom
feature/dashboard-diagnostics
Jun 16, 2026
Merged

Add dashboard diagnostics#56
Kirari04 merged 1 commit into
devfrom
feature/dashboard-diagnostics

Conversation

@Kirari04

@Kirari04 Kirari04 commented Jun 16, 2026

Copy link
Copy Markdown
Owner

Summary

  • add a management diagnostics RPC for proxy outcome/status/failure analysis
  • store request method, host, and redacted path prefix for proxy events
  • add exact status-code rollups and diagnostics UI page

Tests

  • go test ./internal/db ./internal/server
  • go test ./...
  • bun run typecheck
  • bun test src/lib/dashboardStats.test.ts

Note: npm test was not run because web/management has no npm test script.

Summary by CodeRabbit

  • New Features
    • Added Diagnostics dashboard page to view proxy request metrics, status code distribution, and failure analysis.
    • Enhanced proxy request event tracking with HTTP method, host, and path prefix information.
    • Added aggregated analytics for improved observability of proxy request failures across multiple error dimensions.

@coderabbitai

coderabbitai Bot commented Jun 16, 2026

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

Pull request was closed or merged during review

📝 Walkthrough

Walkthrough

Adds a GetDashboardDiagnostics RPC and backing infrastructure: proxy_request_events gains method, host, and path_prefix columns; a new proxy_request_status_rollup_minutes table stores per-minute status-code aggregates; the rollup write/backfill/cleanup paths are extended; and a new Diagnostics management UI page surfaces problem-dimension breakdowns and recent error samples.

Changes

Dashboard Diagnostics Feature

Layer / File(s) Summary
Schema: proxy_request_events columns, status rollup table, and partial index
sql/schema.sql, internal/db/models.go
Adds method, host, path_prefix to proxy_request_events; creates proxy_request_status_rollup_minutes with composite PK (bucket_unix_millis, status_code); adds idx_proxy_request_events_recent_problem partial index. Adds ProxyRequestStatusRollupMinute model and new fields on ProxyRequestEvent.
SQLite migrations and observability rollup backfill
internal/db/connection.go, internal/db/connection_test.go
Updates migrate() to ALTER existing tables with new columns and create the new index; extends migrateObservabilityRollups() to create and conditionally backfill proxy_request_status_rollup_minutes; updates migrateProxyObservabilityTargetOnly() to clear and rebuild the status rollup table. Updates migration tests for new columns, index, and table assertions.
SQL queries: insert updates, status rollup upsert/backfill, problem rollups, and samples
sql/query.sql
Updates InsertProxyRequestEvent/At with new columns; adds UpsertProxyRequestStatusRollupMinute, BackfillProxyRequestStatusRollupMinutesRange, DeleteProxyRequestStatusRollupsBefore, ListProxyStatusCodeRollupsSince, five ListProblemProxy*RollupsSince variants, and ListRecentProxyProblemSamplesSince.
DB models, Querier interface, and generated query.sql.go
internal/db/querier.go, internal/db/query.sql.go
Extends the Querier interface and generates Queries implementations for all new operations: backfill, delete, insert (with new fields), five problem-dimension rollup listings, status-code rollup listing, recent-samples query, and status rollup upsert.
Protobuf: GetDashboardDiagnostics RPC and message types
proto/p2pstream/v1/management.proto
Adds GetDashboardDiagnosticsRequest, GetDashboardDiagnosticsResponse, DashboardDiagnosticsOutcomeSummary, DashboardStatusCodeSummary, and DashboardDiagnosticsSample messages; registers GetDashboardDiagnostics on AgentManagementService.
proxyRequestContext extraction and event recorder refactor
internal/server/dashboard.go
Introduces proxyRequestContext struct and proxyRequestContextFromHTTP() to normalize method/host/path from *http.Request; refactors existing recordProxyRequestEvent* functions to delegate to new ...AndContext variants; persists Method/Host/PathPrefix in the insert path.
Rollup write path: status rollup upsert and backfill
internal/server/observability_rollup.go
Extends insertProxyRequestEventWithRollups to transactionally upsert UpsertProxyRequestStatusRollupMinute; changes proxyRequestRollupParams to return a third status params value; extends backfillObservabilityRollupBatch to call BackfillProxyRequestStatusRollupMinutesRange.
Request context threading through proxy pipeline stages and cache
internal/server/public_proxy_pipeline.go, internal/server/public_routing.go, internal/server/public_cache.go
Adds RequestContext to publicProxyContext, initializes it via proxyRequestContextFromHTTP; updates ACME/WAF/rate-limit/route-error stages and redirect/static/cache-hit recording paths to pass ctx.RequestContext to ...AndContext recorder variants.
GetDashboardDiagnostics RPC handler and response builders
internal/server/dashboard.go
Implements GetDashboardDiagnostics with auth/DB validation, window-to-duration mapping, sample-limit clamping, multi-rollup queries, and response construction; extends cleanupObservability to call DeleteProxyRequestStatusRollupsBefore.
Backend tests: migration, rollup, diagnostics RPC, and cleanup
internal/server/dashboard_test.go, tests/integration/observability_test.go
Adds TestGetDashboardDiagnosticsRequiresAuth, TestGetDashboardDiagnosticsAggregatesStatusesFailuresAndSamples, TestCleanupObservabilityDeletesOldExactStatusRollups; adds insertDiagnosticsProxyEvent and test helpers; extends status rollup and integration schema tests.
Frontend dashboardStats: nonSuccess metrics and formatPathPrefix
web/management/src/lib/dashboardStats.ts, web/management/src/lib/dashboardStats.test.ts
Adds nonSuccess to DashboardTrafficBucketView; adds nonSuccessRequests, proxyFailureRequests, nonSuccessRate, and formatPathPrefix helpers; removes errorRate; updates tests for new API surface.
Diagnostics.vue page: component, template, styles, and routing
web/management/src/views/Diagnostics.vue, web/management/src/router.ts, web/management/src/App.vue
Adds the Diagnostics SFC with reactive loading, derived outcome/status/dimension views, stale-response guard, summary strip, status-code bars, dimension panels, recent-samples table, and scoped CSS; registers /diagnostics route and nav tab.
Overview.vue: non-success display and diagnostics link
web/management/src/views/Overview.vue
Replaces error-based bucket visuals and hotspot column with non-success helpers; adds a "View diagnostics" router link in the Problem Signals panel header; updates empty-state and column label copy.

Sequence Diagram(s)

sequenceDiagram
  participant Browser
  participant DiagnosticsVue
  participant AgentManagementService
  participant GetDashboardDiagnostics
  participant SQLiteQuerier

  Browser->>DiagnosticsVue: mount / window change
  DiagnosticsVue->>AgentManagementService: getDashboardDiagnostics(window, sampleLimit)
  AgentManagementService->>GetDashboardDiagnostics: auth check + DB precondition
  GetDashboardDiagnostics->>SQLiteQuerier: ListProxyStatusCodeRollupsSince
  GetDashboardDiagnostics->>SQLiteQuerier: ListProblemProxy*RollupsSince (×5 dimensions)
  GetDashboardDiagnostics->>SQLiteQuerier: ListRecentProxyProblemSamplesSince
  SQLiteQuerier-->>GetDashboardDiagnostics: rollup rows + sample rows
  GetDashboardDiagnostics-->>AgentManagementService: GetDashboardDiagnosticsResponse
  AgentManagementService-->>DiagnosticsVue: response
  DiagnosticsVue-->>Browser: render outcome strip, status bars, dimension panels, samples table
Loading
sequenceDiagram
  participant HTTPRequest
  participant publicProxyContext
  participant proxyRequestContextFromHTTP
  participant recordProxyRequestEventAndContext
  participant insertProxyRequestEventWithRollups
  participant proxy_request_events
  participant proxy_request_status_rollup_minutes

  HTTPRequest->>publicProxyContext: newPublicProxyContext(r)
  publicProxyContext->>proxyRequestContextFromHTTP: r
  proxyRequestContextFromHTTP-->>publicProxyContext: {Method, Host, PathPrefix}
  publicProxyContext->>recordProxyRequestEventAndContext: ctx.RequestContext
  recordProxyRequestEventAndContext->>insertProxyRequestEventWithRollups: event + context params
  insertProxyRequestEventWithRollups->>proxy_request_events: INSERT method, host, path_prefix
  insertProxyRequestEventWithRollups->>proxy_request_status_rollup_minutes: UPSERT per-minute status rollup
Loading

Estimated code review effort

🎯 5 (Critical) | ⏱️ ~120 minutes

Possibly related PRs

  • Kirari04/p2pstream#38: Introduced the foundational observability rollup pipeline (insertProxyRequestEventWithRollups, backfill/cleanup logic) that this PR directly extends with status-code rollup writes.
  • Kirari04/p2pstream#47: Introduced migrateObservabilityRollups / migrateProxyObservabilityTargetOnly and route-target-based observability that this PR modifies to add the new proxy_request_status_rollup_minutes table and reset handling.

Poem

🐇 Hop, hop — a new Diagnostics page appears!
Status codes roll up by the minute, banishing fears.
Method, host, and path now live in every event row,
Problem dimensions charted wherever errors flow.
The rabbit checks the rollup, sees non-success defined —
And links "View diagnostics" for the curious of mind! 🎉

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Add dashboard diagnostics' directly describes the main feature added across the changeset—a comprehensive diagnostics capability including RPC endpoint, UI page, database schema updates, and status-code rollups.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/dashboard-diagnostics

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@Kirari04 Kirari04 merged commit a92fb66 into dev Jun 16, 2026
5 of 6 checks passed
@Kirari04 Kirari04 deleted the feature/dashboard-diagnostics branch June 16, 2026 16:13
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.

1 participant