-
-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(tui): display individual tracing flows in Tui (#777)
- Loading branch information
1 parent
56125f3
commit fc0358b
Showing
17 changed files
with
286 additions
and
31 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 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 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 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 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,55 @@ | ||
use crate::frontend::tui_app::TuiApp; | ||
use ratatui::layout::{Alignment, Rect}; | ||
use ratatui::style::{Modifier, Style}; | ||
use ratatui::text::Line; | ||
use ratatui::widgets::{Bar, BarChart, BarGroup, Block, BorderType, Borders}; | ||
use ratatui::Frame; | ||
|
||
/// Render the flows. | ||
pub fn render(f: &mut Frame<'_>, rect: Rect, app: &TuiApp) { | ||
let round_flow_id = app.tracer_data().round_flow_id(); | ||
let data: Vec<_> = app | ||
.flow_counts | ||
.iter() | ||
.map(|(flow_id, count)| { | ||
let bar_color = if flow_id == &app.selected_flow { | ||
app.tui_config.theme.flows_chart_bar_selected_color | ||
} else { | ||
app.tui_config.theme.flows_chart_bar_unselected_color | ||
}; | ||
let label_color = if flow_id == &round_flow_id { | ||
app.tui_config.theme.flows_chart_text_current_color | ||
} else { | ||
app.tui_config.theme.flows_chart_text_non_current_color | ||
}; | ||
Bar::default() | ||
.label(Line::from(format!("{flow_id}"))) | ||
.value(*count as u64) | ||
.style(Style::default().fg(bar_color)) | ||
.value_style( | ||
Style::default() | ||
.bg(bar_color) | ||
.fg(label_color) | ||
.add_modifier(Modifier::BOLD), | ||
) | ||
}) | ||
.collect(); | ||
let block = Block::default() | ||
.title("Flows") | ||
.title_alignment(Alignment::Left) | ||
.borders(Borders::ALL) | ||
.border_type(BorderType::Rounded) | ||
.border_style(Style::default().fg(app.tui_config.theme.border_color)) | ||
.style( | ||
Style::default() | ||
.bg(app.tui_config.theme.bg_color) | ||
.fg(app.tui_config.theme.text_color), | ||
); | ||
let group = BarGroup::default().bars(&data); | ||
let flow_counts = BarChart::default() | ||
.block(block) | ||
.data(group) | ||
.bar_width(4) | ||
.bar_gap(1); | ||
f.render_widget(flow_counts, rect); | ||
} |
This file contains 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 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.