feat: add metrics, observability, test fixtures, and scaling playbook artifacts
This commit is contained in:
1 parent
926a663c23
commit
f9aba11b90
32 files changed
+1788
-124
No files matched your search
@@ -0,0 +1,68 @@
|
||||
#!/usr/bin/env pwsh
|
||||
param(
|
||||
[Parameter(Mandatory = $true)]
|
||||
[string]$SummaryFile
|
||||
)
|
||||
|
||||
$ErrorActionPreference = 'Stop'
|
||||
|
||||
if (-not (Test-Path $SummaryFile)) {
|
||||
throw "Summary file not found: $SummaryFile"
|
||||
}
|
||||
|
||||
$summary = Get-Content -Raw -Path $SummaryFile | ConvertFrom-Json
|
||||
$metrics = $summary.metrics
|
||||
|
||||
if (-not $metrics) {
|
||||
throw 'Invalid k6 summary file: missing metrics object.'
|
||||
}
|
||||
|
||||
$endpoints = @('overview', 'analytics', 'chat_log', 'users')
|
||||
|
||||
function Get-MetricValue {
|
||||
param(
|
||||
[object]$Metric,
|
||||
[string]$Key
|
||||
)
|
||||
|
||||
if (-not $Metric) {
|
||||
return $null
|
||||
}
|
||||
if (-not $Metric.values) {
|
||||
return $null
|
||||
}
|
||||
|
||||
$value = $Metric.values.$Key
|
||||
if ($null -ne $value) {
|
||||
return [double]$value
|
||||
}
|
||||
return $null
|
||||
}
|
||||
|
||||
$globalDuration = Get-MetricValue -Metric $metrics.http_req_duration -Key 'p(95)'
|
||||
$globalFailRate = Get-MetricValue -Metric $metrics.http_req_failed -Key 'rate'
|
||||
|
||||
Write-Output "k6 Summary: $SummaryFile"
|
||||
if ($null -ne $globalDuration) {
|
||||
Write-Output ("Global p95 duration (ms): {0:N2}" -f $globalDuration)
|
||||
}
|
||||
if ($null -ne $globalFailRate) {
|
||||
Write-Output ("Global failure rate: {0:P2}" -f $globalFailRate)
|
||||
}
|
||||
Write-Output ''
|
||||
|
||||
$rows = foreach ($endpoint in $endpoints) {
|
||||
$durationMetricName = "http_req_duration{endpoint:$endpoint}"
|
||||
$failMetricName = "http_req_failed{endpoint:$endpoint}"
|
||||
|
||||
$durationP95 = Get-MetricValue -Metric $metrics.$durationMetricName -Key 'p(95)'
|
||||
$failRate = Get-MetricValue -Metric $metrics.$failMetricName -Key 'rate'
|
||||
|
||||
[PSCustomObject]@{
|
||||
Endpoint = $endpoint
|
||||
P95Ms = if ($null -ne $durationP95) { [math]::Round($durationP95, 2) } else { $null }
|
||||
FailurePct = if ($null -ne $failRate) { [math]::Round($failRate * 100, 4) } else { $null }
|
||||
}
|
||||
}
|
||||
|
||||
$rows | Format-Table -AutoSize | Out-String | Write-Output
|
||||
Reference in new issue
Block a user