File tree Expand file tree Collapse file tree 2 files changed +14
-0
lines changed
Expand file tree Collapse file tree 2 files changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ use serde::Serialize;
44
55use axum:: extract:: { Path , State } ;
66use axum:: Json ;
7+ use uuid:: Uuid ;
78
89use crate :: namespace:: { MakeNamespace , NamespaceName } ;
910use crate :: replication:: FrameNo ;
@@ -13,6 +14,7 @@ use super::AppState;
1314
1415#[ derive( Serialize ) ]
1516pub struct StatsResponse {
17+ pub id : Option < Uuid > ,
1618 pub rows_read_count : u64 ,
1719 pub rows_written_count : u64 ,
1820 pub storage_bytes_used : u64 ,
@@ -25,6 +27,7 @@ pub struct StatsResponse {
2527impl From < & Stats > for StatsResponse {
2628 fn from ( stats : & Stats ) -> Self {
2729 Self {
30+ id : stats. id ( ) ,
2831 rows_read_count : stats. rows_read ( ) ,
2932 rows_written_count : stats. rows_written ( ) ,
3033 storage_bytes_used : stats. storage_bytes_used ( ) ,
Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ use std::collections::BTreeSet;
88use tokio:: io:: AsyncWriteExt ;
99use tokio:: task:: JoinSet ;
1010use tokio:: time:: Duration ;
11+ use uuid:: Uuid ;
1112
1213use crate :: namespace:: NamespaceName ;
1314use crate :: replication:: FrameNo ;
@@ -56,6 +57,8 @@ pub struct Stats {
5657 #[ serde( skip) ]
5758 namespace : NamespaceName ,
5859
60+ #[ serde( default ) ]
61+ id : Option < Uuid > ,
5962 #[ serde( default ) ]
6063 rows_written : AtomicU64 ,
6164 #[ serde( default ) ]
@@ -93,6 +96,10 @@ impl Stats {
9396 Stats :: default ( )
9497 } ;
9598
99+ if this. id . is_none ( ) {
100+ this. id = Some ( Uuid :: new_v4 ( ) ) ;
101+ }
102+
96103 this. namespace = namespace;
97104 let this = Arc :: new ( this) ;
98105
@@ -226,6 +233,10 @@ impl Stats {
226233 counter ! ( "libsql_server_query_rows_written" , rows_written) ;
227234 counter ! ( "libsql_server_query_mem_used" , mem_used) ;
228235 }
236+
237+ pub fn id ( & self ) -> Option < Uuid > {
238+ self . id . clone ( )
239+ }
229240}
230241
231242async fn spawn_stats_persist_thread ( stats : Weak < Stats > , path : PathBuf ) -> anyhow:: Result < ( ) > {
You can’t perform that action at this time.
0 commit comments