Skip to content

Commit

Permalink
Update deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
CatherineF-dev committed Dec 12, 2023
1 parent 5614899 commit 37015ff
Showing 1 changed file with 123 additions and 69 deletions.
192 changes: 123 additions & 69 deletions internal/store/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ func deploymentMetricFamilies(allowAnnotationsList, allowLabelsList []string) []
})
}

metric.SetLabelKeys(ms, []string{})

return &metric.Family{
Metrics: ms,
}
Expand All @@ -70,13 +72,17 @@ func deploymentMetricFamilies(allowAnnotationsList, allowLabelsList []string) []
basemetrics.STABLE,
"",
wrapDeploymentFunc(func(d *v1.Deployment) *metric.Family {
return &metric.Family{
Metrics: []*metric.Metric{
{
Value: float64(d.Status.Replicas),
},
ms := []*metric.Metric{
{
Value: float64(d.Status.Replicas),
},
}

metric.SetLabelKeys(ms, []string{})

return &metric.Family{
Metrics: ms,
}
}),
),
*generator.NewFamilyGeneratorWithStability(
Expand All @@ -86,13 +92,17 @@ func deploymentMetricFamilies(allowAnnotationsList, allowLabelsList []string) []
basemetrics.STABLE,
"",
wrapDeploymentFunc(func(d *v1.Deployment) *metric.Family {
return &metric.Family{
Metrics: []*metric.Metric{
{
Value: float64(d.Status.ReadyReplicas),
},
ms := []*metric.Metric{
{
Value: float64(d.Status.ReadyReplicas),
},
}

metric.SetLabelKeys(ms, []string{})

return &metric.Family{
Metrics: ms,
}
}),
),
*generator.NewFamilyGeneratorWithStability(
Expand All @@ -102,13 +112,17 @@ func deploymentMetricFamilies(allowAnnotationsList, allowLabelsList []string) []
basemetrics.STABLE,
"",
wrapDeploymentFunc(func(d *v1.Deployment) *metric.Family {
return &metric.Family{
Metrics: []*metric.Metric{
{
Value: float64(d.Status.AvailableReplicas),
},
ms := []*metric.Metric{
{
Value: float64(d.Status.AvailableReplicas),
},
}

metric.SetLabelKeys(ms, []string{})

return &metric.Family{
Metrics: ms,
}
}),
),
*generator.NewFamilyGeneratorWithStability(
Expand All @@ -118,13 +132,17 @@ func deploymentMetricFamilies(allowAnnotationsList, allowLabelsList []string) []
basemetrics.STABLE,
"",
wrapDeploymentFunc(func(d *v1.Deployment) *metric.Family {
return &metric.Family{
Metrics: []*metric.Metric{
{
Value: float64(d.Status.UnavailableReplicas),
},
ms := []*metric.Metric{
{
Value: float64(d.Status.UnavailableReplicas),
},
}

metric.SetLabelKeys(ms, []string{})

return &metric.Family{
Metrics: ms,
}
}),
),
*generator.NewFamilyGeneratorWithStability(
Expand All @@ -134,13 +152,17 @@ func deploymentMetricFamilies(allowAnnotationsList, allowLabelsList []string) []
basemetrics.STABLE,
"",
wrapDeploymentFunc(func(d *v1.Deployment) *metric.Family {
return &metric.Family{
Metrics: []*metric.Metric{
{
Value: float64(d.Status.UpdatedReplicas),
},
ms := []*metric.Metric{
{
Value: float64(d.Status.UpdatedReplicas),
},
}

metric.SetLabelKeys(ms, []string{})

return &metric.Family{
Metrics: ms,
}
}),
),
*generator.NewFamilyGeneratorWithStability(
Expand All @@ -150,13 +172,17 @@ func deploymentMetricFamilies(allowAnnotationsList, allowLabelsList []string) []
basemetrics.STABLE,
"",
wrapDeploymentFunc(func(d *v1.Deployment) *metric.Family {
return &metric.Family{
Metrics: []*metric.Metric{
{
Value: float64(d.Status.ObservedGeneration),
},
ms := []*metric.Metric{
{
Value: float64(d.Status.ObservedGeneration),
},
}

metric.SetLabelKeys(ms, []string{})

return &metric.Family{
Metrics: ms,
}
}),
),
*generator.NewFamilyGeneratorWithStability(
Expand Down Expand Up @@ -192,13 +218,17 @@ func deploymentMetricFamilies(allowAnnotationsList, allowLabelsList []string) []
basemetrics.STABLE,
"",
wrapDeploymentFunc(func(d *v1.Deployment) *metric.Family {
return &metric.Family{
Metrics: []*metric.Metric{
{
Value: float64(*d.Spec.Replicas),
},
ms := []*metric.Metric{
{
Value: float64(*d.Spec.Replicas),
},
}

metric.SetLabelKeys(ms, []string{})

return &metric.Family{
Metrics: ms,
}
}),
),
*generator.NewFamilyGeneratorWithStability(
Expand All @@ -208,13 +238,17 @@ func deploymentMetricFamilies(allowAnnotationsList, allowLabelsList []string) []
basemetrics.STABLE,
"",
wrapDeploymentFunc(func(d *v1.Deployment) *metric.Family {
return &metric.Family{
Metrics: []*metric.Metric{
{
Value: boolFloat64(d.Spec.Paused),
},
ms := []*metric.Metric{
{
Value: boolFloat64(d.Spec.Paused),
},
}

metric.SetLabelKeys(ms, []string{})

return &metric.Family{
Metrics: ms,
}
}),
),
*generator.NewFamilyGeneratorWithStability(
Expand All @@ -233,13 +267,17 @@ func deploymentMetricFamilies(allowAnnotationsList, allowLabelsList []string) []
panic(err)
}

return &metric.Family{
Metrics: []*metric.Metric{
{
Value: float64(maxUnavailable),
},
ms := []*metric.Metric{
{
Value: float64(maxUnavailable),
},
}

metric.SetLabelKeys(ms, []string{})

return &metric.Family{
Metrics: ms,
}
}),
),
*generator.NewFamilyGeneratorWithStability(
Expand All @@ -258,13 +296,17 @@ func deploymentMetricFamilies(allowAnnotationsList, allowLabelsList []string) []
panic(err)
}

return &metric.Family{
Metrics: []*metric.Metric{
{
Value: float64(maxSurge),
},
ms := []*metric.Metric{
{
Value: float64(maxSurge),
},
}

metric.SetLabelKeys(ms, []string{})

return &metric.Family{
Metrics: ms,
}
}),
),
*generator.NewFamilyGeneratorWithStability(
Expand All @@ -274,13 +316,17 @@ func deploymentMetricFamilies(allowAnnotationsList, allowLabelsList []string) []
basemetrics.STABLE,
"",
wrapDeploymentFunc(func(d *v1.Deployment) *metric.Family {
return &metric.Family{
Metrics: []*metric.Metric{
{
Value: float64(d.ObjectMeta.Generation),
},
ms := []*metric.Metric{
{
Value: float64(d.ObjectMeta.Generation),
},
}

metric.SetLabelKeys(ms, []string{})

return &metric.Family{
Metrics: ms,
}
}),
),
*generator.NewFamilyGeneratorWithStability(
Expand All @@ -294,15 +340,19 @@ func deploymentMetricFamilies(allowAnnotationsList, allowLabelsList []string) []
return &metric.Family{}
}
annotationKeys, annotationValues := createPrometheusLabelKeysValues("annotation", d.Annotations, allowAnnotationsList)
return &metric.Family{
Metrics: []*metric.Metric{
{
LabelKeys: annotationKeys,
LabelValues: annotationValues,
Value: 1,
},
ms := []*metric.Metric{
{
LabelKeys: annotationKeys,
LabelValues: annotationValues,
Value: 1,
},
}

metric.SetLabelKeys(ms, annotationKeys)

return &metric.Family{
Metrics: ms,
}
}),
),
*generator.NewFamilyGeneratorWithStability(
Expand All @@ -316,15 +366,19 @@ func deploymentMetricFamilies(allowAnnotationsList, allowLabelsList []string) []
return &metric.Family{}
}
labelKeys, labelValues := createPrometheusLabelKeysValues("label", d.Labels, allowLabelsList)
return &metric.Family{
Metrics: []*metric.Metric{
{
LabelKeys: labelKeys,
LabelValues: labelValues,
Value: 1,
},
ms := []*metric.Metric{
{
LabelValues: labelValues,

Value: 1,
},
}

metric.SetLabelKeys(ms, labelKeys)

return &metric.Family{
Metrics: ms,
}
}),
),
}
Expand Down

0 comments on commit 37015ff

Please sign in to comment.