mirror of
https://github.com/k8sgpt-ai/k8sgpt.git
synced 2025-09-17 23:59:21 +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:
@@ -40,6 +40,7 @@ var (
|
||||
interactiveMode bool
|
||||
customAnalysis bool
|
||||
customHeaders []string
|
||||
withStats bool
|
||||
)
|
||||
|
||||
// AnalyzeCmd represents the problems command
|
||||
@@ -63,6 +64,7 @@ var AnalyzeCmd = &cobra.Command{
|
||||
withDoc,
|
||||
interactiveMode,
|
||||
customHeaders,
|
||||
withStats,
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
@@ -88,6 +90,12 @@ var AnalyzeCmd = &cobra.Command{
|
||||
color.Red("Error: %v", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
if withStats {
|
||||
statsData := config.PrintStats()
|
||||
fmt.Println(string(statsData))
|
||||
}
|
||||
|
||||
fmt.Println(string(output_data))
|
||||
|
||||
if interactiveMode && explain {
|
||||
@@ -146,4 +154,6 @@ func init() {
|
||||
AnalyzeCmd.Flags().StringSliceVarP(&customHeaders, "custom-headers", "r", []string{}, "Custom Headers, <key>:<value> (e.g CustomHeaderKey:CustomHeaderValue AnotherHeader:AnotherValue)")
|
||||
// label selector flag
|
||||
AnalyzeCmd.Flags().StringVarP(&labelSelector, "selector", "L", "", "Label selector (label query) to filter on, supports '=', '==', and '!='. (e.g. -L key1=value1,key2=value2). Matching objects must satisfy all of the specified label constraints.")
|
||||
// print stats
|
||||
AnalyzeCmd.Flags().BoolVarP(&withStats, "with-stat", "s", false, "Print analysis stats. This option disables errors display.")
|
||||
}
|
||||
|
Reference in New Issue
Block a user