-
Notifications
You must be signed in to change notification settings - Fork 4
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
Add basic utility command ctk tail
, for tailing a database table and optionally following the tail
#330
Conversation
3a5cfbc
to
397c8a5
Compare
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.
Great stuff! Spotted a cli arg issue..
@click.option("--format", "format_", type=str, required=False, help="Select output format. Default: log / jsonl") | ||
@click.option("--follow", "-f", is_flag=True, required=False, help="Follow new records added, by polling the table") | ||
@click.option("--verbose", is_flag=True, required=False, help="Turn on logging") | ||
@click.option("--debug", is_flag=True, required=False, help="Turn on logging with debug level") |
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 like the --interval
option is not defined and passed through?
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.
Nice spot. Thanks!
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.
... and optionally following the tail.
It is mostly sufficient and still provides enough interactivity. By reducing the frequency, it will incur less spam on sys.jobs_log itself.
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.
👍
@click.option( | ||
"--lines", "-n", type=int, required=False, default=10, help="Displays n last lines of the input. Default: 10" | ||
) | ||
@click.option("--format", "format_", type=str, required=False, help="Select output format. Default: log / jsonl") | ||
@click.option("--follow", "-f", is_flag=True, required=False, help="Follow new records added, by polling the table") | ||
@click.option( | ||
"--interval", "-i", type=float, required=False, help="When following the tail, poll each N seconds. Default: 0.5" | ||
) | ||
@click.option("--verbose", is_flag=True, required=False, help="Turn on logging") | ||
@click.option("--debug", is_flag=True, required=False, help="Turn on logging with debug level") |
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.
Any reason not to use click
default option settings for all default values instead of later on inside the code?
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.
If the defaults would be applied to click, they wouldn't apply when using ctk's Python APIs in your own programs, that's why I decided to put them there, also to avoid redundancy declaring them on both sides.
About
Implement
tail -f
forsys.jobs_log
, to support ad hoc tracing of SQL statements processed by CrateDB.Synopsis
export CRATEDB_SQLALCHEMY_URL=crate://crate@localhost:4200/
ctk tail -n 3 --follow --format=log-pretty sys.jobs_log crash -c "SELECT * FROM sys.summits LIMIT 3;"
The implementation may be versatile enough to also work well on arbitrary tables.
Documentation
References
tail -f
on top ofsys.jobs_log
table #171