Skip to content

Commit

Permalink
update metric
Browse files Browse the repository at this point in the history
  • Loading branch information
vovkman committed Aug 29, 2024
1 parent 591f84b commit 2a77d4d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 4 additions & 1 deletion rpc/src/rpc_pubsub_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ use {
},
stream_cancel::{Trigger, Tripwire},
thiserror::Error,
tokio::time::Instant,
tokio::{net::TcpStream, pin, select, sync::broadcast},
tokio_util::compat::TokioAsyncReadCompatExt,
};
Expand Down Expand Up @@ -399,11 +400,13 @@ async fn handle_connection(
Err(err) => return Err(err.into()),
},
result = broadcast_receiver.recv() => {

let time = Instant::now();
// In both possible error cases (closed or lagged) we disconnect the client.
if let Some(json) = broadcast_handler.handle(result?)? {
sender.send_text(&*json).await?;
}
let send_time = time.elapsed().as_micros();
datapoint_info!("rpc-pubsub-broadcast-receive-send-us", ("time", send_time, i64));
},
_ = &mut tripwire => {
warn!("disconnecting websocket client: shutting down");
Expand Down
5 changes: 4 additions & 1 deletion rpc/src/rpc_subscriptions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,10 @@ impl RpcNotifier {
let time = Instant::now();
let _ = self.sender.send(notification);
let send_time = time.elapsed().as_micros();
datapoint_info!("rpc-pubsub-send-time-us", ("time", send_time, i64));
datapoint_info!(
"rpc-pubsub-broadcast-send-time-us",
("time", send_time, i64)
);

inc_new_counter_info!("rpc-pubsub-messages", 1);
inc_new_counter_info!("rpc-pubsub-bytes", buf_arc.len());
Expand Down

0 comments on commit 2a77d4d

Please sign in to comment.