8000 Fix guest tracing filter by dblnz · Pull Request #977 · hyperlight-dev/hyperlight · GitHub
[go: up one dir, main page]

Skip to content

Fix guest tracing filter#977

Merged
dblnz merged 4 commits intohyperlight-dev:mainfrom
dblnz:fix-tracing-filter
Mar 5, 2026
Merged

Fix guest tracing filter#977
dblnz merged 4 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

@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

@dblnz dblnz force-pushed the fix-tracing-filter branch 5 times, most recently from 6e47f8f to 72aaf11 Compare February 19, 2026 14:13
jsturtevant
jsturtevant previously approved these changes Feb 20, 2026
ludfjig
ludfjig previously approved these changes Feb 20, 2026
Copy link
Contributor
Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes issue #990 by implementing proper filtering of guest tracing spans and events based on the max_log_level parameter. Previously, even though the log level was correctly received by guests, only logs were filtered while tracing spans and events were not.

Changes:

  • Introduced a new GuestLogFilter enum to unify log level conversions between log::LevelFilter, tracing_core::LevelFilter, and u64 values passed across the host-guest boundary
  • Implemented filtering in the GuestSubscriber::enabled() method to properly filter tracing spans and events based on the maximum log level
  • Updated trace span levels from Trace to Info for infrastructure calls (halt, dispatch_function, call_guest_function, call_host_function) to ensure they are visible at appropriate log levels and updated test expectations accordingly

Reviewed changes

Copilot reviewed 18 out of 22 changed files in this pull request and generated 2 comments.

Show a summary per file
8000 File Description
src/hyperlight_common/src/log_level.rs New file introducing GuestLogFilter enum with conversions to/from log::LevelFilter, tracing_core::LevelFilter, and u64
src/hyperlight_common/src/lib.rs Adds log_level module export
src/hyperlight_common/Cargo.toml Adds tracing-core dependency
src/hyperlight_guest_tracing/src/subscriber.rs Adds max_log_level field and implements filtering in enabled() method
src/hyperlight_guest_tracing/src/lib.rs Updates init_guest_tracing to accept LevelFilter parameter
src/hyperlight_guest_tracing/Cargo.toml Adds "log" feature to tracing dependency for log/tracing interop
src/hyperlight_guest_bin/src/lib.rs Updates to use GuestLogFilter for initialization
src/hyperlight_guest_bin/src/guest_logger.rs Minor parameter rename for clarity
src/hyperlight_guest_bin/src/guest_function/call.rs Updates trace levels from Trace to Info and removes explicit parent span references
src/hyperlight_host/src/hypervisor/mod.rs Removes old get_max_log_level function
src/hyperlight_host/src/hypervisor/hyperlight_vm.rs Adds new get_max_log_level_filter and get_guest_log_filter functions with proper conversions
src/hyperlight_host/src/sandbox/uninitialized.rs Updates imports to use tracing_core::LevelFilter
src/hyperlight_host/src/sandbox/trace/context.rs Updates span levels from trace to info
src/hyperlight_host/tests/integration_test.rs Updates test expectations to account for new info-level trace logs and converts to use tracing_core::LevelFilter
src/hyperlight_guest/src/exit.rs Updates halt span level from Trace to Info
src/hyperlight_guest/src/guest_handle/io.rs Removes explicit parent span reference
src/hyperlight_guest/src/guest_handle/host_comm.rs Adds instrumentation and updates trace levels
src/tests/rust_guests/simpleguest/src/main.rs CRITICAL BUG: Incorrect conversion logic in LogMessage function
Cargo.lock files Updates dependency locks for tracing-core additions

@dblnz dblnz dismissed stale reviews from ludfjig and jsturtevant via 214c2de February 23, 2026 11:13
@dblnz dblnz force-pushed the fix-tracing-filter branch from 72aaf11 to 214c2de Compare February 23, 2026 11:13
Copy link
Contributor
Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 17 out of 21 changed files in this pull request and generated 3 comments.

@dblnz dblnz force-pushed the fix-tracing-filter branch from 214c2de to f4c4af9 Compare February 23, 2026 11:48
ludfjig
ludfjig previously approved these changes Feb 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.

Awesome!

jsturtevant
jsturtevant previously approved these changes Feb 23, 2026
@dblnz dblnz dismissed stale reviews from jsturtevant and ludfjig via b243e36 February 24, 2026 11:05
@dblnz dblnz force-pushed the fix-tracing-filter branch from f4c4af9 to b243e36 Compare February 24, 2026 11:05
dblnz added 3 commits March 3, 2026 22:50
…arent

- To make the codebase more readable, remove the `parent` argument from
  the `#[instrument]` attribute.

Signed-off-by: Doru Blânzeanu <dblnz@pm.me>
- The `max_log_level` argument provided to the guest function is
  now used to filter traces also

Signed-off-by: Doru Blânzeanu <dblnz@pm.me>
… and logging

- Adds a `GuestLogFilter` enum that is used as an intermediary type
  between the `u64` used as a register to call the guest entrypoint and
  the `log::LogFilter` or `tracing_core::LogFilter`.
- Adds unit tests for the `GuestLogFilter`.

Signed-off-by: Doru Blânzeanu <dblnz@pm.me>
@dblnz dblnz force-pushed the fix-tracing-filter branch from b243e36 to e7fe98b Compare March 3, 2026 20:53
- Add more comments and tests to verify the new logic works as expected

Signed-off-by: Doru Blânzeanu <dblnz@pm.me>
@dblnz dblnz force-pushed the fix-tracing-filter branch from e7fe98b to 57170e2 Compare March 3, 2026 21:57
@dblnz dblnz merged commit facac5d into hyperlight-dev:main Mar 5, 2026
56 checks passed
danbugs pushed a commit to nanvix/hyperlight that referenced this pull request Mar 5, 2026
* [trace-guest] Update guest library trace levels and remove explicit parent

- To make the codebase more readable, remove the `parent` argument from
  the `#[instrument]` attribute.

Signed-off-by: Doru Blânzeanu <dblnz@pm.me>

* [trace-guest] Add trace filtering based on max_log_level

- The `max_log_level` argument provided to the guest function is
  now used to filter traces also

Signed-off-by: Doru Blânzeanu <dblnz@pm.me>

* [trace-guest] Define a common log level filter to be used for tracing and logging

- Adds a `GuestLogFilter` enum that is used as an intermediary type
  between the `u64` used as a register to call the guest entrypoint and
  the `log::LogFilter` or `tracing_core::LogFilter`.
- Adds unit tests for the `GuestLogFilter`.

Signed-off-by: Doru Blânzeanu <dblnz@pm.me>

* [host] Simplify `get_max_log_level_filter` function

- Add more comments and tests to verify the new logic works as expected

Signed-off-by: Doru Blânzeanu <dblnz@pm.me>

---------

Signed-off-by: Doru Blânzeanu <dblnz@pm.me>
Signed-off-by: danbugs <danilochiarlone@gmail.com>
danbugs pushed a commit to nanvix/hyperlight that referenced this pull request Mar 5, 2026
* [trace-guest] Update guest library trace levels and remove explicit parent

- To make the codebase more readable, remove the `parent` argument from
  the `#[instrument]` attribute.

Signed-off-by: Doru Blânzeanu <dblnz@pm.me>

* [trace-guest] Add trace filtering based on max_log_level

- The `max_log_level` argument provided to the guest function is
  now used to filter traces also

Signed-off-by: Doru Blânzeanu <dblnz@pm.me>

* [trace-guest] Define a common log level filter to be used for tracing and logging

- Adds a `GuestLogFilter` enum that is used as an intermediary type
  between the `u64` used as a register to call the guest entrypoint and
  the `log::LogFilter` or `tracing_core::LogFilter`.
- Adds unit tests for the `GuestLogFilter`.

Signed-off-by: Doru Blânzeanu <dblnz@pm.me>

* [host] Simplify `get_max_log_level_filter` function

- Add more comments and tests to verify the new logic works as expected

Signed-off-by: Doru Blânzeanu <dblnz@pm.me>

---------

Signed-off-by: Doru Blânzeanu <dblnz@pm.me>
Signed-off-by: danbugs <danilochiarlone@gmail.com>
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

4 participants

0