Skip to content

Commit

Permalink
Add jobName to metrics (kube-burner#669)
Browse files Browse the repository at this point in the history
## Type of change

- [ ] Refactor
- [ ] New feature
- [x] Bug fix
- [ ] Optimization
- [ ] Documentation Update

## Description

Adding job name back to metrics.

## Related Tickets & Documents

- Related Issue #
- Closes kube-burner#668

Signed-off-by: Raul Sevilla <[email protected]>
  • Loading branch information
rsevilla87 authored Jul 24, 2024
1 parent 2b0a32b commit d683cbb
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 3 deletions.
1 change: 1 addition & 0 deletions pkg/measurements/metrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ type LatencyQuantiles struct {
Avg int `json:"avg"`
Timestamp time.Time `json:"timestamp"`
MetricName string `json:"metricName"`
JobName string `json:"jobName,omitempty"`
Metadata interface{} `json:"metadata,omitempty"`
}

Expand Down
4 changes: 4 additions & 0 deletions pkg/measurements/pod_latency.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ type podMetric struct {
PodReadyLatency int `json:"podReadyLatency"`
MetricName string `json:"metricName"`
UUID string `json:"uuid"`
JobName string `json:"jobName,omitempty"`
Namespace string `json:"namespace"`
Name string `json:"podName"`
NodeName string `json:"nodeName"`
Expand Down Expand Up @@ -82,6 +83,7 @@ func (p *podLatency) handleCreatePod(obj interface{}) {
MetricName: podLatencyMeasurement,
UUID: globalCfg.UUID,
Metadata: factory.metadata,
JobName: factory.jobConfig.Name,
}
}
}
Expand Down Expand Up @@ -216,6 +218,7 @@ func (p *podLatency) collect(measurementWg *sync.WaitGroup) {
initialized: initialized,
containersReady: containersReady,
podReady: podReady,
JobName: factory.jobConfig.Name,
}
}
}
Expand Down Expand Up @@ -323,6 +326,7 @@ func (p *podLatency) calcQuantiles() {
latencySummary.UUID = globalCfg.UUID
latencySummary.Metadata = factory.metadata
latencySummary.MetricName = podLatencyQuantilesMeasurement
latencySummary.JobName = factory.jobConfig.Name
return latencySummary
}
for podCondition, latencies := range quantileMap {
Expand Down
3 changes: 3 additions & 0 deletions pkg/measurements/service_latency.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ type svcMetric struct {
Name string `json:"service"`
Metadata interface{} `json:"metadata,omitempty"`
ServiceType corev1.ServiceType `json:"type"`
JobName string `json:"jobName,omitempty"`
}

func init() {
Expand Down Expand Up @@ -169,6 +170,7 @@ func (s *serviceLatency) handleCreateSvc(obj interface{}) {
UUID: globalCfg.UUID,
Metadata: factory.metadata,
IPAssignedLatency: ipAssignedLatency,
JobName: factory.jobConfig.Name,
}
s.metricLock.Unlock()
}(svc)
Expand Down Expand Up @@ -261,6 +263,7 @@ func (s *serviceLatency) normalizeMetrics() {
latencySummary.Timestamp = time.Now().UTC()
latencySummary.Metadata = factory.metadata
latencySummary.MetricName = svcLatencyQuantilesMeasurement
latencySummary.JobName = factory.jobConfig.Name
return latencySummary
}
if len(s.metrics) > 0 {
Expand Down
6 changes: 3 additions & 3 deletions pkg/measurements/vmi_latency.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ type vmiMetric struct {
Namespace string `json:"namespace"`
Name string `json:"podName"`
NodeName string `json:"nodeName"`
JobName string `json:"jobName,omitempty"`
}

type vmiLatency struct {
Expand Down Expand Up @@ -107,6 +108,7 @@ func (p *vmiLatency) handleCreateVM(obj interface{}) {
MetricName: vmiLatencyMeasurement,
UUID: globalCfg.UUID,
Metadata: factory.metadata,
JobName: factory.jobConfig.Name,
}
}
}
Expand Down Expand Up @@ -405,20 +407,18 @@ func (p *vmiLatency) normalizeMetrics() {
continue
}
m.VMReadyLatency = int(m.vmReady.Sub(m.Timestamp).Milliseconds())

m.VMICreatedLatency = int(m.vmiCreated.Sub(m.Timestamp).Milliseconds())
m.VMIPendingLatency = int(m.vmiPending.Sub(m.Timestamp).Milliseconds())
m.VMISchedulingLatency = int(m.vmiScheduling.Sub(m.Timestamp).Milliseconds())
m.VMIScheduledLatency = int(m.vmiScheduled.Sub(m.Timestamp).Milliseconds())
m.VMIReadyLatency = int(m.vmiReady.Sub(m.Timestamp).Milliseconds())
m.VMIRunningLatency = int(m.vmiRunning.Sub(m.Timestamp).Milliseconds())

m.PodCreatedLatency = int(m.podCreated.Sub(m.Timestamp).Milliseconds())
m.PodScheduledLatency = int(m.podScheduled.Sub(m.Timestamp).Milliseconds())
m.PodInitializedLatency = int(m.podInitialized.Sub(m.Timestamp).Milliseconds())
m.PodContainersReadyLatency = int(m.podContainersReady.Sub(m.Timestamp).Milliseconds())
m.PodReadyLatency = int(m.podReady.Sub(m.Timestamp).Milliseconds())

m.JobName = factory.jobConfig.Name
p.normLatencies = append(p.normLatencies, m)
}
}
Expand Down
1 change: 1 addition & 0 deletions pkg/prometheus/prometheus.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ func (p *Prometheus) createMetric(query, metricName string, job Job, labels mode
Query: query,
MetricName: metricName,
Timestamp: timestamp,
JobName: job.JobConfig.Name,
}
if len(p.metadata) != 0 {
m.Metadata = p.metadata
Expand Down
1 change: 1 addition & 0 deletions pkg/prometheus/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,5 +72,6 @@ type metric struct {
Query string `json:"query"`
ChurnMetric bool `json:"churnMetric,omitempty"`
MetricName string `json:"metricName,omitempty"`
JobName string `json:"jobName,omitempty"`
Metadata interface{} `json:"metadata,omitempty"`
}

0 comments on commit d683cbb

Please sign in to comment.