diff --git a/minecraft-protocol/src/components/chunk.rs b/minecraft-protocol/src/components/chunk.rs index 97f1b8d8..827313d3 100644 --- a/minecraft-protocol/src/components/chunk.rs +++ b/minecraft-protocol/src/components/chunk.rs @@ -221,6 +221,7 @@ impl Chunk { Ok(chunks) } + #[cfg_attr(feature = "tracing", instrument(skip(output)))] pub fn into_data(chunks: Vec) -> Result, &'static str> { let mut output = Vec::new(); diff --git a/minecraft-server/src/player_handler/connect.rs b/minecraft-server/src/player_handler/connect.rs index 3b206068..db280d35 100644 --- a/minecraft-server/src/player_handler/connect.rs +++ b/minecraft-server/src/player_handler/connect.rs @@ -1,7 +1,8 @@ use super::*; -#[instrument(skip_all)] +#[cfg_attr(feature = "tracing", instrument(skip_all))] + pub async fn handle_connection( mut stream: TcpStream, addr: SocketAddr, diff --git a/minecraft-server/src/player_handler/login.rs b/minecraft-server/src/player_handler/login.rs index 1a78f4cd..f794cc6e 100644 --- a/minecraft-server/src/player_handler/login.rs +++ b/minecraft-server/src/player_handler/login.rs @@ -6,7 +6,8 @@ pub struct LoggedInPlayerInfo { pub(super) uuid: u128, } -#[instrument(skip_all)] +#[cfg_attr(feature = "tracing", instrument(skip_all))] + pub async fn login(stream: &mut TcpStream, addr: SocketAddr) -> Result { // Receive login start let packet = receive_packet(stream).await?; diff --git a/minecraft-server/src/player_handler/network.rs b/minecraft-server/src/player_handler/network.rs index eb723853..8c2b90aa 100644 --- a/minecraft-server/src/player_handler/network.rs +++ b/minecraft-server/src/player_handler/network.rs @@ -48,7 +48,7 @@ pub async fn receive_packet_split(stream: &mut OwnedReadHalf) -> Result, Ok(data) } -#[instrument] +#[cfg_attr(feature = "tracing", instrument)] pub async fn send_packet_raw(stream: &mut TcpStream, packet: &[u8]) { let length = VarInt::from(packet.len()); stream.write_all(length.serialize_minecraft_packet().unwrap().as_slice()).await.unwrap(); @@ -56,7 +56,7 @@ pub async fn send_packet_raw(stream: &mut TcpStream, packet: &[u8]) { stream.flush().await.unwrap(); } -#[instrument] +#[cfg_attr(feature = "tracing", instrument)] pub async fn send_packet_raw_split(stream: &mut OwnedWriteHalf, packet: &[u8]) { let length = VarInt::from(packet.len()); stream.write_all(length.serialize_minecraft_packet().unwrap().as_slice()).await.unwrap(); @@ -64,7 +64,7 @@ pub async fn send_packet_raw_split(stream: &mut OwnedWriteHalf, packet: &[u8]) { stream.flush().await.unwrap(); } -#[instrument(skip_all)] +#[cfg_attr(feature = "tracing", instrument(skip_all))] pub async fn send_packet<'a, P: MinecraftPacketPart<'a>>(stream: &mut TcpStream, packet: P) { let packet = packet.serialize_minecraft_packet().unwrap(); send_packet_raw(stream, packet.as_slice()).await; diff --git a/minecraft-server/src/player_handler/status.rs b/minecraft-server/src/player_handler/status.rs index 0e6dd654..0999565b 100644 --- a/minecraft-server/src/player_handler/status.rs +++ b/minecraft-server/src/player_handler/status.rs @@ -1,6 +1,6 @@ use super::*; -#[instrument(skip_all)] +#[cfg_attr(feature = "tracing", instrument(skip_all))] pub async fn status(stream: &mut TcpStream) -> Result<(), ()> { loop { let packet = receive_packet(stream).await?;