Skip to content

Commit 92ead9f

Browse files
Accept POST on system metrics for compatibility
Allow both GET and POST requests on /api/system/metrics and cover the compatibility path in feature and control-plane contract tests.
1 parent ddfd2fc commit 92ead9f

4 files changed

Lines changed: 55 additions & 1 deletion

File tree

routes/api.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@
174174
// ── System / Operations ─────────────────────────────────────────
175175
Route::prefix('system')->middleware([$admin, $cpv, $ns])->group(function () {
176176
Route::get('/health', [SystemController::class, 'health']);
177-
Route::get('/metrics', [SystemController::class, 'metrics']);
177+
Route::match(['get', 'post'], '/metrics', [SystemController::class, 'metrics']);
178178
Route::get('/operator-metrics', [SystemController::class, 'operatorMetrics']);
179179
Route::get('/repair', [SystemController::class, 'repairStatus']);
180180
Route::post('/repair/pass', [SystemController::class, 'repairPass']);

tests/Feature/ControlPlaneOperationalSuccessContractTest.php

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,39 @@ public static function operationalSuccessProvider(): array
147147
],
148148
],
149149
],
150+
'system.metrics_empty_post' => [
151+
'method' => 'post',
152+
'path' => '/api/system/metrics',
153+
'body' => [],
154+
'structure' => [
155+
'generated_at',
156+
'namespace',
157+
'metrics' => [
158+
'dw_workflow_task_consecutive_failures' => [
159+
'max_consecutive_failures',
160+
'failed_task_count',
161+
'workflow_type_count',
162+
'workflow_type_limit',
163+
'workflow_types_truncated',
164+
'suppressed_workflow_type_count',
165+
'suppressed_failed_task_count',
166+
'label_cardinality_policy',
167+
'by_workflow_type',
168+
],
169+
'dw_projection_drift_total' => [
170+
'total',
171+
'table_count',
172+
'tables_with_drift',
173+
'scope',
174+
'label_cardinality_policy',
175+
'by_table',
176+
],
177+
],
178+
'cardinality' => [
179+
'metric_label_sets',
180+
],
181+
],
182+
],
150183
'system.health_empty' => [
151184
'method' => 'get',
152185
'path' => '/api/system/health',

tests/Feature/ControlPlaneVersionCoverageTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ public static function controlPlaneEndpointProvider(): array
125125
// SystemController
126126
'system.health' => ['method' => 'get', 'path' => '/api/system/health'],
127127
'system.metrics' => ['method' => 'get', 'path' => '/api/system/metrics'],
128+
'system.metrics_post' => ['method' => 'post', 'path' => '/api/system/metrics'],
128129
'system.operator_metrics' => ['method' => 'get', 'path' => '/api/system/operator-metrics'],
129130
'system.repair_status' => ['method' => 'get', 'path' => '/api/system/repair'],
130131
'system.repair_pass' => ['method' => 'post', 'path' => '/api/system/repair/pass'],

tests/Feature/SystemMetricsTest.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,26 @@ public function test_system_metrics_reports_bounded_workflow_task_failure_series
7373
], $response->json('metrics.dw_workflow_task_consecutive_failures.by_workflow_type'));
7474
}
7575

76+
public function test_system_metrics_accepts_post_requests_for_compatibility(): void
77+
{
78+
config(['server.metrics.workflow_task_failure_type_limit' => 2]);
79+
80+
$this->createWorkflowTaskMetricRow('tests.metric-high', 7);
81+
$this->createWorkflowTaskMetricRow('tests.metric-middle', 3);
82+
83+
$getResponse = $this->getJson('/api/system/metrics', $this->controlPlaneHeadersWithWorkerProtocol());
84+
$postResponse = $this->postJson('/api/system/metrics', [], $this->controlPlaneHeadersWithWorkerProtocol());
85+
86+
$getResponse->assertOk()
87+
->assertHeader(ControlPlaneProtocol::HEADER, ControlPlaneProtocol::VERSION);
88+
$postResponse->assertOk()
89+
->assertHeader(ControlPlaneProtocol::HEADER, ControlPlaneProtocol::VERSION)
90+
->assertJsonPath('namespace', 'default');
91+
92+
$this->assertSame($getResponse->json('metrics'), $postResponse->json('metrics'));
93+
$this->assertSame($getResponse->json('cardinality'), $postResponse->json('cardinality'));
94+
}
95+
7696
public function test_system_metrics_reports_projection_drift_by_fixed_table_inventory(): void
7797
{
7898
$this->createWorkflowTaskMetricRow('tests.projection-drift', 1);

0 commit comments

Comments
 (0)