fix(timings): count time spent on custom on 'when' command failure (#4121)

Count time spent on custom 'when' commands
This commit is contained in:
Jan Larres 2022-07-09 02:38:26 +12:00 committed by GitHub
parent e4fa652169
commit aae1ed04ba
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -34,6 +34,8 @@ pub fn module<'a>(name: &str, context: &'a Context) -> Option<Module<'a>> {
}
}
let mut module = Module::new(name, config.description, Some(toml_config));
let mut is_match = context
.try_begin_scan()?
.set_extensions(&config.detect_extensions)
@ -46,14 +48,9 @@ pub fn module<'a>(name: &str, context: &'a Context) -> Option<Module<'a>> {
Either::First(b) => b,
Either::Second(s) => exec_when(s, &config, context),
};
if !is_match {
return None;
}
}
let mut module = Module::new(name, config.description, Some(toml_config));
if is_match {
let parsed = StringFormatter::new(config.format).and_then(|formatter| {
formatter
.map_meta(|var, _| match var {
@ -86,6 +83,7 @@ pub fn module<'a>(name: &str, context: &'a Context) -> Option<Module<'a>> {
log::warn!("Error in module `custom.{}`:\n{}", name, error);
}
};
}
let elapsed = start.elapsed();
log::trace!("Took {:?} to compute custom module {:?}", elapsed, name);
module.duration = elapsed;