You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The existing worker metrics apply to background workers as they are:
busy_workers counts a thread holding a task, from pickup to the close of
the task's stream, and worker_queue_depth counts the tasks waiting for a
thread, which is the only queue a background worker has. Two new ones
break tasks down: worker_task_count{worker,outcome} with completed,
aborted (the script ended with the task open), abandoned (the sender
closed its stream first) or timeout (no thread picked the task up in
time), settled by whichever side closes first so every task counts once,
and worker_task_time, the seconds spent on tasks from pickup to close.
The threads endpoint follows: a background thread is busy while it holds
a task and waiting otherwise, counted per thread since a script may hold
several.
Copy file name to clipboardExpand all lines: docs/metrics.md
+6-4Lines changed: 6 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -16,13 +16,15 @@ When [Caddy metrics](https://caddyserver.com/docs/metrics) are enabled, FrankenP
16
16
-`frankenphp_busy_threads`: The number of PHP threads currently processing a request (running workers always consume a thread).
17
17
-`frankenphp_queue_depth`: The number of regular queued requests.
18
18
-`frankenphp_total_workers{worker="[worker_name]"}`: The total number of workers.
19
-
-`frankenphp_busy_workers{worker="[worker_name]"}`: The number of workers currently processing a request.
19
+
-`frankenphp_busy_workers{worker="[worker_name]"}`: The number of workers currently processing a request, or a task for a background worker.
20
20
-`frankenphp_worker_request_time{worker="[worker_name]"}`: The time spent processing requests by all workers.
21
21
-`frankenphp_worker_request_count{worker="[worker_name]"}`: The number of requests processed by all workers.
22
22
-`frankenphp_ready_workers{worker="[worker_name]"}`: The number of workers that have reached their ready point at least once: `frankenphp_handle_request()` for HTTP workers, `frankenphp_get_worker_handle()` for background workers.
23
23
-`frankenphp_worker_crashes{worker="[worker_name]"}`: The number of times a worker has unexpectedly terminated.
24
24
-`frankenphp_worker_restarts{worker="[worker_name]"}`: The number of times a worker has been deliberately restarted.
25
-
-`frankenphp_worker_queue_depth{worker="[worker_name]"}`: The number of queued requests.
25
+
-`frankenphp_worker_queue_depth{worker="[worker_name]"}`: The number of queued requests, or of tasks waiting for a thread of a background worker.
26
+
-`frankenphp_worker_task_count{worker="[worker_name]",outcome="[outcome]"}`: The number of tasks sent to a background worker, by outcome: `completed`, `aborted` (the script ended with the task open), `abandoned` (the sender closed its stream first) or `timeout` (no thread picked the task up in time).
27
+
-`frankenphp_worker_task_time{worker="[worker_name]"}`: The time spent on tasks by all threads of a background worker, from pickup to the close of the task's stream.
26
28
27
29
`[worker_name]` is the worker name from the Caddyfile, or the absolute path of the worker file when it has none. Workers of a `php_server` block are prefixed with the name of that block: `<server name>:<worker name>`. They used to be reported under their bare name unless two blocks declared the same one, so dashboards and alerts built on those series need the prefix.
28
30
@@ -73,8 +75,8 @@ Each entry in `ThreadDebugStates` contains:
73
75
|`Index`| integer | The index of the thread. |
74
76
|`Name`| string | The name of the thread (e.g., the worker file path). |
75
77
|`State`| string | The internal state of the thread (e.g., `ready`, `shutting down`). |
76
-
|`IsWaiting`| boolean | Whether the thread is waiting for a request. |
77
-
|`IsBusy`| boolean | Whether the thread is currently processing a request. |
78
+
|`IsWaiting`| boolean | Whether the thread is waiting for a request, or for a task in a background worker. |
79
+
|`IsBusy`| boolean | Whether the thread is currently processing a request, or a task in a background worker. |
78
80
|`WaitingSinceMilliseconds`| integer | How long the thread has been idle, in milliseconds. `0` if the thread is busy. |
79
81
|`CurrentURI`| string | The URI currently being processed. Empty if the thread is idle. |
80
82
|`CurrentMethod`| string | The HTTP method of the current request (e.g., `GET`, `POST`). Empty if the thread is idle. |
Help: "Number of tasks sent to this background worker, by outcome: completed, aborted (the script ended with the task open), abandoned (the sender closed its stream first) or timeout (no thread picked the task up in time)",
# HELP frankenphp_busy_workers Number of busy PHP workers for this worker: processing a request, or a task for a background worker
88
+
# TYPE frankenphp_busy_workers gauge
89
+
`,
90
+
expect: `
91
+
frankenphp_busy_workers{worker="bg_worker"} 0
92
+
`,
93
+
},
94
+
{
95
+
name: "Testing WorkerTaskTime",
96
+
c: m.workerTaskTime,
97
+
metadata: `
98
+
# HELP frankenphp_worker_task_time Time spent on tasks by all threads of this background worker, from pickup to the close of the task's stream
99
+
# TYPE frankenphp_worker_task_time counter
100
+
`,
101
+
expect: `
102
+
frankenphp_worker_task_time{worker="bg_worker"} 3
103
+
`,
104
+
},
105
+
{
106
+
name: "Testing WorkerTaskCount",
107
+
c: m.workerTaskCount,
108
+
metadata: `
109
+
# HELP frankenphp_worker_task_count Number of tasks sent to this background worker, by outcome: completed, aborted (the script ended with the task open), abandoned (the sender closed its stream first) or timeout (no thread picked the task up in time)
0 commit comments