Skip to content

Fix guest tracing filter#977

Open
dblnz wants to merge 3 commits intohyperlight-dev:mainfrom
dblnz:fix-tracing-filter
Open

Fix guest tracing filter#977
dblnz wants to merge 3 commits intohyperlight-dev:mainfrom
dblnz:fix-tracing-filter

Conversation

@dblnz
Copy link
Contributor

@dblnz dblnz commented Oct 24, 2025

This closes #990.
Currently, when tracing guests, the max log level parameter provided to the guest is not used to filter out traces.

This PR adds the filtering capability for the guest tracing and also modifies some of the trace levels in the guest.
For that to work, a change in the integration_tests.rs was necessary to update the number of expected logs in log_message test

@dblnz dblnz added the kind/enhancement For PRs adding features, improving functionality, docs, tests, etc. label Oct 24, 2025
@dblnz dblnz self-assigned this Oct 24, 2025
@dblnz dblnz force-pushed the fix-tracing-filter branch from 489acde to 7ff7b03 Compare October 24, 2025 15:19
@dblnz dblnz force-pushed the fix-tracing-filter branch from 7ff7b03 to 58caf0d Compare January 23, 2026 12:30
@dblnz dblnz marked this pull request as ready for review January 23, 2026 12:31
ludfjig
ludfjig previously approved these changes Jan 23, 2026
Copy link
Contributor

@ludfjig ludfjig left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, but it would be nice if it was possible to remove all uses of tracing::log::LeverFilter and log::Levelfilter for tracing_core::LevelFilter/tracing::LevelFilter instead

Comment on lines 40 to 48
fn convert_level_filter(filter: tracing::log::LevelFilter) -> tracing_core::LevelFilter {
match filter {
tracing::log::LevelFilter::Off => tracing_core::LevelFilter::OFF,
tracing::log::LevelFilter::Error => tracing_core::LevelFilter::ERROR,
tracing::log::LevelFilter::Warn => tracing_core::LevelFilter::WARN,
tracing::log::LevelFilter::Info => tracing_core::LevelFilter::INFO,
tracing::log::LevelFilter::Debug => tracing_core::LevelFilter::DEBUG,
tracing::log::LevelFilter::Trace => tracing_core::LevelFilter::TRACE,
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible to tracing_core::LevelFilter everywhere instead of having this? (in entrypoint of hyperlight_guest_bin + whatever the host passes to the guest)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it is doable, I just wanted to avoid breaking changes.
But I think we'll have breaking changes this release anyway

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It turns out it's more complicated that I had anticipated.
First of all, tracing_core::LevelFIlter cannot be cast to u64 as an entrypoint argument. So, we still need to do some conversions.
Secondly, the logger inside the guest, still needs a log::LevelFilter.

The solution I've used is to have a separate hyperlight_common::log_level::GuestLogFilter that can convert from/to u64 and from/to LevelFilter (both log/tracing ones).

I think this is a short term solution, because I am going to eliminate the logger inside the guest, to only use the tracing approach across the guests logs and traces. That will eliminate the need for log::LevelFilter.

Let me know your opinion on this.

@jsturtevant
Copy link
Contributor

@dblnz would you like to get this into the next release (we have it scheduled for next week (Feb 25th)

@dblnz
Copy link
Contributor Author

dblnz commented Feb 18, 2026

@dblnz would you like to get this into the next release (we have it scheduled for next week (Feb 25th)

Yes, I'm rebasing it to include it in the release

…arent

Signed-off-by: Doru Blânzeanu <dblnz@pm.me>
Signed-off-by: Doru Blânzeanu <dblnz@pm.me>
@dblnz dblnz force-pushed the fix-tracing-filter branch 4 times, most recently from 4fc6b1c to 6e47f8f Compare February 19, 2026 11:19
… and logging

Signed-off-by: Doru Blânzeanu <dblnz@pm.me>
@dblnz dblnz force-pushed the fix-tracing-filter branch from 6e47f8f to 72aaf11 Compare February 19, 2026 14:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/enhancement For PRs adding features, improving functionality, docs, tests, etc.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix guest tracing filtering

3 participants

Comments