Skip to content

feat: add mempool_tx_confirmation_seconds metric by tx type - #2711

Merged
rafa-stacks merged 2 commits into
mainfrom
mempool-tx-metrics
Oct 8, 2026
Merged

rafa-stacks merged 2 commits into
mainfrom
mempool-tx-metrics

Conversation

@rafa-stacks

@rafa-stacks rafa-stacks commented Oct 7, 2026 •

Copy link
Copy Markdown
Collaborator

Adds a mempool_tx_confirmation_seconds Prometheus histogram that measures how long each tx waits between first being received into the mempool and being mined, labeled by tx type so it can be split per type in Grafana.

mempool_tx_confirmation_seconds{type="token_transfer|contract_call|smart_contract|..."}
  • Value: block_time - receipt_time in seconds, clamped to ≥ 0 to absorb clock differences between the miner and the mempool observer.
  • Type label: uses getTxTypeString, the same values as the existing mempool_tx_count{type}.
  • Buckets: 1, 2, 3, 4, 5, 7, 10, 15, 20, 30, 45, 60, 120, 300, 600, 1800, 3600, 7200, 21600. Dense below a minute, where most Nakamoto confirmations land.

@codecov

codecov Bot commented Oct 7, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Confirmation observations can omit known transactions or use unreliable receipt timestamps.

3 open findings
What changed in this PR

Adds a transaction-type confirmation-time histogram to existing mempool monitoring, using SNP receipt timestamps to improve catch-up accuracy.

Changes:

  • Preserves SNP timestamps during event ingestion.
  • Emits mined-transaction metadata after commit and records confirmation durations.
  • Adds timestamp, filtering, lag-cutoff, and replay tests.
File Description
tests/​snp/​snp-ingestion.test.ts Checks original receipt times after replay.
tests/​api/​mempool/​mempool-confirmation-metric.test.ts Tests timing helpers and ingestion behavior.
src/​event-stream/​snp-event-stream.ts Forwards SNP timestamps.
src/​event-stream/​event-server.ts Resolves and passes receipt times.
src/​env.ts Configures the observation lag cutoff.
src/​datastore/​pg-write-store.ts Collects and emits mined-transaction metadata.
src/​datastore/​pg-store-event-emitter.ts Defines the confirmation event.
src/​datastore/​helpers.ts Calculates durations and registers the histogram.
src/​datastore/​common.ts Defines confirmation metadata.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/datastore/helpers.ts Resolved
Comment thread src/datastore/pg-write-store.ts Resolved
Comment thread src/event-stream/event-server.ts Resolved
@rafa-stacks
rafa-stacks marked this pull request as ready for review October 8, 2026 18:15
@rafa-stacks
rafa-stacks merged commit 2a79079 into main Oct 8, 2026
26 checks passed
@rafa-stacks
rafa-stacks deleted the mempool-tx-metrics branch October 8, 2026 19:19

This branch was successfully deployed

1 active deployment
Production — 1f3ea75e Deployed Oct 7, 2026 by rafa-stacks via build-publish #3825
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

3 participants