-
Notifications
You must be signed in to change notification settings - Fork 41
Add DLT statistics native-ui with chart #2477
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
AmmarAbouZor
merged 2 commits into
esrlabs:native-ui
from
kruss:native-ui-dlt-statistics-with-chart
Feb 10, 2026
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
176 changes: 176 additions & 0 deletions
176
application/apps/indexer/gui/application/src/host/common/dlt_stats.rs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,176 @@ | ||
| use dlt_core::{ | ||
| dlt::LogLevel, | ||
| parse::DltParseError, | ||
| read::DltMessageReader, | ||
| statistics::{Statistic, StatisticCollector, collect_statistics}, | ||
| }; | ||
| use rustc_hash::{FxHashMap, FxHashSet}; | ||
| use std::{fs::File, path::PathBuf}; | ||
|
|
||
| /// Collects the DLT statistics from the given source files. | ||
| pub fn dlt_statistics(sources: Vec<PathBuf>) -> Result<DltStatistics, String> { | ||
| let mut statistics = DltStatistics::default(); | ||
|
|
||
| for source in sources { | ||
| if let Ok(path) = source.clone().into_os_string().into_string() | ||
| && let Ok(file) = File::open(path) | ||
| { | ||
| let mut reader = DltMessageReader::new(file, true); | ||
| if let Err(error) = collect_statistics(&mut reader, &mut statistics) { | ||
| return Err(format!("{:?}: {}", source, error)); | ||
| } | ||
| } else { | ||
| return Err(format!("invalid source: {:?}", source)); | ||
| } | ||
| } | ||
|
|
||
| Ok(statistics) | ||
| } | ||
|
|
||
| /// The statistics-info of DLT files. | ||
| #[derive(Debug, Default, Clone)] | ||
| pub struct DltStatistics { | ||
| counter: usize, | ||
| pub total: LevelDistribution, | ||
| pub app_ids: FxHashMap<String, LevelDistribution>, | ||
| pub ctx_ids: FxHashMap<String, LevelDistribution>, | ||
| pub ecu_ids: FxHashMap<String, LevelDistribution>, | ||
| } | ||
|
|
||
| impl DltStatistics { | ||
| pub fn count(&self) -> usize { | ||
| self.app_ids.len() + self.ctx_ids.len() + self.ecu_ids.len() | ||
| } | ||
| } | ||
|
|
||
| /// The Level distribution of DLT messages. | ||
| #[derive(Debug, Default, Clone)] | ||
| pub struct LevelDistribution { | ||
| pub fatal: FxHashSet<usize>, | ||
| pub error: FxHashSet<usize>, | ||
| pub warn: FxHashSet<usize>, | ||
| pub info: FxHashSet<usize>, | ||
| pub debug: FxHashSet<usize>, | ||
| pub verbose: FxHashSet<usize>, | ||
| pub none: FxHashSet<usize>, | ||
| pub invalid: FxHashSet<usize>, | ||
| } | ||
|
|
||
| impl LevelDistribution { | ||
| pub fn count(&self) -> usize { | ||
| self.fatal.len() | ||
| + self.error.len() | ||
| + self.warn.len() | ||
| + self.info.len() | ||
| + self.debug.len() | ||
| + self.verbose.len() | ||
| + self.none.len() | ||
| + self.invalid.len() | ||
| } | ||
|
|
||
| pub fn values(&self) -> [usize; 8] { | ||
| [ | ||
| self.fatal.len(), | ||
| self.error.len(), | ||
| self.warn.len(), | ||
| self.info.len(), | ||
| self.debug.len(), | ||
| self.verbose.len(), | ||
| self.none.len(), | ||
| self.invalid.len(), | ||
| ] | ||
| } | ||
|
|
||
| pub fn merge(&mut self, other: &LevelDistribution) -> &mut Self { | ||
| self.fatal.extend(other.fatal.iter().copied()); | ||
| self.error.extend(other.error.iter().copied()); | ||
| self.warn.extend(other.warn.iter().copied()); | ||
| self.info.extend(other.info.iter().copied()); | ||
| self.debug.extend(other.debug.iter().copied()); | ||
| self.verbose.extend(other.verbose.iter().copied()); | ||
| self.none.extend(other.none.iter().copied()); | ||
| self.invalid.extend(other.invalid.iter().copied()); | ||
| self | ||
| } | ||
|
|
||
| pub fn intersect(&mut self, other: &LevelDistribution) -> &mut Self { | ||
| self.fatal.retain(|item| other.fatal.contains(item)); | ||
| self.error.retain(|item| other.error.contains(item)); | ||
| self.warn.retain(|item| other.warn.contains(item)); | ||
| self.info.retain(|item| other.info.contains(item)); | ||
| self.debug.retain(|item| other.debug.contains(item)); | ||
| self.verbose.retain(|item| other.verbose.contains(item)); | ||
| self.none.retain(|item| other.none.contains(item)); | ||
| self.invalid.retain(|item| other.invalid.contains(item)); | ||
| self | ||
| } | ||
| } | ||
|
|
||
| impl StatisticCollector for DltStatistics { | ||
| fn collect_statistic(&mut self, statistic: Statistic) -> Result<(), DltParseError> { | ||
| self.counter += 1; | ||
| let msg = self.counter; | ||
|
|
||
| let level = statistic.log_level; | ||
| add_for_level(&mut self.total, level, msg); | ||
|
|
||
| let header = statistic.standard_header; | ||
| add_for_id( | ||
| &mut self.ecu_ids, | ||
| header.ecu_id.unwrap_or("NONE".to_string()), | ||
| level, | ||
| msg, | ||
| ); | ||
|
|
||
| if let Some(header) = statistic.extended_header { | ||
| add_for_id(&mut self.app_ids, header.application_id, level, msg); | ||
| add_for_id(&mut self.ctx_ids, header.context_id, level, msg); | ||
| } | ||
|
|
||
| Ok(()) | ||
| } | ||
| } | ||
|
|
||
| fn add_for_id( | ||
| ids: &mut FxHashMap<String, LevelDistribution>, | ||
| id: String, | ||
| level: Option<LogLevel>, | ||
| msg: usize, | ||
| ) { | ||
| if let Some(levels) = ids.get_mut(&id) { | ||
| add_for_level(levels, level, msg); | ||
| } else { | ||
| let mut levels = LevelDistribution::default(); | ||
| add_for_level(&mut levels, level, msg); | ||
| ids.insert(id, levels); | ||
| } | ||
| } | ||
|
|
||
| fn add_for_level(levels: &mut LevelDistribution, level: Option<LogLevel>, msg: usize) { | ||
| match level { | ||
| None => { | ||
| levels.none.insert(msg); | ||
| } | ||
| Some(LogLevel::Fatal) => { | ||
| levels.fatal.insert(msg); | ||
| } | ||
| Some(LogLevel::Error) => { | ||
| levels.error.insert(msg); | ||
| } | ||
| Some(LogLevel::Warn) => { | ||
| levels.warn.insert(msg); | ||
| } | ||
| Some(LogLevel::Info) => { | ||
| levels.info.insert(msg); | ||
| } | ||
| Some(LogLevel::Debug) => { | ||
| levels.debug.insert(msg); | ||
| } | ||
| Some(LogLevel::Verbose) => { | ||
| levels.verbose.insert(msg); | ||
| } | ||
| Some(LogLevel::Invalid(_)) => { | ||
| levels.invalid.insert(msg); | ||
| } | ||
| } | ||
| } |
1 change: 1 addition & 0 deletions
1
application/apps/indexer/gui/application/src/host/common/mod.rs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,5 @@ | ||
| pub mod colors; | ||
| pub mod dlt_stats; | ||
| pub mod file_utls; | ||
| pub mod parsers; | ||
| pub mod sources; | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.