Skip to content
This repository has been archived by the owner on Oct 31, 2024. It is now read-only.

Commit

Permalink
chore: reset and update metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
hadjiszs committed Aug 1, 2023
1 parent 51431ab commit 2ce29ca
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 3 deletions.
4 changes: 4 additions & 0 deletions crates/topos-metrics/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,19 @@ pub fn gather_metrics() -> String {
}

pub fn init_metrics() {
API_GRPC_CERTIFICATE_RECEIVED_TOTAL.reset();
P2P_EVENT_STREAM_CAPACITY_TOTAL.reset();
P2P_MESSAGE_RECEIVED_ON_GOSSIP_TOTAL.reset();
P2P_MESSAGE_RECEIVED_ON_ECHO_TOTAL.reset();
P2P_MESSAGE_RECEIVED_ON_READY_TOTAL.reset();
P2P_MESSAGE_SENT_ON_GOSSIPSUB_TOTAL.reset();
DOUBLE_ECHO_ACTIVE_TASKS_COUNT.set(0);
DOUBLE_ECHO_COMMAND_CHANNEL_CAPACITY_TOTAL.reset();
DOUBLE_ECHO_BUFFER_CAPACITY_TOTAL.reset();
DOUBLE_ECHO_CURRENT_BUFFER_SIZE.set(0);
DOUBLE_ECHO_BUFFERED_MESSAGE_COUNT.set(0);
DOUBLE_ECHO_BROADCAST_CREATED_TOTAL.reset();
DOUBLE_ECHO_BROADCAST_FINISHED_TOTAL.reset();
CERTIFICATE_RECEIVED_TOTAL.reset();
CERTIFICATE_RECEIVED_FROM_GOSSIP_TOTAL.reset();
CERTIFICATE_RECEIVED_FROM_API_TOTAL.reset();
Expand Down
1 change: 0 additions & 1 deletion crates/topos-tce-broadcast/src/double_echo/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ use std::collections::HashSet;
use tce_transport::{ProtocolEvents, ReliableBroadcastParams};
use tokio::sync::{mpsc, oneshot};
use topos_core::uci::{Certificate, CertificateId};

use topos_p2p::PeerId;
use tracing::{error, info, warn};

Expand Down
4 changes: 2 additions & 2 deletions crates/topos-tce-broadcast/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ use crate::sampler::SubscriptionsView;

#[derive(Debug, PartialEq, Eq)]
pub enum TaskStatus {
/// The task finished succesfully and broadcasted the certificate + received ready
/// The task finished successfully and broadcasted the certificate + received ready
Success,
/// The task did not finish succesfully and stopped.
/// The task did not finish successfully and stopped.
Failure,
}

Expand Down
11 changes: 11 additions & 0 deletions crates/topos-tce-broadcast/src/task_manager_channels/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ use crate::sampler::SubscriptionsView;
use crate::TaskStatus;
use crate::{constant, DoubleEchoCommand};
use task::{Task, TaskContext};
use topos_metrics::{
CERTIFICATE_RECEIVED_FROM_API_TOTAL, CERTIFICATE_RECEIVED_FROM_GOSSIP_TOTAL,
CERTIFICATE_RECEIVED_TOTAL,
};

/// The TaskManager is responsible for receiving messages from the network and distributing them
/// among tasks. These tasks are either created if none for a certain CertificateID exists yet,
Expand Down Expand Up @@ -94,6 +98,13 @@ impl TaskManager {

spawn(task.run());

CERTIFICATE_RECEIVED_TOTAL.inc();
if need_gossip {
CERTIFICATE_RECEIVED_FROM_API_TOTAL.inc();
} else {
CERTIFICATE_RECEIVED_FROM_GOSSIP_TOTAL.inc();
}

if let Some(messages) = self.buffered_messages.remove(&cert.id) {
let sink = task_context.sink.clone();
spawn(async move {
Expand Down
10 changes: 10 additions & 0 deletions crates/topos-tce-broadcast/src/task_manager_futures/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ use std::pin::Pin;
use tce_transport::{ProtocolEvents, ReliableBroadcastParams};
use tokio::{spawn, sync::mpsc};
use topos_core::uci::CertificateId;
use topos_metrics::CERTIFICATE_RECEIVED_FROM_API_TOTAL;
use topos_metrics::CERTIFICATE_RECEIVED_FROM_GOSSIP_TOTAL;
use topos_metrics::CERTIFICATE_RECEIVED_TOTAL;
use topos_metrics::DOUBLE_ECHO_ACTIVE_TASKS_COUNT;
use tracing::warn;

Expand Down Expand Up @@ -113,6 +116,13 @@ impl TaskManager {

DOUBLE_ECHO_ACTIVE_TASKS_COUNT.inc();

CERTIFICATE_RECEIVED_TOTAL.inc();
if need_gossip {
CERTIFICATE_RECEIVED_FROM_API_TOTAL.inc();
} else {
CERTIFICATE_RECEIVED_FROM_GOSSIP_TOTAL.inc();
}

entry.insert(task_context);
}
std::collections::hash_map::Entry::Occupied(_) => {},
Expand Down

0 comments on commit 2ce29ca

Please sign in to comment.