Skip to content

Commit

Permalink
Merge pull request #104 from gmllt/fix-wrong-label-applicationID
Browse files Browse the repository at this point in the history
fix wrongly renamed label applicationID
  • Loading branch information
gmllt committed Oct 17, 2023
2 parents 25bffe3 + 04910ba commit fea94eb
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 21 deletions.
10 changes: 5 additions & 5 deletions collectors/applications.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func NewApplicationsCollector(
Help: "Labeled Cloud Foundry Application information with a constant '1' value.",
ConstLabels: prometheus.Labels{"environment": environment, "deployment": deployment},
},
[]string{"applicationID", "application_name", "detected_buildpack", "buildpack", "organization_id", "organization_name", "space_id", "space_name", "stack_id", "state"},
[]string{"application_id", "application_name", "detected_buildpack", "buildpack", "organization_id", "organization_name", "space_id", "space_name", "stack_id", "state"},
)

applicationInstancesMetric := prometheus.NewGaugeVec(
Expand All @@ -50,7 +50,7 @@ func NewApplicationsCollector(
Help: "Number of desired Cloud Foundry Application Instances.",
ConstLabels: prometheus.Labels{"environment": environment, "deployment": deployment},
},
[]string{"applicationID", "application_name", "organization_id", "organization_name", "space_id", "space_name", "state"},
[]string{"application_id", "application_name", "organization_id", "organization_name", "space_id", "space_name", "state"},
)

applicationInstancesRunningMetric := prometheus.NewGaugeVec(
Expand All @@ -61,7 +61,7 @@ func NewApplicationsCollector(
Help: "Number of running Cloud Foundry Application Instances.",
ConstLabels: prometheus.Labels{"environment": environment, "deployment": deployment},
},
[]string{"applicationID", "application_name", "organization_id", "organization_name", "space_id", "space_name", "state"},
[]string{"application_id", "application_name", "organization_id", "organization_name", "space_id", "space_name", "state"},
)

applicationMemoryMbMetric := prometheus.NewGaugeVec(
Expand All @@ -72,7 +72,7 @@ func NewApplicationsCollector(
Help: "Cloud Foundry Application Memory (Mb).",
ConstLabels: prometheus.Labels{"environment": environment, "deployment": deployment},
},
[]string{"applicationID", "application_name", "organization_id", "organization_name", "space_id", "space_name"},
[]string{"application_id", "application_name", "organization_id", "organization_name", "space_id", "space_name"},
)

applicationDiskQuotaMbMetric := prometheus.NewGaugeVec(
Expand All @@ -83,7 +83,7 @@ func NewApplicationsCollector(
Help: "Cloud Foundry Application Disk Quota (Mb).",
ConstLabels: prometheus.Labels{"environment": environment, "deployment": deployment},
},
[]string{"applicationID", "application_name", "organization_id", "organization_name", "space_id", "space_name"},
[]string{"application_id", "application_name", "organization_id", "organization_name", "space_id", "space_name"},
)

applicationsScrapesTotalMetric := prometheus.NewCounter(
Expand Down
2 changes: 1 addition & 1 deletion collectors/service_bindings.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func NewServiceBindingsCollector(
Help: "Labeled Cloud Foundry Service Binding information with a constant '1' value.",
ConstLabels: prometheus.Labels{"environment": environment, "deployment": deployment},
},
[]string{"service_binding_id", "applicationID", "service_instance_id"},
[]string{"service_binding_id", "application_id", "service_instance_id"},
)

serviceBindingsScrapesTotalMetric := prometheus.NewCounter(
Expand Down
30 changes: 15 additions & 15 deletions collectors/tasks.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func NewTasksCollector(
Help: "Labeled Cloud Foundry Task information with a constant '1' value.",
ConstLabels: prometheus.Labels{"environment": environment, "deployment": deployment},
},
[]string{"applicationID", "state"},
[]string{"application_id", "state"},
)

tasksCountMetric := prometheus.NewGaugeVec(
Expand All @@ -47,7 +47,7 @@ func NewTasksCollector(
Help: "Number of Cloud Foundry Tasks.",
ConstLabels: prometheus.Labels{"environment": environment, "deployment": deployment},
},
[]string{"applicationID", "state"},
[]string{"application_id", "state"},
)

tasksMemoryMbSumMetric := prometheus.NewGaugeVec(
Expand All @@ -58,7 +58,7 @@ func NewTasksCollector(
Help: "Sum of Cloud Foundry Tasks Memory (Mb).",
ConstLabels: prometheus.Labels{"environment": environment, "deployment": deployment},
},
[]string{"applicationID", "state"},
[]string{"application_id", "state"},
)

tasksDiskQuotaMbSumMetric := prometheus.NewGaugeVec(
Expand All @@ -69,7 +69,7 @@ func NewTasksCollector(
Help: "Sum of Cloud Foundry Tasks Disk Quota (Mb).",
ConstLabels: prometheus.Labels{"environment": environment, "deployment": deployment},
},
[]string{"applicationID", "state"},
[]string{"application_id", "state"},
)

tasksOldestCreatedAtMetric := prometheus.NewGaugeVec(
Expand All @@ -80,7 +80,7 @@ func NewTasksCollector(
Help: "Number of seconds since 1970 of creation time of oldest Cloud Foundry task.",
ConstLabels: prometheus.Labels{"environment": environment, "deployment": deployment},
},
[]string{"applicationID", "state"},
[]string{"application_id", "state"},
)

tasksScrapesTotalMetric := prometheus.NewCounter(
Expand Down Expand Up @@ -194,16 +194,16 @@ func (c TasksCollector) reportTasksMetrics(objs *models.CFObjects, ch chan<- pro
c.tasksOldestCreatedAtMetric.Reset()

type keyType struct {
applicationID string
state string
application_id string

Check warning on line 197 in collectors/tasks.go

View workflow job for this annotation

GitHub Actions / linter

var-naming: don't use underscores in Go names; struct field application_id should be applicationID (revive)

Check warning on line 197 in collectors/tasks.go

View workflow job for this annotation

GitHub Actions / linter

var-naming: don't use underscores in Go names; struct field application_id should be applicationID (revive)
state string
}
groupedTasks := map[keyType][]models.Task{}
for _, task := range objs.Tasks {
applicationID := "unavailable"
application_id := "unavailable"

Check warning on line 202 in collectors/tasks.go

View workflow job for this annotation

GitHub Actions / linter

var-naming: don't use underscores in Go names; var application_id should be applicationID (revive)

Check warning on line 202 in collectors/tasks.go

View workflow job for this annotation

GitHub Actions / linter

var-naming: don't use underscores in Go names; var application_id should be applicationID (revive)
if app, ok := task.Relationships["app"]; ok && app.GUID != "" {
applicationID = app.GUID
application_id = app.GUID
}
key := keyType{applicationID, string(task.State)}
key := keyType{application_id, 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.applicationID,
key.application_id,
key.state,
).Set(float64(1))

c.tasksCountMetric.WithLabelValues(
key.applicationID,
key.application_id,
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.applicationID,
key.application_id,
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.applicationID,
key.application_id,
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.applicationID,
key.application_id,
key.state,
).Set(float64(createdAtOldest.Unix()))
}
Expand Down

0 comments on commit fea94eb

Please sign in to comment.