Display queue latency

This commit is contained in:
Ken Hibino 2022-02-23 06:30:55 -08:00
parent 0d58ef86f4
commit 8a508c58eb
4 changed files with 45 additions and 15 deletions

View File

@ -82,6 +82,11 @@ type queueStateSnapshot struct {
MemoryUsage int64 `json:"memory_usage_bytes"` MemoryUsage int64 `json:"memory_usage_bytes"`
// Total number of tasks in the queue. // Total number of tasks in the queue.
Size int `json:"size"` Size int `json:"size"`
// Latency of the queue in milliseconds.
LatencyMillisec int64 `json:"latency_msec"`
// Latency duration string for display purpose.
DisplayLatency string `json:"display_latency"`
// Number of tasks in each state. // Number of tasks in each state.
Active int `json:"active"` Active int `json:"active"`
Pending int `json:"pending"` Pending int `json:"pending"`
@ -103,22 +108,24 @@ type queueStateSnapshot struct {
Timestamp time.Time `json:"timestamp"` Timestamp time.Time `json:"timestamp"`
} }
func toQueueStateSnapshot(s *asynq.QueueInfo) *queueStateSnapshot { func toQueueStateSnapshot(info *asynq.QueueInfo) *queueStateSnapshot {
return &queueStateSnapshot{ return &queueStateSnapshot{
Queue: s.Queue, Queue: info.Queue,
MemoryUsage: s.MemoryUsage, MemoryUsage: info.MemoryUsage,
Size: s.Size, Size: info.Size,
Active: s.Active, LatencyMillisec: info.Latency.Milliseconds(),
Pending: s.Pending, DisplayLatency: info.Latency.String(),
Scheduled: s.Scheduled, Active: info.Active,
Retry: s.Retry, Pending: info.Pending,
Archived: s.Archived, Scheduled: info.Scheduled,
Completed: s.Completed, Retry: info.Retry,
Processed: s.Processed, Archived: info.Archived,
Succeeded: s.Processed - s.Failed, Completed: info.Completed,
Failed: s.Failed, Processed: info.Processed,
Paused: s.Paused, Succeeded: info.Processed - info.Failed,
Timestamp: s.Timestamp, Failed: info.Failed,
Paused: info.Paused,
Timestamp: info.Timestamp,
} }
} }

View File

@ -254,6 +254,8 @@ export interface Queue {
queue: string; queue: string;
paused: boolean; paused: boolean;
size: number; size: number;
latency_msec: number;
display_latency: string;
memory_usage_bytes: number; memory_usage_bytes: number;
active: number; active: number;
pending: number; pending: number;

View File

@ -74,6 +74,15 @@ function QueueInfoBanner(props: Props & ReduxProps) {
</Typography> </Typography>
</div> </div>
<div className={classes.bannerItem}>
<Typography variant="subtitle2" color="textPrimary" gutterBottom>
Latency
</Typography>
<Typography color="textSecondary">
{queue ? queue.display_latency : "-"}
</Typography>
</div>
<div className={classes.bannerItem}> <div className={classes.bannerItem}>
<Typography variant="subtitle2" color="textPrimary" gutterBottom> <Typography variant="subtitle2" color="textPrimary" gutterBottom>
Processed Processed

View File

@ -50,6 +50,7 @@ enum SortBy {
State, State,
Size, Size,
MemoryUsage, MemoryUsage,
Latency,
Processed, Processed,
Failed, Failed,
ErrorRate, ErrorRate,
@ -72,6 +73,12 @@ const colConfigs: SortableTableColumn<SortBy>[] = [
sortBy: SortBy.MemoryUsage, sortBy: SortBy.MemoryUsage,
align: "right", align: "right",
}, },
{
label: "Latency",
key: "latency",
sortBy: SortBy.Latency,
align: "right",
},
{ {
label: "Processed", label: "Processed",
key: "processed", key: "processed",
@ -137,6 +144,10 @@ export default function QueuesOverviewTable(props: Props) {
if (q1.memory_usage_bytes === q2.memory_usage_bytes) return 0; if (q1.memory_usage_bytes === q2.memory_usage_bytes) return 0;
isQ1Smaller = q1.memory_usage_bytes < q2.memory_usage_bytes; isQ1Smaller = q1.memory_usage_bytes < q2.memory_usage_bytes;
break; break;
case SortBy.Latency:
if (q1.latency_msec === q2.latency_msec) return 0;
isQ1Smaller = q1.latency_msec < q2.latency_msec;
break;
case SortBy.Processed: case SortBy.Processed:
if (q1.processed === q2.processed) return 0; if (q1.processed === q2.processed) return 0;
isQ1Smaller = q1.processed < q2.processed; isQ1Smaller = q1.processed < q2.processed;
@ -283,6 +294,7 @@ function Row(props: RowProps) {
</TableCell> </TableCell>
<TableCell align="right">{q.size}</TableCell> <TableCell align="right">{q.size}</TableCell>
<TableCell align="right">{prettyBytes(q.memory_usage_bytes)}</TableCell> <TableCell align="right">{prettyBytes(q.memory_usage_bytes)}</TableCell>
<TableCell align="right">{q.display_latency}</TableCell>
<TableCell align="right">{q.processed}</TableCell> <TableCell align="right">{q.processed}</TableCell>
<TableCell align="right">{q.failed}</TableCell> <TableCell align="right">{q.failed}</TableCell>
<TableCell align="right">{percentage(q.failed, q.processed)}</TableCell> <TableCell align="right">{percentage(q.failed, q.processed)}</TableCell>