Skip to content
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

feat: introduce tracing #4282

Merged
merged 125 commits into from
Nov 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
125 commits
Select commit Hold shift + click to select a range
393ae2f
feaat:tracing
eserilev Aug 1, 2023
b3f055a
move error span
eserilev Aug 3, 2023
9780a07
remove tracing-subscriber from library crate
eserilev Aug 4, 2023
c9e4a3b
update logging
eserilev Aug 10, 2023
bf2fa39
remove reduncdant logs
eserilev Aug 10, 2023
8b30438
resolve conflict
eserilev Aug 10, 2023
6c12589
autonat tracing
eserilev Aug 30, 2023
ae55e8b
dcutr changes
eserilev Aug 30, 2023
3ce8b02
relay server
eserilev Aug 30, 2023
ccdf589
floodsub
eserilev Aug 30, 2023
d23d9a1
gossipsub
eserilev Aug 30, 2023
dce4a61
identity
eserilev Aug 30, 2023
8466290
merge conflicts
eserilev Aug 30, 2023
60c4c23
kad
eserilev Aug 30, 2023
1344b7f
mdns
eserilev Aug 30, 2023
ec8f0f1
perf
eserilev Aug 30, 2023
2000e42
rendezvous
eserilev Aug 30, 2023
3f40960
request-response
eserilev Aug 30, 2023
d990488
chat example changes
eserilev Aug 30, 2023
3e7af9b
distributed key value store example
eserilev Aug 30, 2023
f4d9944
inline tracing spans
eserilev Aug 31, 2023
ea8683f
add tracing to the rest of the examples
eserilev Aug 31, 2023
9b5b439
merge conflicts
eserilev Sep 6, 2023
8eb986f
fully qualified tracing usage
eserilev Sep 6, 2023
79a533b
fix
eserilev Sep 6, 2023
1a5c1ee
fix cargo newline issue
eserilev Sep 6, 2023
f6b2f6e
fully qualify trace usage
eserilev Sep 6, 2023
4796bd9
Merge branch 'master' into feat-tracing
thomaseizinger Sep 21, 2023
a2e9834
Fix clippy lints
thomaseizinger Sep 21, 2023
e8d7745
Fix formatting
thomaseizinger Sep 21, 2023
b8473fd
Fix wasm compile error
thomaseizinger Sep 21, 2023
b9a7949
added improved tracing for autonat, dcutr, floodsub, gossipsub
eserilev Sep 21, 2023
97458ad
tracing improvements to kad and identify
eserilev Sep 21, 2023
2a42e73
mdns tracing improvements
eserilev Sep 21, 2023
6a7fbfe
perf tracing improvements
eserilev Sep 21, 2023
8ec399a
the rest of the protocols
eserilev Sep 21, 2023
a723629
remove tracing from core crate
eserilev Sep 21, 2023
8229030
removed log dependency from identity crate
eserilev Sep 21, 2023
0c0e13f
swap log w/ trace for interop-tests
eserilev Sep 21, 2023
eba436a
browser-webrtc example tracing
eserilev Sep 21, 2023
863ad7a
dcutr example tracing
eserilev Sep 21, 2023
06bfcd2
memory-connection-limits tracing
eserilev Sep 21, 2023
9885250
multistream-select tracing
eserilev Sep 21, 2023
365e21d
server tracing
eserilev Sep 21, 2023
f523e07
muxer crate tracing
eserilev Sep 22, 2023
2df883f
yamux, test harness tracing
eserilev Sep 22, 2023
b45c345
autonat tracing, plus remove unwrap
eserilev Sep 22, 2023
186cd05
keypair tracing fix
eserilev Sep 22, 2023
7b7e4af
upnp and a few other crates tracing
eserilev Sep 22, 2023
d50fed5
swarm tracing
eserilev Sep 22, 2023
9e60720
swarm test tracing
eserilev Sep 22, 2023
317e0dc
cargo fmt
eserilev Sep 22, 2023
76c8f06
tracing cleanup
eserilev Sep 22, 2023
886297b
remove '.' from tracing messages
eserilev Sep 22, 2023
913ec28
tracing dns crate, plus alphabatize dependancies
eserilev Sep 22, 2023
a227415
noise crate tracing
eserilev Sep 22, 2023
8f75357
plaintext crate tracing
eserilev Sep 22, 2023
27c49ee
pnet crate tracing
eserilev Sep 22, 2023
73b9c58
added quic tracing
eserilev Sep 22, 2023
fc4bc36
tcp crate tracing
eserilev Sep 22, 2023
49db005
webrtc crate tracing
eserilev Sep 22, 2023
0935901
weebrtc-websys crate tracing
eserilev Sep 22, 2023
e9c495a
Merge branch 'master' of https://github.com/libp2p/rust-libp2p into f…
eserilev Sep 22, 2023
8e8980f
websocket crate tracing
eserilev Sep 23, 2023
62628f4
fix dependencies
eserilev Sep 23, 2023
8497c2d
changes based on feedback
eserilev Sep 23, 2023
b6f8e50
cargo fmt
eserilev Sep 23, 2023
dd405ba
resovle conflicts
eserilev Sep 23, 2023
09ea23a
personal review
eserilev Sep 23, 2023
5263e7c
merge
eserilev Sep 24, 2023
cbbf21c
remove env logger dependency
eserilev Oct 1, 2023
540f129
fmt
eserilev Oct 1, 2023
47767b1
fixes
eserilev Oct 1, 2023
92eb669
fmt
eserilev Oct 1, 2023
fc40b56
fmt
eserilev Oct 1, 2023
294f1e0
fixes based on feedback
eserilev Oct 1, 2023
897dea0
remove unnecessary peer id ref
eserilev Oct 1, 2023
587b1ac
fixing tracing subscriber issue
eserilev Oct 5, 2023
a53da1f
fmt
eserilev Oct 5, 2023
612d933
add mdns + ping example
eserilev Oct 5, 2023
edaea4f
otel example
eserilev Oct 5, 2023
9e8774e
Merge branch 'master' into feat-tracing
thomaseizinger Oct 16, 2023
6d070c4
Merge branch 'master' into feat-tracing
thomaseizinger Oct 25, 2023
09f9e3f
Merge branch 'master' into feat-tracing
thomaseizinger Oct 25, 2023
4ba5c90
Fix compile errors
thomaseizinger Oct 25, 2023
9f856a3
Revert bad updates
thomaseizinger Oct 25, 2023
651da5a
Add more spans and extend metrics example
thomaseizinger Oct 25, 2023
70a8e26
Add more docs
thomaseizinger Oct 25, 2023
8839f36
Remove span from select
thomaseizinger Oct 25, 2023
4c574f3
Move muxer spans into `Connection`
thomaseizinger Oct 25, 2023
d5ebef0
Add spans for `Swarm`
thomaseizinger Oct 25, 2023
52048e6
Add local peer id to `Swarm::poll` span
thomaseizinger Oct 25, 2023
ffe04d4
Move spans to concrete `poll` functions
thomaseizinger Oct 25, 2023
5a3514b
Move stream muxer spans to concrete impl
thomaseizinger Oct 25, 2023
ccf60a4
Remove unused imports
thomaseizinger Oct 25, 2023
20beaad
Instrument dialing of new connections
thomaseizinger Oct 25, 2023
fee6485
Remove parents
thomaseizinger Oct 25, 2023
eac2630
Set `follows_from` instead
thomaseizinger Oct 25, 2023
d6e8eb7
Fix doc link
thomaseizinger Oct 25, 2023
40c7517
Fix libp2p doc tests
thomaseizinger Oct 25, 2023
c6e2222
Fix bad char
thomaseizinger Oct 25, 2023
77f240e
Merge branch 'master' into feat-tracing
thomaseizinger Oct 27, 2023
4a0b030
merge
eserilev Oct 30, 2023
9659490
resolve merge conflicts
eserilev Oct 30, 2023
702c664
Merge branch 'master' into feat-tracing
thomaseizinger Oct 31, 2023
c75d265
Fix formatting
thomaseizinger Oct 31, 2023
4874464
Fix compile errors and delete otel-example
thomaseizinger Oct 31, 2023
94f9caa
Add spans for durations of connections
thomaseizinger Oct 31, 2023
8d84da4
Remove fields already present in parent span
thomaseizinger Oct 31, 2023
93350b1
Fix link
thomaseizinger Oct 31, 2023
e827911
Fix doc tests and warnings
thomaseizinger Oct 31, 2023
b136d49
Remove `local_peer_id` from `Swarm::poll`
thomaseizinger Oct 31, 2023
eccc6c1
dont upgrade debug to error
eserilev Nov 1, 2023
0f34558
add tracing decorator to handlers
eserilev Nov 1, 2023
88f256e
add tracing decorator to network behaviours
eserilev Nov 1, 2023
3cdf295
merge
eserilev Nov 1, 2023
c18fbd3
Merge branch 'master' into feat-tracing
thomaseizinger Nov 2, 2023
7b55185
Remove unused imports
thomaseizinger Nov 2, 2023
949ae15
Fix logger init in test
thomaseizinger Nov 2, 2023
fd2ba76
Merge remote-tracking branch 'origin/feat-tracing' into feat-tracing
thomaseizinger Nov 2, 2023
c3595da
Unify init of subscriber across examples
thomaseizinger Nov 2, 2023
6df4a94
Serve metrics on random port to avoid panic
thomaseizinger Nov 2, 2023
b5c2233
Fix bad merge
thomaseizinger Nov 2, 2023
cb72fbf
Merge branch 'master' into feat-tracing
thomaseizinger Nov 2, 2023
1cdaaa7
Merge branch 'master' into feat-tracing
thomaseizinger Nov 2, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
374 changes: 298 additions & 76 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ futures = { version = "0.3.29", features = ["executor", "thread-pool"] }
futures-timer = "3"
instant = "0.1.12"
libp2p-identity = { workspace = true, features = ["peerid", "ed25519"] }
log = "0.4"
multiaddr = { workspace = true }
multihash = { workspace = true }
multistream-select = { workspace = true }
Expand All @@ -30,6 +29,7 @@ rw-stream-sink = { workspace = true }
serde = { version = "1", optional = true, features = ["derive"] }
smallvec = "1.11.1"
thiserror = "1.0"
tracing = "0.1.37"
unsigned-varint = "0.7"
void = "1"

Expand Down
49 changes: 24 additions & 25 deletions core/src/transport/choice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ use crate::either::EitherFuture;
use crate::transport::{ListenerId, Transport, TransportError, TransportEvent};
use either::Either;
use futures::future;
use log::{debug, trace};
use multiaddr::Multiaddr;
use std::{pin::Pin, task::Context, task::Poll};

Expand Down Expand Up @@ -52,33 +51,33 @@ where
id: ListenerId,
addr: Multiaddr,
) -> Result<(), TransportError<Self::Error>> {
trace!(
"Attempting to listen on {} using {}",
addr,
tracing::trace!(
address=%addr,
"Attempting to listen on address using {}",
std::any::type_name::<A>()
);
let addr = match self.0.listen_on(id, addr) {
Err(TransportError::MultiaddrNotSupported(addr)) => {
debug!(
"Failed to listen on {} using {}",
addr,
tracing::debug!(
address=%addr,
"Failed to listen on address using {}",
std::any::type_name::<A>()
);
addr
}
res => return res.map_err(|err| err.map(Either::Left)),
};

trace!(
"Attempting to listen on {} using {}",
addr,
tracing::trace!(
address=%addr,
"Attempting to listen on address using {}",
std::any::type_name::<B>()
);
let addr = match self.1.listen_on(id, addr) {
Err(TransportError::MultiaddrNotSupported(addr)) => {
debug!(
"Failed to listen on {} using {}",
addr,
tracing::debug!(
address=%addr,
"Failed to listen on address using {}",
std::any::type_name::<B>()
);
addr
Expand All @@ -94,17 +93,17 @@ where
}

fn dial(&mut self, addr: Multiaddr) -> Result<Self::Dial, TransportError<Self::Error>> {
trace!(
"Attempting to dial {} using {}",
addr,
tracing::trace!(
address=%addr,
"Attempting to dial address using {}",
std::any::type_name::<A>()
);
let addr = match self.0.dial(addr) {
Ok(connec) => return Ok(EitherFuture::First(connec)),
Err(TransportError::MultiaddrNotSupported(addr)) => {
debug!(
"Failed to dial {} using {}",
addr,
tracing::debug!(
address=%addr,
"Failed to dial address using {}",
std::any::type_name::<A>()
);
addr
Expand All @@ -114,17 +113,17 @@ where
}
};

trace!(
"Attempting to dial {} using {}",
addr,
tracing::trace!(
address=%addr,
"Attempting to dial address using {}",
std::any::type_name::<A>()
);
let addr = match self.1.dial(addr) {
Ok(connec) => return Ok(EitherFuture::Second(connec)),
Err(TransportError::MultiaddrNotSupported(addr)) => {
debug!(
"Failed to dial {} using {}",
addr,
tracing::debug!(
address=%addr,
"Failed to dial address using {}",
std::any::type_name::<A>()
);
addr
Expand Down
13 changes: 6 additions & 7 deletions core/src/transport/global_only.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ use crate::{
multiaddr::{Multiaddr, Protocol},
transport::{ListenerId, TransportError, TransportEvent},
};
use log::debug;
use std::{
pin::Pin,
task::{Context, Poll},
Expand Down Expand Up @@ -292,20 +291,20 @@ impl<T: crate::Transport + Unpin> crate::Transport for Transport<T> {
match addr.iter().next() {
Some(Protocol::Ip4(a)) => {
if !ipv4_global::is_global(a) {
debug!("Not dialing non global IP address {:?}.", a);
tracing::debug!(ip=%a, "Not dialing non global IP address");
return Err(TransportError::MultiaddrNotSupported(addr));
}
self.inner.dial(addr)
}
Some(Protocol::Ip6(a)) => {
if !ipv6_global::is_global(a) {
debug!("Not dialing non global IP address {:?}.", a);
tracing::debug!(ip=%a, "Not dialing non global IP address");
return Err(TransportError::MultiaddrNotSupported(addr));
}
self.inner.dial(addr)
}
_ => {
debug!("Not dialing unsupported Multiaddress {:?}.", addr);
tracing::debug!(address=%addr, "Not dialing unsupported Multiaddress");
Err(TransportError::MultiaddrNotSupported(addr))
}
}
Expand All @@ -318,20 +317,20 @@ impl<T: crate::Transport + Unpin> crate::Transport for Transport<T> {
match addr.iter().next() {
Some(Protocol::Ip4(a)) => {
if !ipv4_global::is_global(a) {
debug!("Not dialing non global IP address {:?}.", a);
tracing::debug!(ip=?a, "Not dialing non global IP address");
return Err(TransportError::MultiaddrNotSupported(addr));
}
self.inner.dial_as_listener(addr)
}
Some(Protocol::Ip6(a)) => {
if !ipv6_global::is_global(a) {
debug!("Not dialing non global IP address {:?}.", a);
tracing::debug!(ip=?a, "Not dialing non global IP address");
return Err(TransportError::MultiaddrNotSupported(addr));
}
self.inner.dial_as_listener(addr)
}
_ => {
debug!("Not dialing unsupported Multiaddress {:?}.", addr);
tracing::debug!(address=%addr, "Not dialing unsupported Multiaddress");
Err(TransportError::MultiaddrNotSupported(addr))
}
}
Expand Down
9 changes: 4 additions & 5 deletions core/src/upgrade/apply.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
use crate::upgrade::{InboundConnectionUpgrade, OutboundConnectionUpgrade, UpgradeError};
use crate::{connection::ConnectedPoint, Negotiated};
use futures::{future::Either, prelude::*};
use log::debug;
use multistream_select::{self, DialerSelectFuture, ListenerSelectFuture};
use std::{mem, pin::Pin, task::Context, task::Poll};

Expand Down Expand Up @@ -141,11 +140,11 @@ where
return Poll::Pending;
}
Poll::Ready(Ok(x)) => {
log::trace!("Upgraded inbound stream to {name}");
tracing::trace!(upgrade=%name, "Upgraded inbound stream");
return Poll::Ready(Ok(x));
}
Poll::Ready(Err(e)) => {
debug!("Failed to upgrade inbound stream to {name}");
tracing::debug!(upgrade=%name, "Failed to upgrade inbound stream");
return Poll::Ready(Err(UpgradeError::Apply(e)));
}
}
Expand Down Expand Up @@ -223,11 +222,11 @@ where
return Poll::Pending;
}
Poll::Ready(Ok(x)) => {
log::trace!("Upgraded outbound stream to {name}",);
tracing::trace!(upgrade=%name, "Upgraded outbound stream");
return Poll::Ready(Ok(x));
}
Poll::Ready(Err(e)) => {
debug!("Failed to upgrade outbound stream to {name}",);
tracing::debug!(upgrade=%name, "Failed to upgrade outbound stream",);
return Poll::Ready(Err(UpgradeError::Apply(e)));
}
}
Expand Down
3 changes: 2 additions & 1 deletion examples/autonat/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@ release = false
[dependencies]
tokio = { version = "1.33", features = ["full"] }
clap = { version = "4.4.7", features = ["derive"] }
env_logger = "0.10.0"
futures = "0.3.29"
libp2p = { path = "../../libp2p", features = ["tokio", "tcp", "noise", "yamux", "autonat", "identify", "macros"] }
tracing = "0.1.37"
tracing-subscriber = { version = "0.3", features = ["env-filter"] }

[lints]
workspace = true
5 changes: 4 additions & 1 deletion examples/autonat/src/bin/autonat_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ use libp2p::{autonat, identify, identity, noise, tcp, yamux, PeerId};
use std::error::Error;
use std::net::Ipv4Addr;
use std::time::Duration;
use tracing_subscriber::EnvFilter;

#[derive(Debug, Parser)]
#[clap(name = "libp2p autonat")]
Expand All @@ -45,7 +46,9 @@ struct Opt {

#[tokio::main]
async fn main() -> Result<(), Box<dyn Error>> {
env_logger::init();
let _ = tracing_subscriber::fmt()
.with_env_filter(EnvFilter::from_default_env())
.try_init();

let opt = Opt::parse();

Expand Down
5 changes: 4 additions & 1 deletion examples/autonat/src/bin/autonat_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ use libp2p::swarm::{NetworkBehaviour, SwarmEvent};
use libp2p::{autonat, identify, identity, noise, tcp, yamux};
use std::error::Error;
use std::net::Ipv4Addr;
use tracing_subscriber::EnvFilter;

#[derive(Debug, Parser)]
#[clap(name = "libp2p autonat")]
Expand All @@ -37,7 +38,9 @@ struct Opt {

#[tokio::main]
async fn main() -> Result<(), Box<dyn Error>> {
env_logger::init();
let _ = tracing_subscriber::fmt()
.with_env_filter(EnvFilter::from_default_env())
.try_init();

let opt = Opt::parse();

Expand Down
4 changes: 2 additions & 2 deletions examples/browser-webrtc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ crate-type = ["cdylib"]

[dependencies]
anyhow = "1.0.72"
env_logger = "0.10"
futures = "0.3.29"
log = "0.4"
rand = "0.8"
tracing = "0.1.37"
tracing-subscriber = { version = "0.3", features = ["env-filter"] }

[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
axum = "0.6.19"
Expand Down
8 changes: 4 additions & 4 deletions examples/browser-webrtc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ pub async fn run(libp2p_endpoint: String) -> Result<(), JsError> {
.build();

let addr = libp2p_endpoint.parse::<Multiaddr>()?;
log::info!("Dialing {addr}");
tracing::info!("Dialing {addr}");
swarm.dial(addr)?;

loop {
match swarm.next().await.unwrap() {
SwarmEvent::Behaviour(ping::Event { result: Err(e), .. }) => {
log::error!("Ping failed: {:?}", e);
tracing::error!("Ping failed: {:?}", e);

break;
}
Expand All @@ -43,10 +43,10 @@ pub async fn run(libp2p_endpoint: String) -> Result<(), JsError> {
result: Ok(rtt),
..
}) => {
log::info!("Ping successful: RTT: {rtt:?}, from {peer}");
tracing::info!("Ping successful: RTT: {rtt:?}, from {peer}");
body.append_p(&format!("RTT: {rtt:?} at {}", Date::new_0().to_string()))?;
}
evt => log::info!("Swarm event: {:?}", evt),
evt => tracing::info!("Swarm event: {:?}", evt),
}
}

Expand Down
19 changes: 10 additions & 9 deletions examples/browser-webrtc/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,9 @@ use tower_http::cors::{Any, CorsLayer};

#[tokio::main]
async fn main() -> anyhow::Result<()> {
env_logger::builder()
.parse_filters("browser_webrtc_example=debug,libp2p_webrtc=info,libp2p_ping=debug")
eserilev marked this conversation as resolved.
Show resolved Hide resolved
.parse_default_env()
.init();
let _ = tracing_subscriber::fmt()
.with_env_filter("browser_webrtc_example=debug,libp2p_webrtc=info,libp2p_ping=debug")
.try_init();

let mut swarm = libp2p::SwarmBuilder::with_new_identity()
.with_tokio()
Expand Down Expand Up @@ -56,11 +55,13 @@ async fn main() -> anyhow::Result<()> {
.iter()
.any(|e| e == Protocol::Ip4(Ipv4Addr::LOCALHOST))
{
log::debug!("Ignoring localhost address to make sure the example works in Firefox");
tracing::debug!(
"Ignoring localhost address to make sure the example works in Firefox"
);
continue;
}

log::info!("Listening on: {address}");
tracing::info!(%address, "Listening");

break address;
}
Expand All @@ -74,7 +75,7 @@ async fn main() -> anyhow::Result<()> {
loop {
tokio::select! {
swarm_event = swarm.next() => {
log::trace!("Swarm Event: {:?}", swarm_event)
tracing::trace!(?swarm_event)
},
_ = tokio::signal::ctrl_c() => {
break;
Expand Down Expand Up @@ -110,7 +111,7 @@ pub(crate) async fn serve(libp2p_transport: Multiaddr) {

let addr = SocketAddr::new(listen_addr.into(), 8080);

log::info!("Serving client files at http://{addr}");
tracing::info!(url=%format!("http://{addr}"), "Serving client files at url");

axum::Server::bind(&addr)
.serve(server.into_make_service())
Expand Down Expand Up @@ -141,7 +142,7 @@ async fn get_index(

/// Serves the static files generated by `wasm-pack`.
async fn get_static_file(Path(path): Path<String>) -> Result<impl IntoResponse, StatusCode> {
log::debug!("Serving static file: {path}");
tracing::debug!(file_path=%path, "Serving static file");

let content = StaticFiles::get(&path).ok_or(StatusCode::NOT_FOUND)?.data;
let content_type = mime_guess::from_path(path)
Expand Down
3 changes: 2 additions & 1 deletion examples/chat/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@ release = false
[dependencies]
tokio = { version = "1.33", features = ["full"] }
async-trait = "0.1"
env_logger = "0.10.0"
futures = "0.3.29"
libp2p = { path = "../../libp2p", features = [ "tokio", "gossipsub", "mdns", "noise", "macros", "tcp", "yamux", "quic"] }
tracing = "0.1.37"
tracing-subscriber = { version = "0.3", features = ["env-filter"] }

[lints]
workspace = true
5 changes: 5 additions & 0 deletions examples/chat/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ use std::error::Error;
use std::hash::{Hash, Hasher};
use std::time::Duration;
use tokio::{io, io::AsyncBufReadExt, select};
use tracing_subscriber::EnvFilter;

// We create a custom network behaviour that combines Gossipsub and Mdns.
#[derive(NetworkBehaviour)]
Expand All @@ -37,6 +38,10 @@ struct MyBehaviour {

#[tokio::main]
async fn main() -> Result<(), Box<dyn Error>> {
let _ = tracing_subscriber::fmt()
.with_env_filter(EnvFilter::from_default_env())
.try_init();

let mut swarm = libp2p::SwarmBuilder::with_new_identity()
.with_tokio()
.with_tcp(
Expand Down
Loading