Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 0 additions & 10 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion crates/lgn-tracing/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ chrono = "0.4"
memoffset = "0.6"
thread-id = "4.0"
lazy_static = "1.4"
pin-project-lite = "0.2.9"

[dev-dependencies]
criterion = "0.3"
Expand Down
53 changes: 12 additions & 41 deletions crates/lgn-tracing/proc-macros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,56 +40,27 @@ pub fn span_fn(
args: proc_macro::TokenStream,
input: proc_macro::TokenStream,
) -> proc_macro::TokenStream {
let args = parse_macro_input!(args as TraceArgs);
let mut function = parse_macro_input!(input as ItemFn);

let function_name = args
.alternative_name
.map_or(function.sig.ident.to_string(), |n| n.to_string());

if function.sig.asyncness.is_none() {
function.block.stmts.insert(0, parse_quote! {
lgn_tracing::span_scope!(_METADATA_FUNC, concat!(module_path!(), "::", #function_name));
});

if function.sig.asyncness.is_some() {
// NOOP For now
return proc_macro::TokenStream::from(quote! {
#function
});
}
};

let stmts = function.block.stmts;
let args = parse_macro_input!(args as TraceArgs);

function.block.stmts = vec![
parse_quote! {
static _METADATA_FUNC: lgn_tracing::spans::SpanMetadata = lgn_tracing::spans::SpanMetadata {
name: concat!(module_path!(), "::", #function_name),
location: lgn_tracing::spans::SpanLocation {
lod: lgn_tracing::Verbosity::Max,
target: module_path!(),
module_path: module_path!(),
file: file!(),
line: line!()
}
};
},
parse_quote! {
lgn_tracing::dispatch::on_begin_scope(&_METADATA_FUNC);
},
parse_quote! {
let __lgn_tracing_future = async move {
#(#stmts)*
};
},
parse_quote! {
let __lgn_tracing_output = lgn_tracing::spans::Instrumentation::new(__lgn_tracing_future, &_METADATA_FUNC).await;
},
parse_quote! {
lgn_tracing::dispatch::on_end_scope(&_METADATA_FUNC);
},
let function_name = args
.alternative_name
.map_or(function.sig.ident.to_string(), |n| n.to_string());

function.block.stmts.insert(
0,
parse_quote! {
return __lgn_tracing_output;
lgn_tracing::span_scope!(_METADATA_FUNC, concat!(module_path!(), "::", #function_name));
},
];
);

proc_macro::TokenStream::from(quote! {
#function
Expand Down
61 changes: 0 additions & 61 deletions crates/lgn-tracing/src/spans/instrument.rs

This file was deleted.

2 changes: 0 additions & 2 deletions crates/lgn-tracing/src/spans/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,5 @@ pub use block::*;

mod events;
pub use events::*;
mod instrument;
pub use instrument::*;

// todo: implement non thread based perf spans for other systems to be used
12 changes: 0 additions & 12 deletions tests/async-span-fn/Cargo.toml

This file was deleted.

68 changes: 0 additions & 68 deletions tests/async-span-fn/src/main.rs

This file was deleted.