This is an automated email from the ASF dual-hosted git repository.

zuston pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-uniffle.git


The following commit(s) were added to refs/heads/master by this push:
     new 23e26fcee [#1293] feat(rust): Add total_read_data metric (#1298)
23e26fcee is described below

commit 23e26fcee695b54f291649a42c0e1e5b4d9cd9b4
Author: wenlongbrother <[email protected]>
AuthorDate: Wed Nov 8 15:18:04 2023 +0800

    [#1293] feat(rust): Add total_read_data metric (#1298)
    
    ### What changes were proposed in this pull request?
    
    Add total_received_data metric
    
    ### Why are the changes needed?
    
    Currently, the total_received_data metric has been introduced, the 
total_read_data is also necessary
    
    ### Does this PR introduce _any_ user-facing change?
    
    No.
    
    ### How was this patch tested?
    
    Needn't
    
    ---------
    
    Co-authored-by: 蒋文龙 <[email protected]>
---
 rust/experimental/server/src/app.rs    | 13 +++++++++++--
 rust/experimental/server/src/metric.rs |  7 +++++++
 2 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/rust/experimental/server/src/app.rs 
b/rust/experimental/server/src/app.rs
index 9b1596845..43d9a32aa 100644
--- a/rust/experimental/server/src/app.rs
+++ b/rust/experimental/server/src/app.rs
@@ -19,7 +19,7 @@ use crate::config::Config;
 use crate::error::WorkerError;
 use crate::metric::{
     GAUGE_APP_NUMBER, TOTAL_APP_NUMBER, 
TOTAL_HUGE_PARTITION_REQUIRE_BUFFER_FAILED,
-    TOTAL_RECEIVED_DATA, TOTAL_REQUIRE_BUFFER_FAILED,
+    TOTAL_READ_DATA, TOTAL_RECEIVED_DATA, TOTAL_REQUIRE_BUFFER_FAILED,
 };
 
 use crate::readable_size::ReadableSize;
@@ -183,7 +183,16 @@ impl App {
     }
 
     pub async fn select(&self, ctx: ReadingViewContext) -> 
Result<ResponseData, WorkerError> {
-        self.store.get(ctx).await
+        let response = self.store.get(ctx).await;
+        response.map(|data| {
+            let length = match &data {
+                ResponseData::Local(local_data) => local_data.data.len() as 
u64,
+                ResponseData::Mem(mem_data) => mem_data.data.len() as u64,
+            };
+            TOTAL_READ_DATA.inc_by(length);
+
+            data
+        })
     }
 
     pub async fn list_index(
diff --git a/rust/experimental/server/src/metric.rs 
b/rust/experimental/server/src/metric.rs
index 22c91e7db..7c1fe2792 100644
--- a/rust/experimental/server/src/metric.rs
+++ b/rust/experimental/server/src/metric.rs
@@ -35,6 +35,10 @@ pub static TOTAL_RECEIVED_DATA: Lazy<IntCounter> = 
Lazy::new(|| {
     IntCounter::new("total_received_data", "Incoming Requests").expect("metric 
should be created")
 });
 
+pub static TOTAL_READ_DATA: Lazy<IntCounter> = Lazy::new(|| {
+    IntCounter::new("total_read_data", "Reading Data").expect("metric should 
be created")
+});
+
 pub static GRPC_GET_MEMORY_DATA_TRANSPORT_TIME: Lazy<Histogram> = Lazy::new(|| 
{
     let opts = HistogramOpts::new("grpc_get_memory_data_transport_time", 
"none")
         .buckets(Vec::from(DEFAULT_BUCKETS as &'static [f64]));
@@ -201,6 +205,9 @@ fn register_custom_metrics() {
     REGISTRY
         .register(Box::new(TOTAL_RECEIVED_DATA.clone()))
         .expect("total_received_data must be registered");
+    REGISTRY
+        .register(Box::new(TOTAL_READ_DATA.clone()))
+        .expect("total_read_data must be registered");
     REGISTRY
         .register(Box::new(TOTAL_MEMORY_USED.clone()))
         .expect("total_memory_used must be registered");

Reply via email to