Repository navigation
fix: keep the log ID cursor when tailing logs with --filter - #1723
Open
RaphaelFakhri wants to merge 1 commit into
Open
RaphaelFakhri wants to merge 1 commit into
RaphaelFakhri wants to merge 1 commit into
Conversation
This branch has not been deployed
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.
🔧 Changes
auth0 logs tail --filter <query>drops thelog_id:[<last-id> TO *]cursor on every poll. The poll builds twomanagement.Queryoptions, one for the cursor and one for the filter, andmanagement.Querycallsq.Set("q", ...), so the filter replaces the cursor and the request only containsq=<filter>.As a result, each filtered poll fetches the latest 100 matching events instead of the events after the last one shown. Client-side deduplication hides the repeats, but once the tenant has 100 or more events that match the filter, every poll returns a full page, the 2-second back-off never triggers, and the command polls the Management API in a tight loop, which uses up the tenant's Management API rate limit.
This change adds a
tailLogsQueryhelper that sends a single query that combines both parts,log_id:[<last-id> TO *] AND (<filter>). Tailing without a filter, and the first poll before any log ID is known, send the same query as before.📚 References
Fixes #1722
🔬 Testing
TestTailLogsCommandrunslogs tail --filter type:f, captures the options of the poll request, applies them throughmanagement.Management.NewRequest, and checks the resultingqparameter. Onmainit fails withactual: "type:f", with this change it passes.TestTailLogsQuerycovers the four cursor and filter combinations.go test ./internal/...andgolangci-lint run -c .golangci.yml ./internal/cli/...pass.📝 Checklist