Skip to content

feat(#95): Collect server-side metrics from target - #99

Open
Allan-Nava wants to merge 4 commits into
mainfrom
feat/v1.20.0
Open

Allan-Nava wants to merge 4 commits into
mainfrom
feat/v1.20.0

Conversation

@Allan-Nava

Copy link
Copy Markdown
Member

Description

Add infrastructure to collect and correlate server-side metrics (CPU, memory, throttling) with load test runs. This enables root-cause diagnosis: differentiate between client-side symptoms (latency, errors) and server-side causes (CPU quota, memory pressure).

Changes

  • k6/lib/server-metrics.js (new): Metrics parsing module

    • isCollectionEnabled(profile) — check if collection should run
    • parseMetrics(body, metricName) — parse Prometheus/custom formats
    • formatSeries(samples) — format for correlation with run steps
    • Pure, runnable in node (for testing)
  • tests/unit/server-metrics.test.js (new): 9 unit tests

    • Prometheus text format parsing
    • Custom key=value format parsing
    • Empty/missing data handling
  • k6/live-event.js: Import server-metrics module

    • Placeholder for active collection during run
    • Next: one VU dedicated to metrics polling

Architecture

Profile (server_metrics_endpoint, server_metrics_metric_name)
  ↓
k6/live-event.js (collect during run) [next iteration]
  ↓
handleSummary() (format samples) [next iteration]
  ↓
bin/crowdsim (detect, write TSV) [next iteration]
  ↓
lib/server-metrics-cli.mjs (correlate with steps) [existing]
  ↓
out/server-side-<run_id>.json
  ↓
Report (metrics overlay on latency chart) [future]

Currently, metrics can be handed to a run via --server-metrics (collected externally). Next: active collection.

Testing

  • Unit tests: 9/9 passing
  • Lint: ✅
  • Full suite: 321/321 passing

Related

Closes #95 (partial — active collection deferred to v1.20.1)

🤖 Generated with Claude Code

allan added 4 commits September 21, 2026 14:45
…trics format

- k6/lib/server-metrics.js: parse metrics from endpoint responses
- isCollectionEnabled() checks profile for server_metrics_endpoint + metric_name
- parseMetrics() handles both Prometheus and key=value formats
- tests/unit/server-metrics.test.js: unit tests for parsing logic

Next: implement k6 collection loop and CLI integration.
…dule

- formatSeries() formats collected samples for correlation
- collectSample() placeholder for k6 http collection (to be implemented)
- tests: 9 passing, 0 failing

Next: integrate into live-event.js handleSummary()
- k6/lib/server-metrics.js: parse metrics from endpoints
- isCollectionEnabled(), parseMetrics(), formatSeries()
- k6/live-event.js: import and placeholder for collection
- tests: 9 unit tests passing

The infrastructure for server-side metrics is now in place:
1. User provides --server-metrics file (collected externally)
2. crowdsim passes to server-metrics-cli.mjs
3. Metrics aligned with run steps in out/server-side-<run_id>.json

Next version: active collection during k6 run
@Allan-Nava Allan-Nava self-assigned this Sep 21, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Collect server-side metrics from target

1 participant