Skip to content

Commit d0bd05f

Browse files
Surface ready-due queue-latency age on dw system:operator-metrics
Extends the CLI Tasks section of `dw system:operator-metrics` to render `operator_metrics.tasks.max_ready_due_age_ms` and `oldest_ready_due_at` when the workflow engine exposes them, mirroring the stuck-lease-age rendering already added alongside the transport-failure roll-up. The CLI output schema at schemas/output/operator-metrics.schema.json now pins both keys under `tasks` so downstream consumers of `--json` have a stable contract for the queue-latency duration signal.
1 parent 5486312 commit d0bd05f

3 files changed

Lines changed: 29 additions & 0 deletions

File tree

schemas/output/operator-metrics.schema.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@
3232
"lease_expired": { "type": ["integer", "null"] },
3333
"oldest_lease_expired_at": { "type": ["string", "null"] },
3434
"max_lease_expired_age_ms": { "type": ["integer", "null"] },
35+
"oldest_ready_due_at": { "type": ["string", "null"] },
36+
"max_ready_due_age_ms": { "type": ["integer", "null"] },
3537
"unhealthy": { "type": ["integer", "null"] }
3638
},
3739
"additionalProperties": true

src/Commands/SystemCommand/OperatorMetricsCommand.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,15 @@ private function renderTasks(OutputInterface $output, array $tasks): void
127127
if (is_string($tasks['oldest_lease_expired_at'] ?? null)) {
128128
$output->writeln(sprintf(' Oldest lease expired at: %s', $tasks['oldest_lease_expired_at']));
129129
}
130+
if (array_key_exists('max_ready_due_age_ms', $tasks)) {
131+
$output->writeln(sprintf(
132+
' Oldest ready-due age: %d ms',
133+
(int) ($tasks['max_ready_due_age_ms'] ?? 0),
134+
));
135+
}
136+
if (is_string($tasks['oldest_ready_due_at'] ?? null)) {
137+
$output->writeln(sprintf(' Oldest ready-due at: %s', $tasks['oldest_ready_due_at']));
138+
}
130139
$output->writeln('');
131140
}
132141

tests/Commands/SystemCommandTest.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -515,6 +515,8 @@ public function test_operator_metrics_command_renders_rollout_safety_signals():
515515
);
516516
self::assertStringContainsString('Oldest lease-expired age: 95000 ms', $display);
517517
self::assertStringContainsString('Oldest lease expired at: 2026-04-24T11:28:25Z', $display);
518+
self::assertStringContainsString('Oldest ready-due age: 15000 ms', $display);
519+
self::assertStringContainsString('Oldest ready-due at: 2026-04-24T11:29:45Z', $display);
518520

519521
self::assertStringContainsString('Runnable tasks: 7', $display);
520522
self::assertStringContainsString('Delayed tasks: 3', $display);
@@ -618,6 +620,20 @@ public function test_operator_metrics_schema_pins_stuck_lease_age_keys(): void
618620
self::assertSame(['integer', 'null'], $tasks['max_lease_expired_age_ms']['type']);
619621
}
620622

623+
public function test_operator_metrics_schema_pins_ready_due_age_keys(): void
624+
{
625+
$schema = json_decode(
626+
(string) file_get_contents(__DIR__.'/../../schemas/output/operator-metrics.schema.json'),
627+
true,
628+
flags: JSON_THROW_ON_ERROR,
629+
);
630+
631+
$tasks = $schema['properties']['operator_metrics']['properties']['tasks']['properties'];
632+
633+
self::assertSame(['string', 'null'], $tasks['oldest_ready_due_at']['type']);
634+
self::assertSame(['integer', 'null'], $tasks['max_ready_due_age_ms']['type']);
635+
}
636+
621637
public function test_operator_metrics_command_tolerates_minimal_payload(): void
622638
{
623639
$command = new OperatorMetricsCommand();
@@ -659,6 +675,8 @@ private static function operatorMetricsPayload(): array
659675
'lease_expired' => 2,
660676
'oldest_lease_expired_at' => '2026-04-24T11:28:25Z',
661677
'max_lease_expired_age_ms' => 95000,
678+
'oldest_ready_due_at' => '2026-04-24T11:29:45Z',
679+
'max_ready_due_age_ms' => 15000,
662680
'unhealthy' => 11,
663681
],
664682
'backlog' => [

0 commit comments

Comments
 (0)