Skip to content

Commit

Permalink
Fix spans for system
Browse files Browse the repository at this point in the history
  • Loading branch information
stepancheg committed Jan 1, 2024
1 parent 71adb77 commit b5f45d9
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 16 deletions.
4 changes: 2 additions & 2 deletions crates/bevy_ecs/src/system/commands/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use crate::{
world::{EntityWorldMut, FromWorld, World},
};
use bevy_ecs_macros::SystemParam;
use bevy_utils::tracing::{error, info};
use bevy_utils::tracing::{error, info, info_span};
pub use command_queue::CommandQueue;
pub use parallel_scope::*;
use std::marker::PhantomData;
Expand Down Expand Up @@ -119,7 +119,7 @@ impl SystemBuffer for CommandQueue {
#[inline]
fn apply(&mut self, _system_meta: &SystemMeta, world: &mut World) {
#[cfg(feature = "trace")]
let _span_guard = _system_meta.commands_span.enter();
let _span_guard = info_span!("system_commands", name = _system_meta.name()).entered();
self.apply(world);
}
}
Expand Down
3 changes: 2 additions & 1 deletion crates/bevy_ecs/src/system/commands/parallel_scope.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use std::cell::Cell;

use bevy_utils::tracing::info_span;
use thread_local::ThreadLocal;

use crate::{
Expand Down Expand Up @@ -52,7 +53,7 @@ impl SystemBuffer for ParallelCommandQueue {
#[inline]
fn apply(&mut self, _system_meta: &SystemMeta, world: &mut World) {
#[cfg(feature = "trace")]
let _system_span = _system_meta.commands_span.enter();
let _system_span = info_span!("system_commands", name = _system_meta.name()).entered();
for cq in &mut self.thread_local_storage {
cq.get_mut().apply(world);
}
Expand Down
3 changes: 2 additions & 1 deletion crates/bevy_ecs/src/system/exclusive_function_system.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use crate::{
};

use bevy_utils::all_tuples;
use bevy_utils::tracing::info_span;
use std::{any::TypeId, borrow::Cow, marker::PhantomData};

/// A function system that runs with exclusive [`World`] access.
Expand Down Expand Up @@ -106,7 +107,7 @@ where

fn run(&mut self, input: Self::In, world: &mut World) -> Self::Out {
#[cfg(feature = "trace")]
let _span_guard = self.system_meta.system_span.enter();
let _span_guard = info_span!("system", name = self.name().as_ref()).entered();

let saved_last_tick = world.last_change_tick;
world.last_change_tick = self.system_meta.last_run;
Expand Down
14 changes: 2 additions & 12 deletions crates/bevy_ecs/src/system/function_system.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,9 @@ use crate::{
};

use bevy_utils::all_tuples;
use bevy_utils::tracing::info_span;
use std::{any::TypeId, borrow::Cow, marker::PhantomData};

#[cfg(feature = "trace")]
use bevy_utils::tracing::{info_span, Span};

use super::{In, IntoSystem, ReadOnlySystem};

/// The metadata of a [`System`].
Expand All @@ -27,10 +25,6 @@ pub struct SystemMeta {
is_send: bool,
has_deferred: bool,
pub(crate) last_run: Tick,
#[cfg(feature = "trace")]
pub(crate) system_span: Span,
#[cfg(feature = "trace")]
pub(crate) commands_span: Span,
}

impl SystemMeta {
Expand All @@ -43,10 +37,6 @@ impl SystemMeta {
is_send: true,
has_deferred: false,
last_run: Tick::new(0),
#[cfg(feature = "trace")]
system_span: info_span!("system", name = name),
#[cfg(feature = "trace")]
commands_span: info_span!("system_commands", name = name),
}
}

Expand Down Expand Up @@ -486,7 +476,7 @@ where
#[inline]
unsafe fn run_unsafe(&mut self, input: Self::In, world: UnsafeWorldCell) -> Self::Out {
#[cfg(feature = "trace")]
let _span_guard = self.system_meta.system_span.enter();
let _span_guard = info_span!("system", name = self.name().as_ref()).entered();

let change_tick = world.increment_change_tick();

Expand Down

0 comments on commit b5f45d9

Please sign in to comment.