fix: do not allocate log options for excluded urls#1220
Merged
Conversation
* don't allocate in header validator, no need for lowercasing * precompile excluded prefix for http metrics plugin Signed-off-by: ferhat elmas <elmas.ferhat@gmail.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR refactors request logging and metrics collection to reduce per-request allocations on excluded routes and to standardize timing measurements using monotonic clocks.
Changes:
- Switch excluded route/url configuration from
string[]toSet<string>to enable O(1) membership checks and reduce repeated allocations. - Hoist excluded-url checks earlier in
logRequestand remove per-request option allocation for excluded endpoints. - Precompute excluded-route prefix checks in
httpMetricsand remove lowercasing/allocation inheaderValidator.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| src/http/plugins/metrics.ts | Uses Set-based route exclusion and precomputes excluded prefixes to avoid per-request allocations. |
| src/http/plugins/log-request.ts | Uses performance.now() and early excluded-url checks to avoid building log payloads for excluded URLs; fixes response time unit consistency. |
| src/http/plugins/header-validator.ts | Uses Set exclusion and removes toLowerCase() allocation for URL checks. |
| src/app.ts | Updates monitoring exclusions to a shared Set and passes it into metrics/logging/header validation plugins. |
| src/admin-app.ts | Updates admin app log-request exclusions to use Set. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
fenos
approved these changes
Jul 9, 2026
Coverage Report for CI Build 29011440956Coverage decreased (-0.02%) to 79.237%Details
Uncovered Changes
Coverage RegressionsNo coverage regressions found. Coverage Stats💛 - Coveralls |
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.
What kind of change does this PR introduce?
Refactor for performance
What is the current behavior?
What is the new behavior?
Additional context
Use
performance.now(since we checking diff, not absolute) and fix unit for failed requests.It will help minor GC.