Skip to content

Commit 6439019

Browse files
committed
📊 Add collector for metrics
1 parent 54b9d6c commit 6439019

5 files changed

Lines changed: 270 additions & 112 deletions

File tree

‎cmd/feature/install.go‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,13 @@ func runAnsiblePlaybook(featurePath string, vars map[string]any) error {
5252
}
5353

5454
cmd := exec.Command("ansible-playbook", args...)
55+
cmd.Env = append(os.Environ(),
56+
"ANSIBLE_DISPLAY_OK_HOSTS=0",
57+
"ANSIBLE_DISPLAY_FAILED_STDERR=0",
58+
"ANSIBLE_DISPLAY_SKIPPED_HOSTS=0",
59+
"ANSIBLE_SHOW_CUSTOM_STATS=0",
60+
"ANSIBLE_STDOUT_CALLBACK=community.general.unixy",
61+
)
5562
cmd.Stdout = os.Stdout
5663
cmd.Stderr = os.Stderr
5764

‎cmd/info/metrics.go‎

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,14 @@ type metrics struct {
2323
}
2424

2525
func formatCPUTime(seconds float64) string {
26-
if seconds < 60 {
26+
switch {
27+
case seconds < 60:
2728
return fmt.Sprintf("%.1fs", seconds)
28-
}
29-
30-
if seconds < 3600 {
29+
case seconds < 3600:
3130
return fmt.Sprintf("%.1fm", seconds/60)
31+
default:
32+
return fmt.Sprintf("%.1fh", seconds/3600)
3233
}
33-
34-
return fmt.Sprintf("%.1fh", seconds/3600)
3534
}
3635

3736
func getMetrics(includeGPU bool) (*metrics, error) {
@@ -70,8 +69,7 @@ func getMetrics(includeGPU bool) (*metrics, error) {
7069
}
7170

7271
if includeGPU {
73-
gpuStats, err := internalIO.GetGPUStats()
74-
if err == nil {
72+
if gpuStats, err := internalIO.GetGPUStats(); err == nil {
7573
m.gpu = gpuStats
7674
}
7775
}

‎cmd/info/version.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
package info
22

3-
var Version = "0.0.46"
3+
var Version = "0.0.47"

0 commit comments

Comments
 (0)