Skip to content

Commit 7d378c9

Browse files
authored
Merge pull request #136 from jackatbancast/fixup-worker-metrics
fix: Correct worker metrics to provide metrics across all dimensions
2 parents ddafaf4 + 191cd85 commit 7d378c9

File tree

2 files changed

+14
-15
lines changed

2 files changed

+14
-15
lines changed

cloudflare.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -537,7 +537,6 @@ func fetchWorkerTotals(accountID string) (*cloudflareResponseAccts, error) {
537537
dimensions {
538538
scriptName
539539
status
540-
datetime
541540
}
542541
543542
sum {

prometheus.go

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -216,25 +216,25 @@ var (
216216
workerRequests = prometheus.NewCounterVec(prometheus.CounterOpts{
217217
Name: workerRequestsMetricName.String(),
218218
Help: "Number of requests sent to worker by script name",
219-
}, []string{"script_name", "account"},
219+
}, []string{"script_name", "account", "status"},
220220
)
221221

222222
workerErrors = prometheus.NewCounterVec(prometheus.CounterOpts{
223223
Name: workerErrorsMetricName.String(),
224224
Help: "Number of errors by script name",
225-
}, []string{"script_name", "account"},
225+
}, []string{"script_name", "account", "status"},
226226
)
227227

228228
workerCPUTime = prometheus.NewGaugeVec(prometheus.GaugeOpts{
229229
Name: workerCPUTimeMetricName.String(),
230230
Help: "CPU time quantiles by script name",
231-
}, []string{"script_name", "account", "quantile"},
231+
}, []string{"script_name", "account", "status", "quantile"},
232232
)
233233

234234
workerDuration = prometheus.NewGaugeVec(prometheus.GaugeOpts{
235235
Name: workerDurationMetricName.String(),
236236
Help: "Duration quantiles by script name (GB*s)",
237-
}, []string{"script_name", "account", "quantile"},
237+
}, []string{"script_name", "account", "status", "quantile"},
238238
)
239239

240240
poolHealthStatus = prometheus.NewGaugeVec(prometheus.GaugeOpts{
@@ -457,16 +457,16 @@ func fetchWorkerAnalytics(account cloudflare.Account, wg *sync.WaitGroup) {
457457

458458
for _, a := range r.Viewer.Accounts {
459459
for _, w := range a.WorkersInvocationsAdaptive {
460-
workerRequests.With(prometheus.Labels{"script_name": w.Dimensions.ScriptName, "account": accountName}).Add(float64(w.Sum.Requests))
461-
workerErrors.With(prometheus.Labels{"script_name": w.Dimensions.ScriptName, "account": accountName}).Add(float64(w.Sum.Errors))
462-
workerCPUTime.With(prometheus.Labels{"script_name": w.Dimensions.ScriptName, "account": accountName, "quantile": "P50"}).Set(float64(w.Quantiles.CPUTimeP50))
463-
workerCPUTime.With(prometheus.Labels{"script_name": w.Dimensions.ScriptName, "account": accountName, "quantile": "P75"}).Set(float64(w.Quantiles.CPUTimeP75))
464-
workerCPUTime.With(prometheus.Labels{"script_name": w.Dimensions.ScriptName, "account": accountName, "quantile": "P99"}).Set(float64(w.Quantiles.CPUTimeP99))
465-
workerCPUTime.With(prometheus.Labels{"script_name": w.Dimensions.ScriptName, "account": accountName, "quantile": "P999"}).Set(float64(w.Quantiles.CPUTimeP999))
466-
workerDuration.With(prometheus.Labels{"script_name": w.Dimensions.ScriptName, "account": accountName, "quantile": "P50"}).Set(float64(w.Quantiles.DurationP50))
467-
workerDuration.With(prometheus.Labels{"script_name": w.Dimensions.ScriptName, "account": accountName, "quantile": "P75"}).Set(float64(w.Quantiles.DurationP75))
468-
workerDuration.With(prometheus.Labels{"script_name": w.Dimensions.ScriptName, "account": accountName, "quantile": "P99"}).Set(float64(w.Quantiles.DurationP99))
469-
workerDuration.With(prometheus.Labels{"script_name": w.Dimensions.ScriptName, "account": accountName, "quantile": "P999"}).Set(float64(w.Quantiles.DurationP999))
460+
workerRequests.With(prometheus.Labels{"script_name": w.Dimensions.ScriptName, "account": accountName, "status": w.Dimensions.Status}).Add(float64(w.Sum.Requests))
461+
workerErrors.With(prometheus.Labels{"script_name": w.Dimensions.ScriptName, "account": accountName, "status": w.Dimensions.Status}).Add(float64(w.Sum.Errors))
462+
workerCPUTime.With(prometheus.Labels{"script_name": w.Dimensions.ScriptName, "account": accountName, "status": w.Dimensions.Status, "quantile": "P50"}).Set(float64(w.Quantiles.CPUTimeP50))
463+
workerCPUTime.With(prometheus.Labels{"script_name": w.Dimensions.ScriptName, "account": accountName, "status": w.Dimensions.Status, "quantile": "P75"}).Set(float64(w.Quantiles.CPUTimeP75))
464+
workerCPUTime.With(prometheus.Labels{"script_name": w.Dimensions.ScriptName, "account": accountName, "status": w.Dimensions.Status, "quantile": "P99"}).Set(float64(w.Quantiles.CPUTimeP99))
465+
workerCPUTime.With(prometheus.Labels{"script_name": w.Dimensions.ScriptName, "account": accountName, "status": w.Dimensions.Status, "quantile": "P999"}).Set(float64(w.Quantiles.CPUTimeP999))
466+
workerDuration.With(prometheus.Labels{"script_name": w.Dimensions.ScriptName, "account": accountName, "status": w.Dimensions.Status, "quantile": "P50"}).Set(float64(w.Quantiles.DurationP50))
467+
workerDuration.With(prometheus.Labels{"script_name": w.Dimensions.ScriptName, "account": accountName, "status": w.Dimensions.Status, "quantile": "P75"}).Set(float64(w.Quantiles.DurationP75))
468+
workerDuration.With(prometheus.Labels{"script_name": w.Dimensions.ScriptName, "account": accountName, "status": w.Dimensions.Status, "quantile": "P99"}).Set(float64(w.Quantiles.DurationP99))
469+
workerDuration.With(prometheus.Labels{"script_name": w.Dimensions.ScriptName, "account": accountName, "status": w.Dimensions.Status, "quantile": "P999"}).Set(float64(w.Quantiles.DurationP999))
470470
}
471471
}
472472
}

0 commit comments

Comments
 (0)