Skip to content
This repository has been archived by the owner on Jul 1, 2024. It is now read-only.

Commit

Permalink
Remove some tracing
Browse files Browse the repository at this point in the history
  • Loading branch information
DimitriTimoz committed Dec 25, 2023
1 parent 4adb08d commit aee0eca
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 22 deletions.
2 changes: 0 additions & 2 deletions minecraft-server/src/entities/entity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ pub struct Entity {
}

impl Handler<Entity> {
#[cfg_attr(feature = "tracing", instrument(skip_all))]

pub async fn init(self, server_msg_rcvr: BroadcastReceiver<ServerMessage>) {
self.insert_task("newton", tokio::spawn(newton_task(self.clone(), server_msg_rcvr))).await;
}
Expand Down
4 changes: 2 additions & 2 deletions minecraft-server/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ impl std::future::Future for ServerFuture {

#[tokio::main]
async fn main() {
#[cfg(feature = "tracing")]
#[cfg(feature = "trace")]
#[global_allocator]
static GLOBAL: tracy_client::ProfiledAllocator<std::alloc::System> =
tracy_client::ProfiledAllocator::new(std::alloc::System, 100);
Expand All @@ -32,7 +32,7 @@ async fn main() {

let subscriber = Registry::default()
.with(fmt::layer());
#[cfg(feature = "tracing")]
#[cfg(feature = "trace")]
let subscriber = subscriber
.with(tracing_tracy::TracyLayer::new());

Expand Down
3 changes: 1 addition & 2 deletions minecraft-server/src/player_handler/login.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ pub struct LoggedInPlayerInfo {
pub(super) uuid: u128,
}

#[cfg_attr(feature = "tracing", instrument(skip_all))]

#[cfg_attr(feature = "trace", instrument(skip_all))]
pub async fn login(stream: &mut TcpStream, addr: SocketAddr) -> Result<LoggedInPlayerInfo, ()> {
// Receive login start
let packet = receive_packet(stream).await?;
Expand Down
6 changes: 3 additions & 3 deletions minecraft-server/src/player_handler/network.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,23 +48,23 @@ pub async fn receive_packet_split(stream: &mut OwnedReadHalf) -> Result<Vec<u8>,
Ok(data)
}

#[cfg_attr(feature = "tracing", instrument)]
#[cfg_attr(feature = "trace", 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();
stream.write_all(packet).await.unwrap();
stream.flush().await.unwrap();
}

#[cfg_attr(feature = "tracing", instrument)]
#[cfg_attr(feature = "trace", 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();
stream.write_all(packet).await.unwrap();
stream.flush().await.unwrap();
}

#[cfg_attr(feature = "tracing", instrument(skip_all))]
#[cfg_attr(feature = "trace", 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;
Expand Down
2 changes: 1 addition & 1 deletion minecraft-server/src/player_handler/status.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use super::*;

#[cfg_attr(feature = "tracing", instrument(skip_all))]
#[cfg_attr(feature = "trace", instrument(skip_all))]
pub async fn status(stream: &mut TcpStream) -> Result<(), ()> {
loop {
let packet = receive_packet(stream).await?;
Expand Down
14 changes: 2 additions & 12 deletions minecraft-server/src/world/ecs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,12 @@ impl Entities {
}

/// Observe an entity through a closure
#[cfg_attr(feature = "tracing", instrument(skip_all))]

pub(super) async fn observe_entity<R>(&self, eid: Eid, observer: impl FnOnce(&AnyEntity) -> R) -> Option<R> {
self.entities.read().await.get(&eid).map(observer)
}

/// Observe entities in a chunk through a closure
/// That closure will be applied to each entity, and the results will be returned in a vector
#[cfg_attr(feature = "tracing", instrument(skip_all))]

pub(super) async fn observe_entities<R>(&self, chunk: ChunkColumnPosition, mut observer: impl FnMut(&AnyEntity) -> Option<R>) -> Vec<R> {
let entities = self.entities.read().await;
let chunks = self.chunks.read().await;
Expand All @@ -57,8 +53,6 @@ impl Entities {
}

/// Mutate an entity through a closure
#[cfg_attr(feature = "tracing", instrument(skip_all))]

pub(super) async fn mutate_entity<R>(&self, eid: Eid, mutator: impl FnOnce(&mut AnyEntity) -> (R, EntityChanges)) -> Option<(R, EntityChanges)> {
let mut entities = self.entities.write().await;

Expand All @@ -79,8 +73,7 @@ impl Entities {
}
}

#[cfg_attr(feature = "tracing", instrument(skip_all))]

#[cfg_attr(feature = "trace", instrument(skip_all))]
pub(super) async fn spawn_entity<E>(&self, entity: AnyEntity, world: &'static World, receiver: BroadcastReceiver<ServerMessage>) -> (Eid, UUID)
where AnyEntity: TryAsEntityRef<E>, Handler<E>: EntityExt
{
Expand All @@ -100,8 +93,6 @@ impl Entities {
(eid, uuid)
}

#[cfg_attr(feature = "tracing", instrument(skip_all))]

pub(super) async fn insert_entity_task(&self, eid: Eid, name: &'static str, handle: EntityTaskHandle) {
let mut entity_tasks = self.entity_tasks.write().await;
let old = entity_tasks.entry(eid).or_insert(HashMap::new()).insert(name, handle);
Expand All @@ -111,8 +102,7 @@ impl Entities {
}

/// Remove an entity
#[cfg_attr(feature = "tracing", instrument(skip_all))]

#[cfg_attr(feature = "trace", instrument(skip_all))]
pub(super) async fn remove_entity(&self, eid: Eid) -> Option<AnyEntity> {
let entity = self.entities.write().await.remove(&eid);
let mut chunks = self.chunks.write().await;
Expand Down

0 comments on commit aee0eca

Please sign in to comment.