Skip to content

Commit 1e8dfad

Browse files
authored
Merge pull request #9 from bigcommerce/wall-time
SD-11577: add worker wall time
2 parents 96a2ee9 + c9aeb40 commit 1e8dfad

File tree

3 files changed

+24
-0
lines changed

3 files changed

+24
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ Note: `ZONE_<name>` configuration is not supported as flag.
9696
```
9797
# HELP cloudflare_worker_cpu_time CPU time quantiles by script name
9898
# HELP cloudflare_worker_duration Duration quantiles by script name (GB*s)
99+
# HELP cloudflare_worker_wall_time Wall time quantiles by script name (microseconds)
99100
# HELP cloudflare_worker_errors_count Number of errors by script name
100101
# HELP cloudflare_worker_requests_count Number of requests sent to worker by script name
101102
# HELP cloudflare_zone_bandwidth_cached Cached bandwidth per zone in bytes

cloudflare.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,10 @@ type accountResp struct {
122122
DurationP75 float32 `json:"durationP75"`
123123
DurationP99 float32 `json:"durationP99"`
124124
DurationP999 float32 `json:"durationP999"`
125+
WallTimeP50 float32 `json:"wallTimeP50"`
126+
WallTimeP75 float32 `json:"wallTimeP75"`
127+
WallTimeP99 float32 `json:"wallTimeP99"`
128+
WallTimeP999 float32 `json:"wallTimeP999"`
125129
} `json:"quantiles"`
126130
} `json:"workersInvocationsAdaptive"`
127131
}
@@ -737,6 +741,10 @@ func fetchWorkerTotals(accountID string) (*cloudflareResponseAccts, error) {
737741
durationP75
738742
durationP99
739743
durationP999
744+
wallTimeP50
745+
wallTimeP75
746+
wallTimeP99
747+
wallTimeP999
740748
}
741749
}
742750
}

prometheus.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ const (
5050
workerErrorsMetricName MetricName = "cloudflare_worker_errors_count"
5151
workerCPUTimeMetricName MetricName = "cloudflare_worker_cpu_time"
5252
workerDurationMetricName MetricName = "cloudflare_worker_duration"
53+
workerWallTimeMetricName MetricName = "cloudflare_worker_wall_time"
5354
poolHealthStatusMetricName MetricName = "cloudflare_zone_pool_health_status"
5455
poolRequestsTotalMetricName MetricName = "cloudflare_zone_pool_requests_total"
5556
poolOriginHealthStatusMetricName MetricName = "cloudflare_pool_origin_health_status"
@@ -258,6 +259,12 @@ var (
258259
}, []string{"script_name", "account", "status", "quantile"},
259260
)
260261

262+
workerWallTime = prometheus.NewGaugeVec(prometheus.GaugeOpts{
263+
Name: workerWallTimeMetricName.String(),
264+
Help: "Wall time quantiles by script name (microseconds)",
265+
}, []string{"script_name", "account", "status", "quantile"},
266+
)
267+
261268
poolHealthStatus = prometheus.NewGaugeVec(prometheus.GaugeOpts{
262269
Name: poolHealthStatusMetricName.String(),
263270
Help: "Reports the health of a pool, 1 for healthy, 0 for unhealthy.",
@@ -368,6 +375,7 @@ func buildAllMetricsSet() MetricsSet {
368375
allMetricsSet.Add(workerErrorsMetricName)
369376
allMetricsSet.Add(workerCPUTimeMetricName)
370377
allMetricsSet.Add(workerDurationMetricName)
378+
allMetricsSet.Add(workerWallTimeMetricName)
371379
allMetricsSet.Add(poolHealthStatusMetricName)
372380
allMetricsSet.Add(poolOriginHealthStatusMetricName)
373381
allMetricsSet.Add(poolRequestsTotalMetricName)
@@ -487,6 +495,9 @@ func mustRegisterMetrics(deniedMetrics MetricsSet) {
487495
if !deniedMetrics.Has(workerDurationMetricName) {
488496
prometheus.MustRegister(workerDuration)
489497
}
498+
if !deniedMetrics.Has(workerWallTimeMetricName) {
499+
prometheus.MustRegister(workerWallTime)
500+
}
490501
if !deniedMetrics.Has(poolHealthStatusMetricName) {
491502
prometheus.MustRegister(poolHealthStatus)
492503
}
@@ -588,6 +599,10 @@ func fetchWorkerAnalytics(account cfaccounts.Account, wg *sync.WaitGroup) {
588599
workerDuration.With(prometheus.Labels{"script_name": w.Dimensions.ScriptName, "account": accountName, "status": w.Dimensions.Status, "quantile": "P75"}).Set(float64(w.Quantiles.DurationP75))
589600
workerDuration.With(prometheus.Labels{"script_name": w.Dimensions.ScriptName, "account": accountName, "status": w.Dimensions.Status, "quantile": "P99"}).Set(float64(w.Quantiles.DurationP99))
590601
workerDuration.With(prometheus.Labels{"script_name": w.Dimensions.ScriptName, "account": accountName, "status": w.Dimensions.Status, "quantile": "P999"}).Set(float64(w.Quantiles.DurationP999))
602+
workerWallTime.With(prometheus.Labels{"script_name": w.Dimensions.ScriptName, "account": accountName, "status": w.Dimensions.Status, "quantile": "P50"}).Set(float64(w.Quantiles.WallTimeP50))
603+
workerWallTime.With(prometheus.Labels{"script_name": w.Dimensions.ScriptName, "account": accountName, "status": w.Dimensions.Status, "quantile": "P75"}).Set(float64(w.Quantiles.WallTimeP75))
604+
workerWallTime.With(prometheus.Labels{"script_name": w.Dimensions.ScriptName, "account": accountName, "status": w.Dimensions.Status, "quantile": "P99"}).Set(float64(w.Quantiles.WallTimeP99))
605+
workerWallTime.With(prometheus.Labels{"script_name": w.Dimensions.ScriptName, "account": accountName, "status": w.Dimensions.Status, "quantile": "P999"}).Set(float64(w.Quantiles.WallTimeP999))
591606
}
592607
}
593608
}

0 commit comments

Comments
 (0)