Skip to content

Commit cce716e

Browse files
insipxbkchr
authored andcommitted
Change TRACING_SET to static (paritytech#7607)
* change TRACING_SET to static * Update primitives/io/src/lib.rs Co-authored-by: Bastian Köcher <[email protected]> * modify test with nested spans Co-authored-by: Bastian Köcher <[email protected]>
1 parent e771bff commit cce716e

File tree

3 files changed

+21
-1
lines changed

3 files changed

+21
-1
lines changed

client/executor/runtime-test/src/lib.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,17 @@ sp_core::wasm_export_functions! {
261261
wasm_tracing::exit(span_id)
262262
}
263263

264+
fn test_nested_spans() {
265+
sp_io::init_tracing();
266+
let span_id = wasm_tracing::enter_span(Default::default());
267+
{
268+
sp_io::init_tracing();
269+
let span_id = wasm_tracing::enter_span(Default::default());
270+
wasm_tracing::exit(span_id);
271+
}
272+
wasm_tracing::exit(span_id);
273+
}
274+
264275
fn returns_mutable_static() -> u64 {
265276
unsafe {
266277
MUTABLE_STATIC += 1;

client/executor/src/integration_tests/mod.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -719,6 +719,15 @@ fn wasm_tracing_should_work(wasm_method: WasmExecutionMethod) {
719719
assert_eq!(span_datum.target, "default");
720720
assert_eq!(span_datum.name, "");
721721
assert_eq!(values.bool_values.get("wasm").unwrap(), &true);
722+
723+
call_in_wasm(
724+
"test_nested_spans",
725+
Default::default(),
726+
wasm_method,
727+
&mut ext,
728+
).unwrap();
729+
let len = traces.lock().unwrap().len();
730+
assert_eq!(len, 2);
722731
}
723732

724733
#[test_case(WasmExecutionMethod::Interpreted)]

primitives/io/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1093,7 +1093,7 @@ mod tracing_setup {
10931093
};
10941094
use super::{wasm_tracing, Crossing};
10951095

1096-
const TRACING_SET : AtomicBool = AtomicBool::new(false);
1096+
static TRACING_SET: AtomicBool = AtomicBool::new(false);
10971097

10981098

10991099
/// The PassingTracingSubscriber implements `tracing_core::Subscriber`

0 commit comments

Comments
 (0)