shuttle icon indicating copy to clipboard operation
shuttle copied to clipboard

[Improvement]: Head and tail args for the log command

Open jonaro00 opened this issue 1 year ago • 11 comments

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.

jonaro00 avatar Jan 31 '24 19:01 jonaro00

is anyone is working in the issue i want to work in this

biplab5464 avatar Feb 09 '24 09:02 biplab5464

@biplab5464 All yours. Thanks for showing interest.

jonaro00 avatar Feb 09 '24 09:02 jonaro00

can you give me little hint where to start

biplab5464 avatar Feb 09 '24 09:02 biplab5464

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).

jonaro00 avatar Feb 09 '24 09:02 jonaro00

--head --tail --all are all optional value right

biplab5464 avatar Feb 10 '24 06:02 biplab5464

Yes

jonaro00 avatar Feb 10 '24 11:02 jonaro00

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`)

biplab5464 avatar Feb 10 '24 13:02 biplab5464

Hmm, yeah then we can probably skip the short args for now.

jonaro00 avatar Feb 10 '24 17:02 jonaro00

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

biplab5464 avatar Feb 11 '24 10:02 biplab5464

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.

jonaro00 avatar Feb 12 '24 15:02 jonaro00

i will use clap macros for mutual exclusion okay, Thanks

biplab5464 avatar Feb 12 '24 17:02 biplab5464

It's merged, we can close it ? https://github.com/shuttle-hq/shuttle/pull/1629

tibs245 avatar Jun 03 '24 20:06 tibs245