Skip to content

Commit

Permalink
rework tasks metrics report to avoid triggering var-naming errors whe…
Browse files Browse the repository at this point in the history
…n golangci-lint executes
  • Loading branch information
gmllt authored and benjaminguttmann-avtq committed Oct 26, 2023
1 parent fea94eb commit 414b601
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions collectors/tasks.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,16 +194,16 @@ func (c TasksCollector) reportTasksMetrics(objs *models.CFObjects, ch chan<- pro
c.tasksOldestCreatedAtMetric.Reset()

type keyType struct {
application_id string
state string
applicationID string
state string
}
groupedTasks := map[keyType][]models.Task{}
for _, task := range objs.Tasks {
application_id := "unavailable"
applicationID := "unavailable"
if app, ok := task.Relationships["app"]; ok && app.GUID != "" {
application_id = app.GUID
applicationID = app.GUID
}
key := keyType{application_id, string(task.State)}
key := keyType{applicationID, string(task.State)}

existingValue, ok := groupedTasks[key]
if !ok {
Expand All @@ -214,12 +214,12 @@ func (c TasksCollector) reportTasksMetrics(objs *models.CFObjects, ch chan<- pro

for key, tasks := range groupedTasks {
c.taskInfoMetric.WithLabelValues(
key.application_id,
key.applicationID,
key.state,
).Set(float64(1))

c.tasksCountMetric.WithLabelValues(
key.application_id,
key.applicationID,
key.state,
).Set(float64(len(tasks)))

Expand All @@ -228,7 +228,7 @@ func (c TasksCollector) reportTasksMetrics(objs *models.CFObjects, ch chan<- pro
memorySum += task.MemoryInMb
}
c.tasksMemoryMbSumMetric.WithLabelValues(
key.application_id,
key.applicationID,
key.state,
).Set(float64(memorySum))

Expand All @@ -237,7 +237,7 @@ func (c TasksCollector) reportTasksMetrics(objs *models.CFObjects, ch chan<- pro
diskSum += task.DiskInMb
}
c.tasksDiskQuotaMbSumMetric.WithLabelValues(
key.application_id,
key.applicationID,
key.state,
).Set(float64(diskSum))

Expand All @@ -248,7 +248,7 @@ func (c TasksCollector) reportTasksMetrics(objs *models.CFObjects, ch chan<- pro
}
}
c.tasksOldestCreatedAtMetric.WithLabelValues(
key.application_id,
key.applicationID,
key.state,
).Set(float64(createdAtOldest.Unix()))
}
Expand Down

0 comments on commit 414b601

Please sign in to comment.