Skip to content

Metrics/TPS pipeline: code-review fixes + TPS unit tests#100

Merged
muhammetselimfe merged 2 commits into
mainfrom
dev
Jun 16, 2026
Merged

Metrics/TPS pipeline: code-review fixes + TPS unit tests#100
muhammetselimfe merged 2 commits into
mainfrom
dev

Conversation

@muhammetselimfe

Copy link
Copy Markdown
Collaborator

Summary

Addresses the findings from the high-effort code review of the metrics/TPS pipeline, plus unit tests for the new TPS derivation.

Fixes

  • No duplicate API call: TPS is now derived from the daily txCount already stored by txCountService instead of re-fetching /metrics/txCount per chain per cron cycle.
  • Shared infra: cumulativeTxCount now uses createMetricService; tpsService no longer carries its own copy of the RateLimiter / fetch-retry loop (~400 lines removed).
  • Intraday TPS: the elapsed-seconds denominator is floored to 1h, so the in-progress day bucket can't spike on a tiny window or divide by zero at midnight; completed days (full 86400s window) are unaffected.
  • Cron observability: the per-chain cron now inspects each metric update's {success} result and reports the chain as failed instead of always logging success.
  • Concurrency: independent per-chain metric updates run concurrently; TPS derives after txCount is fetched.
  • Health probe: /health/dependencies now reports a 5xx upstream as degraded (503) rather than reachable.
  • Stale script: initWeeklyData.js calls updateWeeklyData() (the prior method name no longer existed).

Tests

  • New tests/tpsDerivation.test.js exercises the real tpsService.updateTpsData against mocked models: full-day division, the in-progress denominator floor (spike guard), skipping future/non-numeric rows, the empty no-op result, and the failure-result-not-throw path.

Testing

  • Full suite green: 14 suites, 200 tests.

🤖 Generated with Claude Code

muhammetselimfe and others added 2 commits June 15, 2026 19:46
- Derive TPS from the daily txCount already stored by txCountService
  instead of re-fetching /metrics/txCount, eliminating a duplicate API
  call per chain per cron cycle.
- Fold tpsService onto the shared metric infrastructure: cumulativeTxCount
  now uses createMetricService, and tpsService no longer carries its own
  copy of the RateLimiter / fetch-retry loop.
- Floor the TPS denominator (>= 1h) so the in-progress day bucket can't
  spike on a tiny window or divide by zero at midnight; past full days are
  unaffected.
- Cron now inspects each metric update's {success} result and reports the
  chain as failed instead of always logging success.
- Run the independent per-chain metric updates concurrently; derive TPS
  after txCount is fetched.
- /health/dependencies now reports a 5xx upstream as 'degraded' (503)
  rather than 'reachable'.
- initWeeklyData.js calls updateWeeklyData() (the prior method name no
  longer existed).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Covers tpsService.updateTpsData against mocked models: full-day division,
the in-progress day denominator floor (no spike), skipping future
timestamps and non-numeric values, the empty no-op result, and the
failure-result-not-throw path. Uses the real service (does not pull in
the global tpsService mock from setup.js).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@muhammetselimfe muhammetselimfe merged commit cef8890 into main Jun 16, 2026
2 checks passed
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