Skip to content

Commit 89d8830

Browse files
Shivs11ShahabT
andauthored
Task Queue Statistics (#414)
* Including `approximate_backlog_counter` in Request/Response protos (#395) * Including approximate_backlog_counter in Request/Response protos * addressed comments * fixed ci error * fixed the jq error locally, maybe causing CI to fail * Updated TaskQueueTypeInfo to have BacklogInfo (#396) * Update DescribeTaskQueueResponse to remove BacklogInfo (#397) * Removed BacklogInfo from DescribeTaskQueueResponse * ran make * Rename BacklogInfo to TaskQueueStats (#411) * corrected tag number * Updated docstrings * Fixed lint complains --------- Co-authored-by: Shahab Tajik <[email protected]>
1 parent 31201e4 commit 89d8830

File tree

5 files changed

+95
-7
lines changed

5 files changed

+95
-7
lines changed

.gitmodules

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "proto/api"]
2+
url = ../api
3+
branch = shivam/backlog-count

openapi/openapiv2.json

+36-1
Original file line numberDiff line numberDiff line change
@@ -1195,9 +1195,16 @@
11951195
},
11961196
"collectionFormat": "multi"
11971197
},
1198+
{
1199+
"name": "reportStats",
1200+
"description": "Report stats for the requested task queue types and versions",
1201+
"in": "query",
1202+
"required": false,
1203+
"type": "boolean"
1204+
},
11981205
{
11991206
"name": "reportPollers",
1200-
"description": "Report backlog info for the requested task queue types and versions\nbool report_backlog_info = 8;\nReport list of pollers for requested task queue types and versions",
1207+
"description": "Report list of pollers for requested task queue types and versions",
12011208
"in": "query",
12021209
"required": false,
12031210
"type": "boolean"
@@ -8314,6 +8321,31 @@
83148321
},
83158322
"description": "Reachability of tasks for a worker on a single task queue."
83168323
},
8324+
"v1TaskQueueStats": {
8325+
"type": "object",
8326+
"properties": {
8327+
"approximateBacklogCount": {
8328+
"type": "string",
8329+
"format": "int64",
8330+
"description": "The approximate number of tasks backlogged in this task queue. May count expired tasks but eventually converges\nto the right value."
8331+
},
8332+
"approximateBacklogAge": {
8333+
"type": "string",
8334+
"description": "Approximate age of the oldest task in the backlog based on the create timestamp of the task at the head of the queue."
8335+
},
8336+
"tasksAddRate": {
8337+
"type": "number",
8338+
"format": "float",
8339+
"description": "Approximate tasks per second added to the task queue based on activity within a fixed window. This includes both backlogged and\nsync-matched tasks."
8340+
},
8341+
"tasksDispatchRate": {
8342+
"type": "number",
8343+
"format": "float",
8344+
"description": "Approximate tasks per second dispatched to workers based on activity within a fixed window. This includes both backlogged and\nsync-matched tasks."
8345+
}
8346+
},
8347+
"description": "For workflow task queues, we only report the normal queue stats, not sticky queues. This means the stats\nreported here do not count all workflow tasks. However, because the tasks queued in sticky queues only remain\nvalid for a few seconds, the inaccuracy becomes less significant as the backlog age grows."
8348+
},
83178349
"v1TaskQueueStatus": {
83188350
"type": "object",
83198351
"properties": {
@@ -8360,6 +8392,9 @@
83608392
"$ref": "#/definitions/v1PollerInfo"
83618393
},
83628394
"description": "Unversioned workers (with `useVersioning=false`) are reported in unversioned result even if they set a Build ID."
8395+
},
8396+
"stats": {
8397+
"$ref": "#/definitions/v1TaskQueueStats"
83638398
}
83648399
}
83658400
},

openapi/openapiv3.yaml

+36-4
Original file line numberDiff line numberDiff line change
@@ -1066,12 +1066,14 @@ paths:
10661066
- TASK_QUEUE_TYPE_NEXUS
10671067
type: string
10681068
format: enum
1069+
- name: reportStats
1070+
in: query
1071+
description: Report stats for the requested task queue types and versions
1072+
schema:
1073+
type: boolean
10691074
- name: reportPollers
10701075
in: query
1071-
description: |-
1072-
Report backlog info for the requested task queue types and versions
1073-
bool report_backlog_info = 8;
1074-
Report list of pollers for requested task queue types and versions
1076+
description: Report list of pollers for requested task queue types and versions
10751077
schema:
10761078
type: boolean
10771079
- name: reportTaskReachability
@@ -6121,6 +6123,34 @@ components:
61216123
See the TaskReachability docstring for information about each enum variant.
61226124
If reachability is empty, this worker is considered unreachable in this task queue.
61236125
description: Reachability of tasks for a worker on a single task queue.
6126+
TaskQueueStats:
6127+
type: object
6128+
properties:
6129+
approximateBacklogCount:
6130+
type: string
6131+
description: |-
6132+
The approximate number of tasks backlogged in this task queue. May count expired tasks but eventually converges
6133+
to the right value.
6134+
approximateBacklogAge:
6135+
pattern: ^-?(?:0|[1-9][0-9]{0,11})(?:\.[0-9]{1,9})?s$
6136+
type: string
6137+
description: Approximate age of the oldest task in the backlog based on the create timestamp of the task at the head of the queue.
6138+
tasksAddRate:
6139+
type: number
6140+
description: |-
6141+
Approximate tasks per second added to the task queue based on activity within a fixed window. This includes both backlogged and
6142+
sync-matched tasks.
6143+
format: float
6144+
tasksDispatchRate:
6145+
type: number
6146+
description: |-
6147+
Approximate tasks per second dispatched to workers based on activity within a fixed window. This includes both backlogged and
6148+
sync-matched tasks.
6149+
format: float
6150+
description: |-
6151+
For workflow task queues, we only report the normal queue stats, not sticky queues. This means the stats
6152+
reported here do not count all workflow tasks. However, because the tasks queued in sticky queues only remain
6153+
valid for a few seconds, the inaccuracy becomes less significant as the backlog age grows.
61246154
TaskQueueStatus:
61256155
type: object
61266156
properties:
@@ -6144,6 +6174,8 @@ components:
61446174
items:
61456175
$ref: '#/components/schemas/PollerInfo'
61466176
description: Unversioned workers (with `useVersioning=false`) are reported in unversioned result even if they set a Build ID.
6177+
stats:
6178+
$ref: '#/components/schemas/TaskQueueStats'
61476179
TaskQueueVersionInfo:
61486180
type: object
61496181
properties:

temporal/api/taskqueue/v1/message.proto

+18
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,24 @@ message TaskQueueVersionInfo {
8484
message TaskQueueTypeInfo {
8585
// Unversioned workers (with `useVersioning=false`) are reported in unversioned result even if they set a Build ID.
8686
repeated PollerInfo pollers = 1;
87+
TaskQueueStats stats = 2;
88+
}
89+
90+
// For workflow task queues, we only report the normal queue stats, not sticky queues. This means the stats
91+
// reported here do not count all workflow tasks. However, because the tasks queued in sticky queues only remain
92+
// valid for a few seconds, the inaccuracy becomes less significant as the backlog age grows.
93+
message TaskQueueStats {
94+
// The approximate number of tasks backlogged in this task queue. May count expired tasks but eventually converges
95+
// to the right value.
96+
int64 approximate_backlog_count = 1;
97+
// Approximate age of the oldest task in the backlog based on the create timestamp of the task at the head of the queue.
98+
google.protobuf.Duration approximate_backlog_age = 2;
99+
// Approximate tasks per second added to the task queue based on activity within a fixed window. This includes both backlogged and
100+
// sync-matched tasks.
101+
float tasks_add_rate = 3;
102+
// Approximate tasks per second dispatched to workers based on activity within a fixed window. This includes both backlogged and
103+
// sync-matched tasks.
104+
float tasks_dispatch_rate = 4;
87105
}
88106

89107
// Deprecated. Use `InternalTaskQueueStatus`. This is kept until `DescribeTaskQueue` supports legacy behavior.

temporal/api/workflowservice/v1/request_response.proto

+2-2
Original file line numberDiff line numberDiff line change
@@ -919,8 +919,8 @@ message DescribeTaskQueueRequest {
919919

920920
// Task queue types to report info about. If not specified, all types are considered.
921921
repeated temporal.api.enums.v1.TaskQueueType task_queue_types = 7;
922-
// Report backlog info for the requested task queue types and versions
923-
// bool report_backlog_info = 8;
922+
// Report stats for the requested task queue types and versions
923+
bool report_stats = 8;
924924
// Report list of pollers for requested task queue types and versions
925925
bool report_pollers = 9;
926926
// Report task reachability for the requested versions and all task types (task reachability is not reported

0 commit comments

Comments
 (0)