This repository has been archived by the owner on Oct 18, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
315: introduce stats route r=MarinPostma a=MarinPostma This PR introduces the `GET /v1/stats` route that return the total amount of rows read/written by an instance: ``` { "rows_read_count": 0, "rows_written_count": 0 } ``` The number of rows read/written persists accross restarts, thanks to a sync loop that flushes the information to disk about every 5s. Co-authored-by: ad hoc <[email protected]> Co-authored-by: Piotr Sarna <[email protected]>
- Loading branch information
Showing
9 changed files
with
575 additions
and
373 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
use hyper::{Body, Response}; | ||
use serde::Serialize; | ||
|
||
use crate::stats::Stats; | ||
|
||
#[derive(Serialize)] | ||
struct StatsResponse { | ||
rows_read_count: usize, | ||
rows_written_count: usize, | ||
} | ||
|
||
pub fn handle_stats(stats: &Stats) -> Response<Body> { | ||
let resp = StatsResponse { | ||
rows_read_count: stats.rows_read(), | ||
rows_written_count: stats.rows_written(), | ||
}; | ||
|
||
let payload = serde_json::to_vec(&resp).unwrap(); | ||
Response::builder() | ||
.header("Content-Type", "application/json") | ||
.body(Body::from(payload)) | ||
.unwrap() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.