tetratelabs / istio-cost-analyzer

Cluster Egress Cost Analysis
Apache License 2.0
12 stars 2 forks source link

Start using logrus/better logging #18

Open adiprerepa opened 2 years ago

adiprerepa commented 2 years ago

We kind of just scatter fmt.Printf or log.Printf everywhere, we should probably use something like logrus so we can utilize scopes.

We should have a normal output mode (no flags) and a verbose output mode (-v). The normal output mode is the baseline, while verbose mode should have debug info.

Normal:

Waiting for prometheus to be ready...
Prometheus is ready! (Code: 200)
Total: -

SOURCE WORKLOAD SOURCE LOCALITY DESTINATION WORKLOAD    DESTINATION LOCALITY    TRANSFERRED (MB)    COST 
productpage-v1  us-west1-c      details-v1              us-west1-c              1.070870            -       
productpage-v1  us-west1-b      reviews-v1              us-west1-b              0.356600            -       
productpage-v1  us-west1-b      reviews-v2              us-west1-b              0.355875            -       
productpage-v1  us-west1-b      reviews-v3              us-west1-b              0.356490            -   

Verbose:

Waiting for prometheus to be ready...
Prometheus is ready! (Code: 200)
Total: -

us-west1-b(productpage-v1) -> us-west1-c(details-v1): 1070870  |  link 0 / 4
<other debug runtime info>

SOURCE WORKLOAD SOURCE LOCALITY DESTINATION WORKLOAD    DESTINATION LOCALITY    TRANSFERRED (MB)    COST 
productpage-v1  us-west1-c      details-v1              us-west1-c              1.070870            -       
productpage-v1  us-west1-b      reviews-v1              us-west1-b              0.356600            -       
productpage-v1  us-west1-b      reviews-v2              us-west1-b              0.355875            -       
productpage-v1  us-west1-b      reviews-v3              us-west1-b              0.356490            -   

The goal is that users can run the tool with -v when they have issues and can possibly get insight into them, maybe making it part of the repository issue template.