feat(sdk): enrich collected metrics — granular status codes, TTFB, request size, inflight#9
Merged
Conversation
…trics and bump version to 2.2.0
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.
feat(sdk): enrich collected metrics — granular status codes, TTFB, request size, inflight
Context
The current schema aggregated HTTP status codes into three fixed buckets (2xx/4xx/5xx),
making it impossible to distinguish a 401 from a 429 or a 404 at the insight level.
This PR extends the data collection layer with higher-value signals while keeping the
privacy-first guarantee intact — no body content, no PII, sizes only.
Also fixes a silent bug:
lat_avgwas computed in the aggregator but never written to SQLite.Changes
status_3xx— redirections tracked as a dedicated counterstatus_dist— per-code granular distribution stored as JSON ({"200":45,"404":3})lat_ttfb_p50/p90/p99— Time To First Byte captured viares.write/res.endpatchrequest_size_avg— request body size fromreq.headers['content-length']inflight_avg/inflight_max— concurrent request count snapshot at processing timelat_avg— bug fix: was computed but missing from INSERT statement and schemaALTER TABLEon existing databases)2.1.2→2.2.0How to test
npm install npm run tests # 82/82 passManual validation: add the middleware to any Express app, make a few requests with
different status codes, then query
.apiforge.db:Checklist