Skip to content
This repository has been archived by the owner on May 3, 2022. It is now read-only.

Commit

Permalink
Merge pull request #173 from bookingcom/jgreff/release-metrics-2
Browse files Browse the repository at this point in the history
collector: don't group releases per cluster
  • Loading branch information
parhamdoustdar committed Sep 5, 2019
2 parents 542c0e6 + 4229528 commit b5cb6e6
Showing 1 changed file with 22 additions and 13 deletions.
35 changes: 22 additions & 13 deletions cmd/shipper-state-metrics/collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ var (
relsDesc = prometheus.NewDesc(
fqn("releases"),
"Number of Release objects",
[]string{"namespace", "shipper_app", "cluster", "cond_type", "cond_status", "cond_reason"},
[]string{"namespace", "shipper_app", "cond_type", "cond_status", "cond_reason"},
nil,
)

Expand Down Expand Up @@ -155,6 +155,10 @@ func (ssm ShipperStateMetrics) collectReleases(ch chan<- prometheus.Metric) {
relAgesByCondition := make(map[string][]float64)

breakdown := make(map[string]float64)
conditions := []shipper.ReleaseConditionType{
shipper.ReleaseConditionTypeScheduled,
shipper.ReleaseConditionTypeComplete,
}
for _, rel := range rels {
var appName string
if len(rel.OwnerReferences) == 1 {
Expand All @@ -163,20 +167,25 @@ func (ssm ShipperStateMetrics) collectReleases(ch chan<- prometheus.Metric) {
appName = "unknown"
}

clusters := strings.Split(rel.Annotations[shipper.ReleaseClustersAnnotation], ",")
if len(clusters) == 0 || len(clusters) == 1 && clusters[0] == "" {
clusters = []string{"unknown"}
}
for _, c := range conditions {
var reason, status string

for _, cluster := range clusters {
for _, cond := range rel.Status.Conditions {
reason := cond.Reason
if reason == "" {
reason = "NoReason"
}
// it's either this or map[string]map[string]map[string]map[string]float64
breakdown[key(rel.Namespace, appName, cluster, string(cond.Type), string(cond.Status), reason)]++
cond := releaseutil.GetReleaseCondition(rel.Status, c)

if cond != nil {
reason = cond.Reason
status = string(cond.Status)
} else {
reason = "NoReason"
status = "False"
}

if reason == "" {
reason = "NoReason"
}

// it's either this or map[string]map[string]map[string]map[string]float64
breakdown[key(rel.Namespace, appName, string(c), status, reason)]++
}

// We're only interested in incomplete releases, as this metric
Expand Down

0 comments on commit b5cb6e6

Please sign in to comment.