Skip to content

Add RPC latency data to Solana Data dashboard#1656

Open
h4rkl wants to merge 15 commits into
mainfrom
add-rpc-data
Open

Add RPC latency data to Solana Data dashboard#1656
h4rkl wants to merge 15 commits into
mainfrom
add-rpc-data

Conversation

@h4rkl

@h4rkl h4rkl commented Jul 8, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • add a server-side Grafana Cloud Prometheus reader for RPC latency metrics
  • expose a cached /api/rpc/data route for avg latency and hourly p99 latency
  • add an RPC tab to /data with method/region filters, provider filtering, avg latency bars, and p99 time series
  • add server-only RPC latency env placeholders and Turbo env passthrough

Validation

  • pnpm --filter solana-com exec tsc --noEmit --project tsconfig.json
  • pnpm --filter solana-com test -- src/__tests__/components/data/solana-data-dashboard.test.ts src/__tests__/components/data/time-series-chart.test.ts src/__tests__/components/data/time-series-chart-legend.test.tsx
  • pnpm --filter solana-com lint (passes with existing unrelated warnings)
  • local browser smoke test on /data?tab=rpc

h4rkl added 3 commits July 8, 2026 16:51
- Introduced new environment variables for Grafana Cloud Prometheus data source.
- Added RPC region and method options to the data configuration.
- Implemented new charts for average and P99 latency metrics in the Solana data dashboard.
- Enhanced the dashboard controls to include RPC method and region filters.
- Created a new API route for fetching RPC latency data from Grafana.
- Developed server-side logic to query Prometheus for RPC latency metrics.
- Updated internationalization files to support new RPC-related labels and descriptions.
@h4rkl h4rkl requested review from ZYJLiu and jacobcreech as code owners July 8, 2026 05:11
@vercel

vercel Bot commented Jul 8, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
solana-com Ready Ready Preview, Comment Jul 14, 2026 10:21am
5 Skipped Deployments
Project Deployment Actions Updated (UTC)
solana-com-accelerate Skipped Skipped Jul 14, 2026 10:21am
solana-com-breakpoint-2 Skipped Skipped Jul 14, 2026 10:21am
solana-com-docs Skipped Skipped Jul 14, 2026 10:21am
solana-com-media Skipped Skipped Jul 14, 2026 10:21am
templates Skipped Skipped Jul 14, 2026 10:21am

Request Review

@greptile-apps

greptile-apps Bot commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR adds a new RPC tab to the Solana Data dashboard, backed by a server-side Grafana Cloud Prometheus reader (/lib/rpc/server.ts) that fetches avg/P50/P95/P99 latency and success-rate metrics, exposed through a cached /api/rpc/data route.

  • Server module (server.ts): validates env config, enforces HTTPS-only base URL, whitelists all PromQL label values, and escapes label strings before query construction; dual-layer caching (Next.js unstable_cache + in-flight Map deduplication) keeps Grafana request volume low.
  • Dashboard (solana-data-dashboard.tsx): adds method/region/infra filter selects, a ranked provider bar chart for avg latency, lowerIsBetter KPI coloring, and per-tab SWR refresh cadence (60 s for RPC vs twice-daily for other tabs).
  • Chart updates (time-series-chart.tsx): adds hourly time-granularity formatting, whole-number Percent axis ticks with domain clamping, and millisecond value formatting — each covered by new unit tests.

Confidence Score: 5/5

Safe to merge; all external inputs are whitelisted before reaching Prometheus, HTTPS enforcement is in place, and the error handling surfaces clean 502/503 responses without leaking credentials.

The new Prometheus reader is well-guarded (HTTPS-only URL validation, full allowlist on every PromQL label, label-value escaping), the caching strategy is sound, and the existing test suite was extended to cover the new query-building logic and chart utilities. The two findings are quality concerns about an unguarded fetch that could hang under a slow upstream and a KPI delta that is structurally always zero for the instant-query avg-latency card — neither affects data correctness or security.

apps/web/src/lib/rpc/server.ts (fetch timeout) and the avg-latency section of solana-data-dashboard.tsx (KPI delta display) are worth a second look before shipping.

Important Files Changed

Filename Overview
apps/web/src/lib/rpc/server.ts New server-only module querying Grafana Cloud Prometheus for RPC latency; solid input validation, HTTPS enforcement, and PromQL label escaping — missing fetch timeout on the 5-way concurrent Prometheus query.
apps/web/src/app/api/rpc/data/route.ts New Next.js route exposing cached RPC latency data with dual-layer caching (unstable_cache + in-flight Map deduplication), clear cache-control headers, and dev-only error detail gating.
apps/web/src/app/[locale]/data/solana-data-dashboard.tsx Adds RPC tab with method/region/infra filters, provider bar chart, and updated KPI logic; avg-latency KPI card always shows 0% delta because the instant-query series has only one data point.
apps/web/src/app/[locale]/data/data-config.ts Adds RPC filter options, provider colors (Alchemy, Helius, QuickNode, Triton), and five RPC chart definitions; logic for option normalisation and source-value lookups is clean.
apps/web/src/app/[locale]/data/time-series-chart.tsx Adds hourly time-granularity formatting, Percent domain clamping, whole-number tick generation, and millisecond value formatting; all new logic is well-tested.
packages/i18n/messages/web/en/common.json Adds RPC tab, filter control labels, KPI tooltip variants, footer strings, and chart captions — all keys are consistent with the code that references them.
turbo.json Adds the two new RPC Grafana env vars to the Turbo passthrough list so they are available during builds.

Sequence Diagram

%%{init: {'theme': 'neutral'}}%%
sequenceDiagram
    participant Browser
    participant SWR as SWR Client (60 s poll)
    participant Route as /api/rpc/data
    participant Cache as unstable_cache + in-flight Map
    participant Grafana as Grafana Cloud Prometheus

    Browser->>SWR: mount RPC tab
    SWR->>Route: "GET /api/rpc/data?method=…&region=…&infra=…"
    Route->>Route: getRpcLatencyConfig() — validate env + HTTPS URL
    Route->>Cache: getCachedRpcLatencyData(config, options)
    alt cache hit (≤60 s)
        Cache-->>Route: cached RpcLatencyData
    else cache miss
        Cache->>Grafana: Promise.all — 5× Prometheus queries
        Grafana-->>Cache: PrometheusResponse[]
        Cache->>Cache: "normalise timestamps & values → MetricRow[]"
        Cache-->>Route: RpcLatencyData
    end
    Route-->>SWR: "200 JSON + Cache-Control s-maxage=60"
    SWR-->>Browser: rows → filterRowsForCharts → buildSeries
    Browser->>Browser: KpiGrid + ProviderBarChart + TimeSeriesChart
Loading
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
sequenceDiagram
    participant Browser
    participant SWR as SWR Client (60 s poll)
    participant Route as /api/rpc/data
    participant Cache as unstable_cache + in-flight Map
    participant Grafana as Grafana Cloud Prometheus

    Browser->>SWR: mount RPC tab
    SWR->>Route: "GET /api/rpc/data?method=…&region=…&infra=…"
    Route->>Route: getRpcLatencyConfig() — validate env + HTTPS URL
    Route->>Cache: getCachedRpcLatencyData(config, options)
    alt cache hit (≤60 s)
        Cache-->>Route: cached RpcLatencyData
    else cache miss
        Cache->>Grafana: Promise.all — 5× Prometheus queries
        Grafana-->>Cache: PrometheusResponse[]
        Cache->>Cache: "normalise timestamps & values → MetricRow[]"
        Cache-->>Route: RpcLatencyData
    end
    Route-->>SWR: "200 JSON + Cache-Control s-maxage=60"
    SWR-->>Browser: rows → filterRowsForCharts → buildSeries
    Browser->>Browser: KpiGrid + ProviderBarChart + TimeSeriesChart
Loading

Reviews (7): Last reviewed commit: "feat: enhance percent axis handling with..." | Re-trigger Greptile

Comment thread apps/web/src/app/[locale]/data/data-config.ts Outdated
Comment thread apps/web/src/app/[locale]/data/solana-data-dashboard.tsx Outdated
Comment thread apps/web/src/lib/rpc/server.ts Outdated
…dd-rpc-data

# Conflicts:
#	apps/web/.env.example
#	turbo.json
@vercel vercel Bot temporarily deployed to Preview – solana-com-docs July 14, 2026 09:55 Inactive
@vercel vercel Bot temporarily deployed to Preview – templates July 14, 2026 09:55 Inactive
@vercel vercel Bot temporarily deployed to Preview – solana-com-media July 14, 2026 09:55 Inactive
@vercel vercel Bot temporarily deployed to Preview – solana-com-accelerate July 14, 2026 09:55 Inactive
@vercel vercel Bot temporarily deployed to Preview – solana-com-breakpoint-2 July 14, 2026 09:55 Inactive
@vercel vercel Bot temporarily deployed to Preview – solana-com-accelerate July 14, 2026 10:12 Inactive
@vercel vercel Bot temporarily deployed to Preview – solana-com-media July 14, 2026 10:12 Inactive
@vercel vercel Bot temporarily deployed to Preview – solana-com-breakpoint-2 July 14, 2026 10:12 Inactive
@vercel vercel Bot temporarily deployed to Preview – templates July 14, 2026 10:12 Inactive
@vercel vercel Bot temporarily deployed to Preview – solana-com-docs July 14, 2026 10:12 Inactive
@vercel vercel Bot temporarily deployed to Preview – solana-com-media July 14, 2026 10:18 Inactive
@vercel vercel Bot temporarily deployed to Preview – templates July 14, 2026 10:18 Inactive
@vercel vercel Bot temporarily deployed to Preview – solana-com-breakpoint-2 July 14, 2026 10:18 Inactive
@vercel vercel Bot temporarily deployed to Preview – solana-com-accelerate July 14, 2026 10:18 Inactive
@vercel vercel Bot temporarily deployed to Preview – solana-com-docs July 14, 2026 10:18 Inactive
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