Add API benchmark toolkit - #2
Merged
Merged
Conversation
Sets up the benchmark toolkit under toolkit/ with commander-based CLI, stub commands (build, deploy, loadtest, run, publish, compare, list, clean), and core utilities (timer, logger, exec wrapper). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Zod-based config validation with env var interpolation, target resolution, and a working list command to display configured benchmark targets. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Docker Compose wrapper (build, up, down, ps), HTTP-based health check polling for readiness detection, and wired-up build/deploy/clean commands with high-resolution timing. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
k6 subprocess wrapper, summary JSON parser for extracting latency percentiles and throughput metrics, bundled default HTTP and gRPC k6 scripts, and wired-up loadtest command with VU/duration overrides. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Full benchmark pipeline: build -> deploy -> loadtest -> collect -> write. Environment info collector (OS, arch, CPU, memory, tool versions), JSON results writer, and run command with skip/override/publish options. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
OTLP JSON formatter converting benchmark results to OpenTelemetry metric format, Grafana Cloud publisher with Basic auth and retry logic, and publish command for pushing result files. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Load multiple result JSON files, compare metrics side-by-side with best-value highlighting (green), and render a formatted terminal table using cli-table3 and chalk. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Covers prerequisites, setup, quick start, all CLI commands with options and examples, config reference, metrics captured, Grafana Cloud publishing, custom k6 scripts, and project structure. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Adds toolkit as an npm workspace so `npm install` at the root installs everything. Adds `npm run benchmark` script so the CLI can be invoked without navigating into toolkit/. Updates README to reflect the simpler workflow. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Adds a new Node.js-based benchmarking toolkit to this repo for running a Docker Compose build/deploy pipeline, executing k6 load tests, writing results to JSON, comparing runs in the terminal, and optionally publishing metrics to Grafana Cloud via OTLP/HTTP.
Changes:
- Introduces
toolkit/as an npm workspace providing abenchmarkCLI with commands for build/deploy/loadtest/run/publish/compare/list/clean. - Implements metrics collection/parsing plus reporting (JSON output + terminal comparison table).
- Adds Grafana Cloud OTLP/HTTP publishing and updates repo docs/config to support running benchmarks from the root.
Reviewed changes
Copilot reviewed 31 out of 35 changed files in this pull request and generated 11 comments.
Show a summary per file
| File | Description |
|---|---|
| toolkit/src/util/logger.js | Adds pino-based pretty logger helper. |
| toolkit/src/util/exec.js | Adds execa wrapper with debug logging. |
| toolkit/src/report/table.js | Renders terminal comparison tables with best-value highlighting. |
| toolkit/src/report/json.js | Writes benchmark results JSON files to disk. |
| toolkit/src/report/compare.js | Loads result files and computes “best” values for comparison. |
| toolkit/src/publish/grafana-cloud.js | Publishes metrics to Grafana Cloud via OTLP/HTTP with retry logic. |
| toolkit/src/publish/formatter.js | Formats results into OTLP/HTTP JSON metric payloads. |
| toolkit/src/metrics/k6-parser.js | Parses k6 summary-export JSON into normalized metrics. |
| toolkit/src/metrics/collector.js | Collects environment metadata and assembles final results object. |
| toolkit/src/core/timer.js | Provides high-resolution timing utility. |
| toolkit/src/core/k6.js | Runs k6 with --summary-export and returns parsed output. |
| toolkit/src/core/health.js | Polls readiness probe endpoint until healthy/timeout. |
| toolkit/src/core/docker.js | Wraps docker compose build/up/down/ps execution. |
| toolkit/src/config/schema.js | Defines Zod schema for benchmark config. |
| toolkit/src/config/loader.js | Loads, interpolates env vars, validates, and resolves targets. |
| toolkit/src/config/defaults.js | Adds defaults object (currently not integrated elsewhere). |
| toolkit/src/cli/index.js | Defines top-level CLI program and global options. |
| toolkit/src/cli/commands/run.js | Implements full pipeline command (build → deploy → loadtest → collect → cleanup). |
| toolkit/src/cli/commands/publish.js | Implements publish command for existing results JSON. |
| toolkit/src/cli/commands/loadtest.js | Implements loadtest-only command against a running target. |
| toolkit/src/cli/commands/list.js | Lists configured benchmark targets. |
| toolkit/src/cli/commands/deploy.js | Implements deploy timing + readiness wait. |
| toolkit/src/cli/commands/compare.js | Implements comparison of multiple results files. |
| toolkit/src/cli/commands/clean.js | Implements docker compose down teardown command. |
| toolkit/src/cli/commands/build.js | Implements build timing command. |
| toolkit/package.json | Declares toolkit workspace package, deps, and benchmark bin. |
| toolkit/package-lock.json | Locks toolkit dependencies. |
| toolkit/k6/scripts/default-http.js | Adds default HTTP k6 script. |
| toolkit/k6/scripts/default-grpc.js | Adds default gRPC k6 script. |
| toolkit/bin/benchmark.js | Adds CLI entrypoint script. |
| package.json | Adds npm workspaces and root benchmark script. |
| package-lock.json | Updates lockfile for workspace linkage and deps. |
| benchmark.config.json | Adds example benchmark configuration and Grafana env interpolation. |
| README.md | Adds full documentation and usage instructions for toolkit. |
| .gitignore | Ignores results/ output directory. |
Files not reviewed (1)
- toolkit/package-lock.json: Language not supported
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Fix default k6 script path to toolkit/k6/scripts/default-http.js - Make readinessProbe httpGet.port optional (falls back to target port) - Clean up k6 temp summary file after parsing - Fix pino-pretty translateTime format (HH:mm:ss not HH:MM:ss) - Multiply error rate by 100 for Error % column display - Remove redundant lowerIsBetter branches in highlight() - Merge config defaults into targets in resolveTarget() - Remove unused ora dependency - Remove unused defaults.js (Zod schema handles defaults) - Drop --output CLI default so config output.dir is respected - Guard cleanup in run command to avoid masking errors Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Configures ESLint (flat config) with eslint-config-prettier and Prettier with singleQuote, trailingComma, 100 printWidth. Adds lint, lint:fix, format, and format:check npm scripts. Fixes all lint errors and formats all source files. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Moves ESLint and Prettier config, dependencies, and scripts into the toolkit workspace. Root scripts now delegate to workspaces via --workspaces --if-present, so future workspaces can define their own lint/format/build scripts independently. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
toolkit/for benchmarking Docker Compose-based API servicesCommands
npm run benchmark -- run <target>npm run benchmark -- build <target>npm run benchmark -- deploy <target>npm run benchmark -- loadtest <target>npm run benchmark -- publish <results>npm run benchmark -- compare <files...>npm run benchmark -- listnpm run benchmark -- clean <target>Test plan
npm installfrom repo rootnpm run benchmark -- listto verify config loadingnpm run benchmark -- --helpto verify all commands registeredresults/--publishcomparewith multiple result files🤖 Generated with Claude Code