-
Notifications
You must be signed in to change notification settings - Fork 14
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
feat(crowtty): add host-side trace filtering #156
Conversation
Currently, our ability to filter traces is limited to setting a max level on the target. This is not ideal --- sometimes, we may want `TRACE` events from one module, but enabling `TRACE` globally results in an unreadably verbose firehose log. In the rest of the `tracing` ecosystem, this is generally solved by using *filters*, typically setting a separate maximum level based on trace targets (module paths). We can't easily implement dynamic target filtering in the kernel itself, because `mnemos_alloc` doesn't currently provide us a nice way of working with owned strings for mudle paths. However, we *can* easily implement this kind of filtering on the host side, in `crowtty`. This branch adds support for module-path-based filtering in `crowtty`, controlled by a `--trace` flag, which replaces the previous `--trace-level`. I felt like breaking the CLI arguments was probably fine but if someone really cares about backwards compatibility, we could make the `--trace-level` flag an alias for `--trace <LEVEL>`. In the future, when we have the capacity to do nice string handling in the kernel, it would be preferable to have these trace filter configurations be sent to the target device, and have it perform filtering. That would allow us to actually skip recording unwanted traces, reducing the performance impact of turning on more verbose traces. However, with the current design, we will still send the max level to the target, so if we enable `INFO` globally and `DEBUG` in some specific module, we will, at least, still disable the `TRACE` level on the target. When the capacity to perform filtering in the target is added, the existing flag can be kept, and the behavior modified to send a traceproto message that selects that filter configuration. Fixes #153
/// maximum `tracing` level to request from the target. | ||
#[arg(short, long, global = true, default_value_t = LevelFilter::INFO)] | ||
trace_level: LevelFilter, | ||
/// a comma-separated list of `tracing` targets and levels to enable. |
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.
It might be nice to have an example of how to use this in the CLI output, or maybe in the crowtty readme (does crowtty have a readme?)? Maybe something like --trace=kernel=log,maitake=trace,postcard::flavors=debug
or whatever.
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.
crowtty has basically no docs lol...we should fix that.
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.
f5b5250 adds a quick description of how this works.
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.
One docs nit, but no complaints and I'm not worried about breaking cli arg changes atm.
Currently, our ability to filter traces is limited to setting a max
level on the target. This is not ideal --- sometimes, we may want
TRACE
events from one module, but enablingTRACE
globally results inan unreadably verbose firehose log.
In the rest of the
tracing
ecosystem, this is generally solved byusing filters, typically setting a separate maximum level based on
trace targets (module paths). We can't easily implement dynamic target
filtering in the kernel itself, because
mnemos_alloc
doesn't currentlyprovide us a nice way of working with owned strings for mudle paths.
However, we can easily implement this kind of filtering on the host
side, in
crowtty
. This branch adds support for module-path-basedfiltering in
crowtty
, controlled by a--trace
flag, which replacesthe previous
--trace-level
. I felt like breaking the CLI arguments wasprobably fine but if someone really cares about backwards compatibility,
we could make the
--trace-level
flag an alias for--trace <LEVEL>
.In the future, when we have the capacity to do nice string handling in
the kernel, it would be preferable to have these trace filter
configurations be sent to the target device, and have it perform
filtering. That would allow us to actually skip recording unwanted
traces, reducing the performance impact of turning on more verbose
traces. However, with the current design, we will still send the max
level to the target, so if we enable
INFO
globally andDEBUG
in somespecific module, we will, at least, still disable the
TRACE
level onthe target.
When the capacity to perform filtering in the target is added, the
existing flag can be kept, and the behavior modified to send a
traceproto message that selects that filter configuration.
For example, here's a
crowtty
session where I enable theTRACE
levelfor the TWI driver, but
INFO
for all other modules. Note that none ofthe traces from other parts of mnemOS, such as
comms::bbq
or the SHARPdisplay driver, are displayed, so we only see the very verbose
diagnostics from the TWI driver.
Fixes #153