Skip to content

Commit

Permalink
Merge pull request ProvableHQ#2143 from AleoHQ/tcp-review
Browse files Browse the repository at this point in the history
TCP review - adds comments, tests, and reorganizes some methods
  • Loading branch information
howardwu authored Dec 6, 2022
2 parents 71621eb + 5165c7d commit 657711c
Show file tree
Hide file tree
Showing 3 changed files with 448 additions and 188 deletions.
3 changes: 3 additions & 0 deletions node/tcp/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,6 @@ parking_lot = "0.12"
tokio = { version = "1.22", features = ["io-util", "net", "parking_lot", "rt", "sync", "time"] }
tokio-util = { version = "0.7", features = ["codec"] }
tracing = { version = "0.1", default-features = false }

[dev-dependencies]
tokio = { version = "1.22", features = ["macros"] }
24 changes: 24 additions & 0 deletions node/tcp/src/helpers/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,27 @@ pub use known_peers::KnownPeers;

mod stats;
pub use stats::Stats;

use tracing::{debug_span, error_span, info_span, trace_span, warn_span, Span};

// FIXME: this can probably be done more elegantly
/// Creates the Tcp's tracing span based on its name.
pub fn create_span(tcp_name: &str) -> Span {
let mut span = trace_span!("tcp", name = tcp_name);
if !span.is_disabled() {
return span;
} else {
span = debug_span!("tcp", name = tcp_name);
}
if !span.is_disabled() {
return span;
} else {
span = info_span!("tcp", name = tcp_name);
}
if !span.is_disabled() {
return span;
} else {
span = warn_span!("tcp", name = tcp_name);
}
if !span.is_disabled() { span } else { error_span!("tcp", name = tcp_name) }
}
Loading

0 comments on commit 657711c

Please sign in to comment.