shuttle
shuttle copied to clipboard
[Improvement]: Head and tail args for the log command
Describe the improvement
A deployment can produce many thousands of log lines, and cargo shuttle log
fetches them all. This can produce very big responses when only a fraction of the log lines are needed.
Add --head N
and --tail N
args to the log command for getting the first or last N lines. The default behaviour should be to get the last 1000 rows.
An additional flag --all
can also be added, which keeps the current behaviour by disabling the default tail value and not setting any query parameter.
Short flags -h
, -t
and -a
can also be added.
The steps required include:
- Adding the fields to the protobuf LogsRequest and query parameter to the deployer endpoints
- Adding args in the CLI and setting the proper query flags when making a log request
- Modifying the logger to accept the new options and add them to the underlying SQL query
This issue is open to contribution. Comment if you want to work on it. Feel free to ask for help and guidance here or in our Discord.
is anyone is working in the issue i want to work in this
@biplab5464 All yours. Thanks for showing interest.
can you give me little hint where to start
You can either start by adding the arguments in cargo-shuttle/src/args, and passing them into the functions that eventually call the log endpoints, or you can start by adding query parameters to deployer's two log endpoints, and pass them on to the gRPC call to logger (requires updating the logger's proto file and regenerating the proto code).
--head --tail --all are all optional value right
Yes
currently -h use for help so we have to give some other short name to the head
Command mod_test: Short option names must be unique for each argument, but '-h' is in use by both 'head' and 'help' (call `cmd.disable_help_flag(true)` to remove the auto-generated `--help`)
Hmm, yeah then we can probably skip the short args for now.
hey, can you help me, i have added the argument in the function but i am unable to understand how the log is getting fetch and how can get log of specific head and tail if we can talk over something like discord ?
and can you please review the above code tell me if it need any change
The argument definitions are looking good. The parsing to make the arguments mutually exclusive can instead be accomplished with the clap macros.
You can ask in the contributors channel in our discord if you want more help.
i will use clap macros for mutual exclusion okay, Thanks
It's merged, we can close it ? https://github.com/shuttle-hq/shuttle/pull/1629