perf(agent): pattern/service catalog lists - #321
Merged
Conversation
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 does this PR do?
Adds server-side pagination to the agent catalog list endpoints (
GET /api/agent/patterns,GET /api/agent/services) so they serve a bounded page plus a cheap total count instead of materializing the whole catalog on every request. Brings these two lists onto the same pattern the incidents/analyses lists already use.Why?
On the Postgres backend,
listPatterns/listServiceswent throughcatalog.Snapshot()— an unboundedSELECTovervs_patterns/vs_servicesplus a full JSON serialize and per-row readiness compute on every list load. This is the catalog twin of the incidents/analyses pagination already shipped. No linked issue — internal perf follow-up.How to test
STORAGE_TYPE=postgresand generate enough varied logs across many services to learn more patterns/services than one page (or pass a smallpage_size).GET /api/agent/patterns?page_size=5→ 5 rows,total= whole-catalog count,next_offsetset on a full page; walkoffset/page→ non-overlapping, stable, gap-free windows;next_offsetnull on the last underfull page.?q=<substring>filters server-side (smallertotal); re-fetching a page is deterministic (patterns fleet-count desc→id; services first_seen→name).GET /api/agent/services?page_size=5→ paged envelope;servicesstays a name→facts map with grace fields;total= whole set.page_sizeclamps to[1,5000](default 1000); negativeoffset→ 0.Type of change
Checklist
go test versuspasses locallygo vet versusis cleangofmtsrc/if behavior changes (internal admin API; nosrc/doc change)ROADMAP.mdif this closes a roadmap item