can specify chrome tracing file (#4618)

# Objective

- I want to have the trace file at a predictable path

## Solution

- Adds an environment variable that is used as the path when it's set
This commit is contained in:
François 2022-05-03 15:35:04 +00:00
parent 5cb6f7ffd2
commit b5feb9ae9b
2 changed files with 6 additions and 2 deletions

View file

@ -283,7 +283,7 @@ jobs:
for example in .github/example-run/*.ron; do
example_name=`basename $example .ron`
echo "running $example_name - "`date`
time CI_TESTING_CONFIG=$example xvfb-run cargo run --example $example_name --no-default-features --features "bevy_dynamic_plugin,bevy_gilrs,bevy_gltf,bevy_winit,render,png,hdr,x11,bevy_ci_testing,trace,trace_chrome,bevy_audio,vorbis"
time TRACE_CHROME=trace-$example_name.json CI_TESTING_CONFIG=$example xvfb-run cargo run --example $example_name --no-default-features --features "bevy_dynamic_plugin,bevy_gilrs,bevy_gltf,bevy_winit,render,png,hdr,x11,bevy_ci_testing,trace,trace_chrome,bevy_audio,vorbis"
sleep 10
done
zip traces.zip trace*.json

View file

@ -137,7 +137,11 @@ impl Plugin for LogPlugin {
{
#[cfg(feature = "tracing-chrome")]
let chrome_layer = {
let (chrome_layer, guard) = tracing_chrome::ChromeLayerBuilder::new()
let mut layer = tracing_chrome::ChromeLayerBuilder::new();
if let Ok(path) = std::env::var("TRACE_CHROME") {
layer = layer.file(path);
}
let (chrome_layer, guard) = layer
.name_fn(Box::new(|event_or_span| match event_or_span {
tracing_chrome::EventOrSpan::Event(event) => event.metadata().name().into(),
tracing_chrome::EventOrSpan::Span(span) => {