-
Notifications
You must be signed in to change notification settings - Fork 3
refactor!: update to iroh 0.35 and non-global metrics tracking #41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
78cbcd0
refactor: update metrics tracking to be non-global
Frando 18358a7
deps: update iroh-metrics to 0.34
Frando ca93e73
deps: update to iroh main
Frando 29cac87
deps: update to released versions of iroh, iroh-blobs, iroh-gossip
Frando 2561167
fix: adjust tests for iroh 0.35
Frando e797194
chore: allow unlicense
Frando f391649
fix: doctest in readme
Frando File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,7 +12,6 @@ use anyhow::{anyhow, Context, Result}; | |
use bytes::Bytes; | ||
use futures_util::FutureExt; | ||
use iroh_blobs::Hash; | ||
use iroh_metrics::inc; | ||
use serde::{Deserialize, Serialize}; | ||
use tokio::{sync::oneshot, task::JoinSet}; | ||
use tracing::{debug, error, error_span, trace, warn}; | ||
|
@@ -224,6 +223,7 @@ struct OpenReplica { | |
pub struct SyncHandle { | ||
tx: async_channel::Sender<Action>, | ||
join_handle: Arc<Option<JoinHandle<()>>>, | ||
metrics: Arc<Metrics>, | ||
} | ||
|
||
/// Options when opening a replica. | ||
|
@@ -255,13 +255,15 @@ impl SyncHandle { | |
content_status_callback: Option<ContentStatusCallback>, | ||
me: String, | ||
) -> SyncHandle { | ||
let metrics = Arc::new(Metrics::default()); | ||
let (action_tx, action_rx) = async_channel::bounded(ACTION_CAP); | ||
let actor = Actor { | ||
store, | ||
states: Default::default(), | ||
action_rx, | ||
content_status_callback, | ||
tasks: Default::default(), | ||
metrics: metrics.clone(), | ||
}; | ||
let join_handle = std::thread::Builder::new() | ||
.name("sync-actor".to_string()) | ||
|
@@ -278,9 +280,15 @@ impl SyncHandle { | |
SyncHandle { | ||
tx: action_tx, | ||
join_handle, | ||
metrics, | ||
} | ||
} | ||
|
||
/// Returns the metrics collected in this sync actor. | ||
pub fn metrics(&self) -> &Arc<Metrics> { | ||
&self.metrics | ||
} | ||
|
||
pub async fn open(&self, namespace: NamespaceId, opts: OpenOpts) -> Result<()> { | ||
let (reply, rx) = oneshot::channel(); | ||
let action = ReplicaAction::Open { reply, opts }; | ||
|
@@ -599,6 +607,7 @@ struct Actor { | |
action_rx: async_channel::Receiver<Action>, | ||
content_status_callback: Option<ContentStatusCallback>, | ||
tasks: JoinSet<()>, | ||
metrics: Arc<Metrics>, | ||
} | ||
|
||
impl Actor { | ||
|
@@ -634,7 +643,7 @@ impl Actor { | |
} | ||
}; | ||
trace!(%action, "tick"); | ||
inc!(Metrics, actor_tick_main); | ||
self.metrics.actor_tick_main.inc(); | ||
match action { | ||
Action::Shutdown { reply } => { | ||
break reply; | ||
|
@@ -750,6 +759,8 @@ impl Actor { | |
let author = get_author(&mut this.store, &author)?; | ||
let mut replica = this.states.replica(namespace, &mut this.store)?; | ||
replica.insert(&key, &author, hash, len)?; | ||
this.metrics.new_entries_local.inc(); | ||
this.metrics.new_entries_local_size.inc_by(len); | ||
Ok(()) | ||
}), | ||
ReplicaAction::DeletePrefix { author, key, reply } => { | ||
|
@@ -769,7 +780,10 @@ impl Actor { | |
let mut replica = this | ||
.states | ||
.replica_if_syncing(&namespace, &mut this.store)?; | ||
let len = entry.content_len(); | ||
replica.insert_remote_entry(entry, from, content_status)?; | ||
this.metrics.new_entries_remote.inc(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These metric were previously tracked in |
||
this.metrics.new_entries_remote_size.inc_by(len); | ||
Ok(()) | ||
}), | ||
|
||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,85 +1,49 @@ | ||
//! Metrics for iroh-docs | ||
|
||
use iroh_metrics::{ | ||
core::{Counter, Metric}, | ||
struct_iterable::Iterable, | ||
}; | ||
use iroh_metrics::{Counter, MetricsGroup}; | ||
|
||
/// Metrics for iroh-docs | ||
#[allow(missing_docs)] | ||
#[derive(Debug, Clone, Iterable)] | ||
#[derive(Debug, Default, MetricsGroup)] | ||
pub struct Metrics { | ||
/// Number of document entries added locally | ||
pub new_entries_local: Counter, | ||
/// Number of document entries added by peers | ||
pub new_entries_remote: Counter, | ||
/// Total size of entry contents added locally | ||
pub new_entries_local_size: Counter, | ||
/// Total size of entry contents added by peers | ||
pub new_entries_remote_size: Counter, | ||
pub sync_via_connect_success: Counter, | ||
pub sync_via_connect_failure: Counter, | ||
/// Number of successful syncs (via accept) | ||
pub sync_via_accept_success: Counter, | ||
/// Number of failed syncs (via accept) | ||
pub sync_via_accept_failure: Counter, | ||
/// Number of successful syncs (via connect) | ||
pub sync_via_connect_success: Counter, | ||
/// Number of failed syncs (via connect) | ||
pub sync_via_connect_failure: Counter, | ||
|
||
/// Number of times the main actor loop ticked | ||
pub actor_tick_main: Counter, | ||
|
||
/// Number of times the gossip actor loop ticked | ||
pub doc_gossip_tick_main: Counter, | ||
/// Number of times the gossip actor processed an event | ||
pub doc_gossip_tick_event: Counter, | ||
/// Number of times the gossip actor processed an actor event | ||
pub doc_gossip_tick_actor: Counter, | ||
/// Number of times the gossip actor processed a pending join | ||
pub doc_gossip_tick_pending_join: Counter, | ||
|
||
/// Number of times the live actor loop ticked | ||
pub doc_live_tick_main: Counter, | ||
/// Number of times the live actor processed an actor event | ||
pub doc_live_tick_actor: Counter, | ||
/// Number of times the live actor processed a replica event | ||
pub doc_live_tick_replica_event: Counter, | ||
/// Number of times the live actor processed a running sync connect | ||
pub doc_live_tick_running_sync_connect: Counter, | ||
/// Number of times the live actor processed a running sync accept | ||
pub doc_live_tick_running_sync_accept: Counter, | ||
/// Number of times the live actor processed a pending download | ||
pub doc_live_tick_pending_downloads: Counter, | ||
} | ||
|
||
impl Default for Metrics { | ||
fn default() -> Self { | ||
Self { | ||
new_entries_local: Counter::new("Number of document entries added locally"), | ||
new_entries_remote: Counter::new("Number of document entries added by peers"), | ||
new_entries_local_size: Counter::new("Total size of entry contents added locally"), | ||
new_entries_remote_size: Counter::new("Total size of entry contents added by peers"), | ||
sync_via_accept_success: Counter::new("Number of successful syncs (via accept)"), | ||
sync_via_accept_failure: Counter::new("Number of failed syncs (via accept)"), | ||
sync_via_connect_success: Counter::new("Number of successful syncs (via connect)"), | ||
sync_via_connect_failure: Counter::new("Number of failed syncs (via connect)"), | ||
|
||
actor_tick_main: Counter::new("Number of times the main actor loop ticked"), | ||
|
||
doc_gossip_tick_main: Counter::new("Number of times the gossip actor loop ticked"), | ||
doc_gossip_tick_event: Counter::new( | ||
"Number of times the gossip actor processed an event", | ||
), | ||
doc_gossip_tick_actor: Counter::new( | ||
"Number of times the gossip actor processed an actor event", | ||
), | ||
doc_gossip_tick_pending_join: Counter::new( | ||
"Number of times the gossip actor processed a pending join", | ||
), | ||
|
||
doc_live_tick_main: Counter::new("Number of times the live actor loop ticked"), | ||
doc_live_tick_actor: Counter::new( | ||
"Number of times the live actor processed an actor event", | ||
), | ||
doc_live_tick_replica_event: Counter::new( | ||
"Number of times the live actor processed a replica event", | ||
), | ||
doc_live_tick_running_sync_connect: Counter::new( | ||
"Number of times the live actor processed a running sync connect", | ||
), | ||
doc_live_tick_running_sync_accept: Counter::new( | ||
"Number of times the live actor processed a running sync accept", | ||
), | ||
doc_live_tick_pending_downloads: Counter::new( | ||
"Number of times the live actor processed a pending download", | ||
), | ||
} | ||
} | ||
} | ||
|
||
impl Metric for Metrics { | ||
fn name() -> &'static str { | ||
"iroh_docs" | ||
} | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These metric were previously tracked in
sync::Replica::insert_entry