Skip to content

Commit

Permalink
removed commented out print statements
Browse files Browse the repository at this point in the history
  • Loading branch information
reggeenr authored Sep 23, 2024
1 parent cc4c79c commit 322d197
Showing 1 changed file with 4 additions and 14 deletions.
18 changes: 4 additions & 14 deletions metrics-collector/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,12 +111,10 @@ func collectInstanceMetrics() {

// fetches all pods
pods := getAllPods(coreClientset, namespace, config)
// fmt.Println("Captured pods after " + strconv.FormatInt(time.Since(startTime).Milliseconds(), 10) + "ms")


// fetch all pod metrics
podMetrics := getAllPodMetrics(namespace, config)
// fmt.Println("Captured pod metrics after " + strconv.FormatInt(time.Since(startTime).Milliseconds(), 10) + "ms")


var wg sync.WaitGroup

for _, metric := range *podMetrics {
Expand All @@ -125,8 +123,6 @@ func collectInstanceMetrics() {
go func(podMetric *v1beta1.PodMetrics) {
defer wg.Done()

// fmt.Println("Starting with pod of '" + podMetric.Name + "' ...")

// Determine the component type (either app, job, build or unknown)
componentType := determineComponentType(podMetric)

Expand Down Expand Up @@ -182,7 +178,6 @@ func collectInstanceMetrics() {

// determine the actual disk usage
storageCurrent := obtainDiskUsage(coreClientset, namespace, podMetric.Name, userContainerName, config)
// fmt.Println("Obtained disk usage of '" + podMetric.Name + "' after " + strconv.FormatInt(time.Since(startTime).Milliseconds(), 10) + " ms")
stats.DiskUsage.Current = int64(storageCurrent)

// extract memory and cpu limits
Expand Down Expand Up @@ -263,8 +258,7 @@ func getAllPods(coreClientset *kubernetes.Clientset, namespace string, config *r

// Helper function to retrieve all pods from the Kube API
func obtainDiskUsage(coreClientset *kubernetes.Clientset, namespace string, pod string, container string, config *rest.Config) float64 {
// fmt.Println("obtainDiskUsage > pod: '" + pod + "', container: '" + container + "'")


// per default, we do not collect disk space statistics
if os.Getenv("COLLECT_DISKUSAGE") != "true" {
return 0
Expand All @@ -290,7 +284,6 @@ func obtainDiskUsage(coreClientset *kubernetes.Clientset, namespace string, pod
option,
scheme.ParameterCodec,
)
// fmt.Println("obtainDiskUsage - URL: '" + req.URL().String() + "'")
exec, reqErr := remotecommand.NewSPDYExecutor(config, "POST", req.URL())
if reqErr != nil {
fmt.Println("obtainDiskUsage of pod:" + pod + "/container:" + container + " failed POST err - " + reqErr.Error())
Expand All @@ -316,17 +309,14 @@ func obtainDiskUsage(coreClientset *kubernetes.Clientset, namespace string, pod

return float64(0)
}
// fmt.Println("obtainDiskUsage of pod:" + pod + "/container:" + container + ": '" + diskUsageOutputStr + "'")


// Parse the output "4000 /" by splitting the words
diskUsageOutput := strings.Fields(strings.TrimSuffix(diskUsageOutputStr, "\n"))
if len(diskUsageOutput) > 2 {
fmt.Println("obtainDiskUsage of pod:" + pod + "/container:" + container + " - len(diskUsageOutput): '" + strconv.Itoa(len(diskUsageOutput)) + "'")
return float64(0)
}

// fmt.Println("obtainDiskUsage of pod:" + pod + "/container:" + container + " - diskUsageOutput[0]: '" + diskUsageOutput[0] + "', len(diskUsageOutput): " + strconv.Itoa(len(diskUsageOutput)))

// Parse the integer string to a float64
ephemeralStorage, parseErr := strconv.ParseFloat(diskUsageOutput[0], 64)
if parseErr != nil {
Expand Down

0 comments on commit 322d197

Please sign in to comment.