mirror of
https://github.com/k8sgpt-ai/k8sgpt.git
synced 2025-09-04 00:36:33 +00:00
feat: add stats option to analyze command for performance insights (#1237)
* feat: add stats option to analyze command for performance insights Introduced a new feature to the analyze command that enables users to print detailed performance statistics of each analyzer. This enhancement aids in debugging and understanding the time taken by various components during analysis, providing valuable insights for performance optimization. Signed-off-by: Matthis Holleville <matthish29@gmail.com> * feat: enhance analysis command with statistics option Refactored the analysis command to support an enhanced statistics option, enabling users to opt-in for detailed performance metrics of the analysis process. This change introduces a more flexible approach to handling statistics, allowing for a clearer separation between the analysis output and performance metrics, thereby improving the usability and insights provided to the user. Signed-off-by: Matthis Holleville <matthish29@gmail.com> --------- Signed-off-by: Matthis Holleville <matthish29@gmail.com> Co-authored-by: Alex Jones <alexsimonjones@gmail.com> Co-authored-by: Aris Boutselis <arisboutselis08@gmail.com>
This commit is contained in:
@@ -55,6 +55,18 @@ func (a *Analysis) jsonOutput() ([]byte, error) {
|
||||
return output, nil
|
||||
}
|
||||
|
||||
func (a *Analysis) PrintStats() []byte {
|
||||
var output strings.Builder
|
||||
|
||||
output.WriteString(color.YellowString("The stats mode allows for debugging and understanding the time taken by an analysis by displaying the statistics of each analyzer.\n"))
|
||||
|
||||
for _, stat := range a.Stats {
|
||||
output.WriteString(fmt.Sprintf("- Analyzer %s took %s \n", color.YellowString(stat.Analyzer), stat.DurationTime))
|
||||
}
|
||||
|
||||
return []byte(output.String())
|
||||
}
|
||||
|
||||
func (a *Analysis) textOutput() ([]byte, error) {
|
||||
var output strings.Builder
|
||||
|
||||
|
Reference in New Issue
Block a user