mirror of
https://github.com/0glabs/0g-storage-node.git
synced 2025-01-30 08:45:17 +00:00
Add metrics for completed file sync
This commit is contained in:
parent
47a0e776bd
commit
914fc785de
8
node/sync/src/controllers/metrics.rs
Normal file
8
node/sync/src/controllers/metrics.rs
Normal file
@ -0,0 +1,8 @@
|
||||
use std::sync::Arc;
|
||||
|
||||
use metrics::{register_timer, Timer};
|
||||
|
||||
lazy_static::lazy_static! {
|
||||
pub static ref SERIAL_SYNC_FILE_COMPLETED: Arc<dyn Timer> = register_timer("sync_controllers_serial_sync_file_completed");
|
||||
pub static ref SERIAL_SYNC_CHUNKS_COMPLETED: Arc<dyn Timer> = register_timer("sync_controllers_serial_sync_chunks_completed");
|
||||
}
|
@ -1,3 +1,4 @@
|
||||
mod metrics;
|
||||
mod peers;
|
||||
mod serial;
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
use crate::context::SyncNetworkContext;
|
||||
use crate::controllers::peers::{PeerState, SyncPeers};
|
||||
use crate::controllers::{FileSyncGoal, FileSyncInfo};
|
||||
use crate::controllers::{metrics, FileSyncGoal, FileSyncInfo};
|
||||
use crate::{Config, InstantWrapper};
|
||||
use file_location_cache::FileLocationCache;
|
||||
use libp2p::swarm::DialError;
|
||||
@ -311,15 +311,15 @@ impl SerialSyncController {
|
||||
.peers
|
||||
.add_new_peer_with_config(peer_id, addr.clone(), shard_config)
|
||||
{
|
||||
info!(%self.tx_seq, %peer_id, %addr, "Found new peer");
|
||||
debug!(%self.tx_seq, %peer_id, %addr, "Found new peer");
|
||||
true
|
||||
} else {
|
||||
// e.g. multiple `AnnounceFile` messages propagated
|
||||
debug!(%self.tx_seq, %peer_id, %addr, "Found an existing peer");
|
||||
trace!(%self.tx_seq, %peer_id, %addr, "Found an existing peer");
|
||||
false
|
||||
}
|
||||
} else {
|
||||
debug!(%self.tx_seq, %peer_id, %addr, "Found peer without shard config");
|
||||
info!(%self.tx_seq, %peer_id, %addr, "Found peer without shard config");
|
||||
false
|
||||
}
|
||||
}
|
||||
@ -406,7 +406,6 @@ impl SerialSyncController {
|
||||
}
|
||||
|
||||
pub async fn on_response(&mut self, from_peer_id: PeerId, response: ChunkArrayWithProof) {
|
||||
debug!(%self.tx_seq, %from_peer_id, "Received RPC response");
|
||||
if self.handle_on_response_mismatch(from_peer_id) {
|
||||
return;
|
||||
}
|
||||
@ -511,6 +510,7 @@ impl SerialSyncController {
|
||||
// completed to download chunks
|
||||
if !self.goal.is_all_chunks() {
|
||||
self.state = SyncState::Completed;
|
||||
metrics::SERIAL_SYNC_CHUNKS_COMPLETED.update_since(self.since.0);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -523,6 +523,7 @@ impl SerialSyncController {
|
||||
Ok(true) => {
|
||||
info!(%self.tx_seq, "Succeeded to finalize file");
|
||||
self.state = SyncState::Completed;
|
||||
metrics::SERIAL_SYNC_FILE_COMPLETED.update_since(self.since.0);
|
||||
}
|
||||
Ok(false) => {
|
||||
warn!(?self.tx_id, %self.tx_seq, "Transaction reverted during finalize_tx");
|
||||
|
@ -68,10 +68,10 @@ impl Default for Config {
|
||||
// serial sync config
|
||||
max_chunks_to_request: 2 * 1024,
|
||||
max_request_failures: 5,
|
||||
peer_connect_timeout: Duration::from_secs(5),
|
||||
peer_disconnect_timeout: Duration::from_secs(5),
|
||||
peer_find_timeout: Duration::from_secs(5),
|
||||
peer_chunks_download_timeout: Duration::from_secs(5),
|
||||
peer_connect_timeout: Duration::from_secs(15),
|
||||
peer_disconnect_timeout: Duration::from_secs(15),
|
||||
peer_find_timeout: Duration::from_secs(30),
|
||||
peer_chunks_download_timeout: Duration::from_secs(15),
|
||||
peer_wait_outgoing_connection_timeout: Duration::from_secs(10),
|
||||
peer_next_chunks_request_wait_timeout: Duration::from_secs(3),
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user