Skip to content

feat: add status dimension in worker metrics - #13

Open
Kaitou786 wants to merge 1 commit into
cloudflare:mainfrom
Kaitou786:tk/add-status-dimension-worker
Open

feat: add status dimension in worker metrics#13
Kaitou786 wants to merge 1 commit into
cloudflare:mainfrom
Kaitou786:tk/add-status-dimension-worker

Conversation

@Kaitou786

Copy link
Copy Markdown

What

Adding the status as part of the worker metrics.

Why

Without status, worker metrics aggregate all invocation outcomes together. This causes misleading data because failed/disconnected requests have vastly different performance characteristics than successful ones.

If we use cloudflare_worker_cpu_time_seconds to determine how much time the worker is taking, currently, the data can be skewed as success status takes far less time than clientDisconnected status.

Without the proper slicing/filtering of the data, it becomes difficult to measure and alert based on the above metric.

Tesing

This should be a completely safe change, especially since we are already fetching this value from the Cloudflare GraphQL API:

export const WorkerTotalsQuery = graphql(`
query WorkerTotals(
$accountID: string!
$mintime: Time!
$maxtime: Time!
$limit: uint64!
) {
viewer {
accounts(filter: { accountTag: $accountID }) {
workersInvocationsAdaptive(
limit: $limit
filter: { datetime_geq: $mintime, datetime_lt: $maxtime }
) {
dimensions {
scriptName
status

However, I did run it against a Cloudflare account using:

  echo "CLOUDFLARE_API_TOKEN=<TOKEN>" > .dev.vars
  npm install
  npm run dev

post which using going to http://localhost:8787/metrics I could see:

cloudflare_worker_requests_total{script_name="redacted",account="redacted",status="success"} 6
cloudflare_worker_requests_total{script_name="redacted",account="redacted",status="clientDisconnected"} 8
...

cloudflare_worker_cpu_time_seconds{script_name="redacted",account="redacted",status="success",quantile="P999"} 0.049446

cloudflare_worker_cpu_time_seconds{script_name="redacted",account="redacted",status="clientDisconnected",quantile="P999"} 0.055794

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant