@@ -22,13 +22,15 @@ use serde::{Deserialize, Serialize};
22
22
23
23
#[ derive( Debug ) ]
24
24
pub struct StatsCounter {
25
+ events_ingested : AtomicU64 ,
25
26
ingestion_size : AtomicU64 ,
26
27
storage_size : AtomicU64 ,
27
28
}
28
29
29
30
impl Default for StatsCounter {
30
31
fn default ( ) -> Self {
31
32
Self {
33
+ events_ingested : AtomicU64 :: new ( 0 ) ,
32
34
ingestion_size : AtomicU64 :: new ( 0 ) ,
33
35
storage_size : AtomicU64 :: new ( 0 ) ,
34
36
}
@@ -43,13 +45,18 @@ impl PartialEq for StatsCounter {
43
45
}
44
46
45
47
impl StatsCounter {
46
- pub fn new ( ingestion_size : u64 , storage_size : u64 ) -> Self {
48
+ pub fn new ( ingestion_size : u64 , storage_size : u64 , event_ingested : u64 ) -> Self {
47
49
Self {
48
- ingestion_size : AtomicU64 :: new ( ingestion_size) ,
49
- storage_size : AtomicU64 :: new ( storage_size) ,
50
+ ingestion_size : ingestion_size. into ( ) ,
51
+ storage_size : storage_size. into ( ) ,
52
+ events_ingested : event_ingested. into ( ) ,
50
53
}
51
54
}
52
55
56
+ pub fn events_ingested ( & self ) -> u64 {
57
+ self . events_ingested . load ( Ordering :: Relaxed )
58
+ }
59
+
53
60
pub fn ingestion_size ( & self ) -> u64 {
54
61
self . ingestion_size . load ( Ordering :: Relaxed )
55
62
}
@@ -65,18 +72,24 @@ impl StatsCounter {
65
72
pub fn add_storage_size ( & self , size : u64 ) {
66
73
self . storage_size . fetch_add ( size, Ordering :: AcqRel ) ;
67
74
}
75
+
76
+ pub fn increase_event_by_one ( & self ) {
77
+ self . events_ingested . fetch_add ( 1 , Ordering :: Relaxed ) ;
78
+ }
68
79
}
69
80
70
81
/// Helper struct type created by copying stats values from metadata
71
82
#[ derive( Debug , Default , Serialize , Deserialize , Clone , Copy , PartialEq , Eq ) ]
72
83
pub struct Stats {
84
+ pub events : u64 ,
73
85
pub ingestion : u64 ,
74
86
pub storage : u64 ,
75
87
}
76
88
77
89
impl From < & StatsCounter > for Stats {
78
90
fn from ( stats : & StatsCounter ) -> Self {
79
91
Self {
92
+ events : stats. events_ingested ( ) ,
80
93
ingestion : stats. ingestion_size ( ) ,
81
94
storage : stats. storage_size ( ) ,
82
95
}
@@ -85,6 +98,6 @@ impl From<&StatsCounter> for Stats {
85
98
86
99
impl From < Stats > for StatsCounter {
87
100
fn from ( stats : Stats ) -> Self {
88
- StatsCounter :: new ( stats. ingestion , stats. storage )
101
+ StatsCounter :: new ( stats. ingestion , stats. storage , stats . events )
89
102
}
90
103
}
0 commit comments