-
Notifications
You must be signed in to change notification settings - Fork 2
chore(NET-112): Add http api, streams and query related metrics to HotblockDB #48
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR adds comprehensive metrics instrumentation to HotblocksDB to track HTTP API performance, stream statistics, and query execution metrics. The implementation introduces Prometheus-compatible metrics for monitoring query throughput, data transfer rates, and API endpoint usage.
Changes:
- Added HTTP middleware to track request metrics including status codes, time-to-first-byte, and endpoint-specific labels
- Implemented stream and query statistics tracking with histograms for bytes, blocks, chunks, and throughput rates
- Integrated metrics reporter that periodically updates active query gauges
Reviewed changes
Copilot reviewed 9 out of 10 changed files in this pull request and generated 13 comments.
Show a summary per file
| File | Description |
|---|---|
| crates/hotblocks/src/metrics.rs | Added new metric definitions for HTTP, stream, and query tracking; reorganized registry with lazy_static |
| crates/hotblocks/src/query/executor.rs | Added metrics reporter for active queries and completed query counter |
| crates/hotblocks/src/query/running.rs | Implemented RunningQueryStats to track chunks, blocks, and bytes processed per query |
| crates/hotblocks/src/query/response.rs | Added QueryStreamStats to track stream metrics with time limit support and metrics reporting on drop |
| crates/hotblocks/src/query/service.rs | Exposed spawn_metrics_reporter method for periodic metrics updates |
| crates/hotblocks/src/api.rs | Added middleware for HTTP request tracking, ResponseWithMetadata pattern for endpoint labeling, and 404 handler |
| crates/hotblocks/src/cli.rs | Initialize metrics reporter with 5-second interval |
| crates/hotblocks/src/dataset_config.rs | Added clarifying comments to RetentionConfig variants |
| crates/hotblocks/Cargo.toml | Added lazy_static and tower-http dependencies |
| Cargo.lock | Updated lock file with new dependencies |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
crates/hotblocks/src/api.rs
Outdated
| } | ||
|
|
||
| #[derive(Clone)] | ||
| pub struct Labels(Vec<(String, String)>); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BTW, I realized that making it Vec<(&'static str, String)> usually works and simplifies syntax. No call for action here, just for the future
What is this PR about?
Closes: https://linear.app/sqd-ai/issue/NET-112/add-metrics-to-hotblocksdb
PR adds metrics for main http endpoints, as well as stream/query related information for HotblocksDB.
Metrics example from the local run
Some of the style changes may appear excessive due to rustfmt not having been run previously.