-
Notifications
You must be signed in to change notification settings - Fork 55
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[A0CLI-5] feat: logs tail #6
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have a bunch of nits, but otherwise 💪 🙇
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! Left some comments and a suggestion for the formatter/renderer.
However the command is broken currently due to the list
assignment issue mentioned, that should be fixed before merging.
As an aside, it shouldn't block this PR, we can change it later if wanted, but I quite like how the heroku CLI does logs i.e. not with a tail subcommand, but rather a couple flags on logs itself:
So it'd look like:
auth0 logs
(return 100 recent logs)auth0 logs -n $x
(return $x recent logs)auth0 logs --tail
(tail logs)
What do you think?
internal/cli/logs.go
Outdated
} | ||
|
||
cli.renderer.LogList(list) | ||
time.Sleep(1 * time.Second) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was thinking about this one, should we just remove the sleep and let the SDK handle retrying and rate limits? It'll make the initial request quickly but gracefully back off if we're rate limited for whatever reason. NAB.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hitting rate limit itself triggers an event and generates an additional log entry, I'm inclined to avoid hitting rate limit if possible. Since this is not real-time logs, the event itself also only appears after a short interval, there is probably not very useful in trying to be real-time.
I've changed the implementation to only sleep when we are not getting a lot entries (<90) returned, otherwise we will keep polling. This should avoid falling behind as I noted earlier.
Co-authored-by: Patrick Carey <[email protected]>
I like that! This PR was meant to get things started and was obviously pretty rough. Sorry for stealing the thunder with my mediocre implementation :-) and thanks a lot for the review! Please take another look! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Description
Add
logs tail
commandThe implementation is naive: it starts with a search query sorted by
date:1
and then takes the last logID and switch to checkpoint method in a loop.The limit of 100 log entries returned in each API call and the sleep duration of 1 second potentially could risk falling behind if the log is being generated at a rate > 100/second, therefore, we only sleep when we are getting less than 90 log entries.
References
https://auth0team.atlassian.net/browse/A0CLI-5
Testing
Checklist
master