Skip to content

Commit 48f115d

Browse files
committed
Fix spans for system
1 parent 71adb77 commit 48f115d

File tree

4 files changed

+12
-15
lines changed

4 files changed

+12
-15
lines changed

crates/bevy_ecs/src/system/commands/mod.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ use crate::{
99
world::{EntityWorldMut, FromWorld, World},
1010
};
1111
use bevy_ecs_macros::SystemParam;
12+
#[cfg(feature = "trace")]
13+
use bevy_utils::tracing::info_span;
1214
use bevy_utils::tracing::{error, info};
1315
pub use command_queue::CommandQueue;
1416
pub use parallel_scope::*;
@@ -119,7 +121,7 @@ impl SystemBuffer for CommandQueue {
119121
#[inline]
120122
fn apply(&mut self, _system_meta: &SystemMeta, world: &mut World) {
121123
#[cfg(feature = "trace")]
122-
let _span_guard = _system_meta.commands_span.enter();
124+
let _span_guard = info_span!("system_commands", name = _system_meta.name()).entered();
123125
self.apply(world);
124126
}
125127
}

crates/bevy_ecs/src/system/commands/parallel_scope.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
use std::cell::Cell;
22

3+
#[cfg(feature = "trace")]
4+
use bevy_utils::tracing::info_span;
35
use thread_local::ThreadLocal;
46

57
use crate::{
@@ -52,7 +54,7 @@ impl SystemBuffer for ParallelCommandQueue {
5254
#[inline]
5355
fn apply(&mut self, _system_meta: &SystemMeta, world: &mut World) {
5456
#[cfg(feature = "trace")]
55-
let _system_span = _system_meta.commands_span.enter();
57+
let _system_span = info_span!("system_commands", name = _system_meta.name()).entered();
5658
for cq in &mut self.thread_local_storage {
5759
cq.get_mut().apply(world);
5860
}

crates/bevy_ecs/src/system/exclusive_function_system.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ use crate::{
1111
};
1212

1313
use bevy_utils::all_tuples;
14+
#[cfg(feature = "trace")]
15+
use bevy_utils::tracing::info_span;
1416
use std::{any::TypeId, borrow::Cow, marker::PhantomData};
1517

1618
/// A function system that runs with exclusive [`World`] access.
@@ -106,7 +108,7 @@ where
106108

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

111113
let saved_last_tick = world.last_change_tick;
112114
world.last_change_tick = self.system_meta.last_run;

crates/bevy_ecs/src/system/function_system.rs

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,9 @@ use crate::{
99
};
1010

1111
use bevy_utils::all_tuples;
12-
use std::{any::TypeId, borrow::Cow, marker::PhantomData};
13-
1412
#[cfg(feature = "trace")]
15-
use bevy_utils::tracing::{info_span, Span};
13+
use bevy_utils::tracing::info_span;
14+
use std::{any::TypeId, borrow::Cow, marker::PhantomData};
1615

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

@@ -27,10 +26,6 @@ pub struct SystemMeta {
2726
is_send: bool,
2827
has_deferred: bool,
2928
pub(crate) last_run: Tick,
30-
#[cfg(feature = "trace")]
31-
pub(crate) system_span: Span,
32-
#[cfg(feature = "trace")]
33-
pub(crate) commands_span: Span,
3429
}
3530

3631
impl SystemMeta {
@@ -43,10 +38,6 @@ impl SystemMeta {
4338
is_send: true,
4439
has_deferred: false,
4540
last_run: Tick::new(0),
46-
#[cfg(feature = "trace")]
47-
system_span: info_span!("system", name = name),
48-
#[cfg(feature = "trace")]
49-
commands_span: info_span!("system_commands", name = name),
5041
}
5142
}
5243

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

491482
let change_tick = world.increment_change_tick();
492483

0 commit comments

Comments
 (0)