Skip to content
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

Logger instrumentation #4063

Conversation

JonathanWoollett-Light
Copy link
Contributor

@JonathanWoollett-Light JonathanWoollett-Light commented Aug 21, 2023

Changes

Adds support for tracing the Firecracker process with logs.

See https://github.com/JonathanWoollett-Light/firecracker/blob/logger-instrumentation/docs/tracing.md

ls -l ./build/cargo_target/release/firecracker

Before PR After PR After PR with instrumentation
9,941kb 9,949kb 10,060kb

The change in binary size from 9,941kb to 9,949kb of 8kb is a result of feat: Add module filter.

Follow-up issues to add CI test: #4215

Reason

It is a valuable feature when debugging, especially in restricted environments where it may be difficult to run another process like strace.

License Acceptance

By submitting this pull request, I confirm that my contribution is made under
the terms of the Apache 2.0 license. For more information on following
Developer Certificate of Origin and signing off your commits, please check
CONTRIBUTING.md.

PR Checklist

  • If a specific issue led to this PR, this PR closes the issue.
  • The description of changes is clear and encompassing.
  • Any required documentation changes (code and docs) are included in this PR.
  • API changes follow the Runbook for Firecracker API changes.
  • User-facing changes are mentioned in CHANGELOG.md.
  • All added/changed functionality is tested.
  • New TODOs link to an issue.
  • Commits meet contribution quality standards.

  • This functionality cannot be added in rust-vmm.

@codecov
Copy link

codecov bot commented Aug 21, 2023

Codecov Report

Attention: 31 lines in your changes are missing coverage. Please review.

Comparison is base (e77c1ac) 82.84% compared to head (3ed64be) 82.96%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4063      +/-   ##
==========================================
+ Coverage   82.84%   82.96%   +0.11%     
==========================================
  Files         222      230       +8     
  Lines       28330    28710     +380     
==========================================
+ Hits        23471    23820     +349     
- Misses       4859     4890      +31     
Flag Coverage Δ
4.14-c7g.metal 78.56% <91.92%> (+0.21%) ⬆️
4.14-m5d.metal 80.36% <91.92%> (+0.16%) ⬆️
4.14-m6a.metal 79.51% <91.92%> (+0.18%) ⬆️
4.14-m6g.metal 78.56% <91.92%> (+0.21%) ⬆️
4.14-m6i.metal 80.36% <91.92%> (+0.16%) ⬆️
5.10-c7g.metal 81.46% <91.92%> (+0.16%) ⬆️
5.10-m5d.metal 83.03% <91.92%> (+0.12%) ⬆️
5.10-m6a.metal 82.28% <91.92%> (+0.14%) ⬆️
5.10-m6g.metal 81.46% <91.92%> (+0.16%) ⬆️
5.10-m6i.metal 83.02% <91.92%> (+0.12%) ⬆️
6.1-c7g.metal 81.46% <91.92%> (+0.16%) ⬆️
6.1-m5d.metal 83.03% <91.92%> (+0.12%) ⬆️
6.1-m6a.metal 82.28% <91.92%> (+0.14%) ⬆️
6.1-m6g.metal 81.46% <91.92%> (+0.16%) ⬆️
6.1-m6i.metal 83.02% <91.92%> (+0.12%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
src/api_server/src/request/logger.rs 100.00% <ø> (ø)
src/log-instrument/src/bin/five.rs 100.00% <100.00%> (ø)
src/log-instrument/src/bin/four.rs 100.00% <100.00%> (ø)
src/log-instrument/src/bin/one.rs 100.00% <100.00%> (ø)
src/log-instrument/src/bin/six.rs 100.00% <100.00%> (ø)
src/log-instrument/src/bin/three.rs 100.00% <100.00%> (ø)
src/log-instrument/src/bin/two.rs 100.00% <100.00%> (ø)
src/log-instrument/src/lib.rs 100.00% <100.00%> (ø)
src/vmm/src/rpc_interface.rs 63.26% <ø> (ø)
src/firecracker/src/main.rs 0.22% <0.00%> (-0.01%) ⬇️
... and 2 more

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@JonathanWoollett-Light JonathanWoollett-Light force-pushed the logger-instrumentation branch 6 times, most recently from 7e7c50e to 59527f5 Compare August 25, 2023 16:19
@JonathanWoollett-Light JonathanWoollett-Light force-pushed the logger-instrumentation branch 9 times, most recently from 735bff2 to a7aee59 Compare August 31, 2023 11:44
@JonathanWoollett-Light JonathanWoollett-Light added the Status: Blocked Indicates that an issue or pull request cannot currently be worked on label Aug 31, 2023
@JonathanWoollett-Light
Copy link
Contributor Author

Blocked on #4047

@JonathanWoollett-Light JonathanWoollett-Light force-pushed the logger-instrumentation branch 11 times, most recently from 7c22318 to d6a279f Compare September 1, 2023 14:57
src/clippy-tracing/README.md Outdated Show resolved Hide resolved
src/clippy-tracing/src/main.rs Outdated Show resolved Hide resolved
src/clippy-tracing/src/main.rs Outdated Show resolved Hide resolved
src/clippy-tracing/src/main.rs Show resolved Hide resolved
src/clippy-tracing/src/main.rs Show resolved Hide resolved
src/clippy-tracing/src/main.rs Outdated Show resolved Hide resolved
Copy link
Contributor

@kalyazin kalyazin left a comment

Choose a reason for hiding this comment

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

  1. It would nice to have a Firecracker-level integration test that verifies that instrumentation works for Firecracker specifically, not only on its own.
  2. I can see some uncovered lines in the codecov report. Specifically action and exclude in CommandLineArgs. Are there reasons for them and others not to be covered?

src/api_server/src/request/logger.rs Show resolved Hide resolved
src/api_server/swagger/firecracker.yaml Show resolved Hide resolved
src/clippy-tracing/src/main.rs Outdated Show resolved Hide resolved
src/clippy-tracing/src/main.rs Outdated Show resolved Hide resolved
src/clippy-tracing/src/main.rs Outdated Show resolved Hide resolved
src/clippy-tracing/tests/integration_tests.rs Outdated Show resolved Hide resolved
src/log-instrument-macros/src/lib.rs Outdated Show resolved Hide resolved
src/log-instrument/src/bin/one.rs Outdated Show resolved Hide resolved
docs/tracing.md Show resolved Hide resolved
CHANGELOG.md Outdated Show resolved Hide resolved
@JonathanWoollett-Light JonathanWoollett-Light force-pushed the logger-instrumentation branch 6 times, most recently from 36e35ac to a3ea9b1 Compare October 26, 2023 14:40
@JonathanWoollett-Light JonathanWoollett-Light force-pushed the logger-instrumentation branch 3 times, most recently from cf49312 to bf33800 Compare November 1, 2023 14:02
@JonathanWoollett-Light
Copy link
Contributor Author

2. I can see some uncovered lines in the codecov report. Specifically action and exclude in CommandLineArgs. Are there reasons for them and others not to be covered?

There are tests covering all the action variants, I am not sure why this would not be covered.

I've added a test to cover exclude.

@JonathanWoollett-Light JonathanWoollett-Light force-pushed the logger-instrumentation branch 3 times, most recently from 5e392e9 to db16dcb Compare November 3, 2023 15:54
@JonathanWoollett-Light JonathanWoollett-Light force-pushed the logger-instrumentation branch 2 times, most recently from 45174ef to d68fd5a Compare November 6, 2023 07:44
@wearyzen
Copy link
Contributor

wearyzen commented Nov 6, 2023

I think all comments are addressed but before merge, could you please confirm and resolve all comments from Nikita.
We also discussed to create an issue to add CI test for logger, it would be good to add the issue# in the description.

Jonathan Woollett-Light added 5 commits November 6, 2023 13:25
`log_path` is no longer required by the `/logger` API. Removes
`log_path` from `required:` in the `firecracker.yaml` swagger
specification for the API.

Signed-off-by: Jonathan Woollett-LIght <[email protected]>
Adds  a module filter to the logger. This allows a user at runtime to
filter log messages by the Rust source code crate and module from which
they originate.

Signed-off-by: Jonathan Woollett-Light <[email protected]>
Adds a crate (`log-instrument`) with an instrumentation macro.
Adds a binary (`clippy-tracing`) to add, remove and check for
instrumentation.

Signed-off-by: Jonathan Woollett-Light <[email protected]>
Add `tracing.md` to document how to use the instrumentation to trace the
Firecracker process.

Signed-off-by: Jonathan Woollett-Light <[email protected]>
Added an entry in the change log on adding tracing.

Signed-off-by: Jonathan Woollett-Light <[email protected]>
@JonathanWoollett-Light JonathanWoollett-Light merged commit f15f840 into firecracker-microvm:main Nov 6, 2023
6 of 7 checks passed
@wearyzen wearyzen mentioned this pull request Nov 9, 2023
9 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants