feat(opensearch): support reason-filtered, unscoped, paginated event queries - #384
feat(opensearch): support reason-filtered, unscoped, paginated event queries#384LakshanSS wants to merge 1 commit into
Conversation
…queries Delivery Insights (DORA metrics, openchoreo/openchoreo#4248) needs the observer's aggregator to sweep controller-emitted delivery lifecycle events (DeploymentStarted/Succeeded/Failed/Recovered) across every namespace on a timer, via the logs adapter's events API. The adapter's contract has been extended with reasons, searchAfter/nextCursor, and an optional searchScope, but this module's QueryEvents handler still required a scope and had no reason filter or pagination beyond a single page. - Allow searchScope to be omitted when reasons is set, running an unscoped sweep across all namespaces instead of 400ing. - Add a reasons terms filter to the component, workflow, and new unscoped query builders. - Add search_after/nextCursor pagination: sort now includes _seq_no as a tiebreaker (a numeric, always-doc-valued metadata field, unlike _id) so paging is stable when multiple events share a timestamp; nextCursor is set from the last hit's sort values when a page fills up. - Regenerate models.gen.go/server.gen.go from the openchoreo laki-obs branch's updated observability-logs-adapter-api spec (not yet on main, since PR #4248 hasn't merged) so the new request/response fields exist. Client.Search wasn't copying each hit's sort values through to the local Hit type, which the new cursor logic depends on. Signed-off-by: LakshanSS <lakshan230897@gmail.com>
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
|
Heads-up on the ordering dependency: the spec side of this is now split out of openchoreo/openchoreo#4248 into its own small PR — openchoreo/openchoreo#4597 (48 lines, spec + regenerated client, no Delivery Insights behaviour). Once #4597 lands on #4597 cites the enforcement in this PR — the 400 for an unscoped, reason-less query and |
Summary
Delivery Insights (DORA metrics, openchoreo/openchoreo#4248) needs the observer's aggregator to sweep controller-emitted delivery lifecycle events (
DeploymentStarted/Succeeded/Failed/Recovered) across every namespace on a timer, via this module's events API. The shared adapter contract (observability-logs-adapter-api.yaml) has been extended withreasons,searchAfter/nextCursor, and an optionalsearchScope, but this module'sQueryEventshandler still required a scope and had no reason filter or pagination beyond a single page — every aggregator call would 400.This is scoped to the
observability-logs-opensearchmodule only, to unblock verifying the Delivery Insights event pipeline end-to-end on local k3d. The same gap exists inaws-cloudwatch,gcp-cloudlogging, andopenobserve(tracked as a separate follow-up issue for the full release).searchScopeto be omitted whenreasonsis set, running an unscoped sweep across all namespaces instead of 400ing.reasonsterms filter to the component, workflow, and new unscoped query builders.searchAfter/nextCursorpagination: sort now includes_seq_noas a tiebreaker (a numeric, always-doc-valued metadata field, unlike_id) so paging is stable when multiple events share a timestamp;nextCursoris set from the last hit's sort values when a page fills up.models.gen.go/server.gen.gofrom the openchoreolaki-obsbranch's updatedobservability-logs-adapter-apispec (not yet onmain, since feat: add Delivery Insights (DORA metrics) store and read API to observer openchoreo#4248 hasn't merged) so the new request/response fields exist. The regen was done from the module's own last-generated spec snapshot patched with only the new fields, to keep the diff scoped — not a full resync against current upstreammain.Client.Searchnot copying each hit'ssortvalues through to the localHittype, which the new cursor logic depends on.Draft because it depends on openchoreo/openchoreo#4248 landing first (that PR is intentionally held open until the whole Delivery Insights feature — including this — is ready), and the generated code here will need re-syncing against
main's spec once that merges.Test plan
go build ./...go vet ./...go test ./...(all packages pass; existingTestQueryEvents_*/TestBuildComponentEventsQuery_*tests updated for theSearchScopepointer change and new sort shape)searchAftercursor 400,nextCursorpopulated when a page fills up, cursor encode/decode round-trip, reasons terms filter on all three query buildersINSIGHTS_EVENTS_SOURCE_ENABLED=true)🤖 Generated with Claude Code