Repository navigation
feat(http-client): flag N+1 outgoing calls by URL shape - #84
Merged
Merged
Conversation
One endpoint called once per id, one call after another, within one
trace is flagged like an N+1 query. Calls are shaped as method + host +
path with id-like segments as {id} + query parameter names. Reads only;
pagination, repeats of the same URL and Http::pool batches are excluded.
Adds the http.client.n_plus_one_detected event, the
http.client.requests.n_plus_one counter, the http.client.n_plus_one.count
root tally, url.template / laravel.http.client.shape /
laravel.http.client.repeat span attributes, code.* origin and tail-mode
retention.
Claude-Session: https://claude.ai/code/session_01LtsaMBeethcCYvKx8PTBYL
sylvesterdamgaard
force-pushed
the
feat/http-client-n-plus-one
branch
from
October 13, 2026 14:08
4d73784 to
26d9d4f
Compare
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.
Flags an N+1 of outgoing HTTP calls (one endpoint fetched once per id, one call after another), the way an N+1 query is already flagged.
How it works
{id}+ sorted query param names (values dropped). Ids are numbers/dates, UUIDs, ULIDs, 16+ hex digests, Stripe-style prefixed tokens, long letter+digit tokens and emails.v2,oauth2and other names are left alone.Support\HttpShapeis the HTTP twin ofSqlShape.threshold(default 3) times in one trace. GET/HEAD only. Not flagged: pagination (page,cursor,offset,after/before,starting_after,pageToken,page[...],/page/2, ...), repeats of the same exact URL (retries), and calls sent together throughHttp::pool(a hop that starts while another of its shape is still in flight isn't counted).http.client.n_plus_one_detectedevent (once per shape per trace, includesurl.template,url.full, shape,http.client.repeat_count,code.*),http.client.requests.n_plus_one{server.address}counter (host label goes through the classifier),http.client.n_plus_one.countroot tally. Client spans geturl.templateandlaravel.http.client.shape. From the crossing call on, they also getlaravel.http.client.repeat = "n_plus_one". Tail detail mode keeps these traces.instrument.http_client_n_plus_one(on),..._threshold(3),instrument.http_client_origin(flagged/all/off). When detection is off, no detector is built and nothing gets shaped.Costs about 2 µs per hop (measured). The shape comes from the request as the app built it. A
withRequestMiddleware()URL rewrite isn't reflected in it.Tests cover the shape edge cases, pagination, pool, same-URL, writes, threshold, origin modes, trace reset and tail retention.
composer checkis green.https://claude.ai/code/session_01LtsaMBeethcCYvKx8PTBYL