Skip to content
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

feat: add stats option to analyze command for performance insights #1237

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

matthisholleville
Copy link
Contributor

Closes #

📑 Description

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.

✅ Checks

  • My pull request adheres to the code style of this project
  • My code requires changes to the documentation
  • I have updated the documentation as required
  • All the tests have passed

ℹ Additional Information

(matthisholleville) ➜  k8sgpt git:(main) ✗ time ./bin/k8sgpt analyze -s
The stats mode allows for debugging and understanding the time taken by an analysis by displaying the statistics of each analyzer.
- Analyzer Ingress took 47.125583ms 
- Analyzer PersistentVolumeClaim took 53.009167ms 
- Analyzer CronJob took 57.517792ms 
- Analyzer Deployment took 156.6205ms 
- Analyzer Node took 160.109833ms 
- Analyzer ReplicaSet took 245.938333ms 
- Analyzer StatefulSet took 448.0455ms 
- Analyzer Pod took 5.662594708s 
- Analyzer Service took 38.583359166s 

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>
@matthisholleville matthisholleville requested review from a team as code owners August 26, 2024 12:15
@matthisholleville
Copy link
Contributor Author

matthisholleville commented Aug 26, 2024

Linked to this issue #1236

@AlexsJones
Copy link
Member

If we do -o json -s what will happen, will it add a field into the json object?

@matthisholleville
Copy link
Contributor Author

The current implementation does not support json as an output.

@matthisholleville
Copy link
Contributor Author

When this option is selected, the results are not displayed. Only the statistics are shown. If we try to display both, in the case of an analysis with many results, it becomes very difficult to visualize the statistics.

defer mutex.Unlock()

if err != nil {
a.Stats = append(a.Stats, stat)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we want to make it optional, shouldn't make sense to gather stats only when the user wants to enable stats reporting ?

@AlexsJones
Copy link
Member

The current implementation does not support json as an output.

Might be worth considering if we want to show the results and time taken

@matthisholleville
Copy link
Contributor Author

@AlexsJones stats implementation is global to analyzer. The results display the errors reported by an analyzer. In my opinion, these are two different notions. We could also display the stats in json format, if that's useful.

_Print analysis stats_

```
k8sgpt analyze -s
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't see a world where you'd want to run this without capturing the output in some format.
But for those that do, perhaps... k8sgpt analyze --stats --no-output ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Proposed
Development

Successfully merging this pull request may close these issues.

3 participants