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

chore: fine grained tracing #3002

Merged
merged 6 commits into from
May 4, 2023
Merged

Conversation

IWANABETHATGUY
Copy link
Contributor

@IWANABETHATGUY IWANABETHATGUY commented May 4, 2023

Related issue (if exists)

#2989, not sure if we could close that.

Summary

  1. Before we could only use TRACE, INFO, etc, to enable tracing . The method we used before has a pitfall, we can't did some fine-grained event filter, for example, only emit the event in function rspack_core::compiler::compilation:xxxx. This might be a problem when you are trying to debug a big project which might have thousands of modules, the tracing file would be too long to read.
  2. After this pull request, we could use the same syntax supported by Tokio tracing https://docs.rs/tracing-subscriber/latest/tracing_subscriber/filter/struct.EnvFilter.html#directives. when you want to trace all debug event in rspack emitted by rspack* crate, you could use
TRACE=info cargo rb bench -F tracing &| sed -e 's/\x1b\[[0-9;]*m//g' > result.log   

or for javascript

TRACE=info npx rspack build

If you only care about event in mod rspack_core::compiler::compilation you could use

TRACE=rspack_core::compiler::compilation cargo rb bench -F tracing &| sed -e 's/\x1b\[[0-9;]*m//g' > result.log   

🤖 Generated by Copilot at 50acdb1

This pull request improves the tracing functionality for the bench and rspack_tracing crates. It allows the bench crate to select different tracing output formats by setting an environment variable. It also simplifies the tracing configuration and output in the rspack_tracing crate by using the EnvFilter layer.

Walkthrough

🤖 Generated by Copilot at 50acdb1

  • Add Layer enum to control tracing output format (link)
  • Import FromStr trait to implement Layer enum (link)
  • Modify run function to take layer parameter and pass it to tracing initialization functions (link)
  • Return Option<FlushGuard> from tracing initialization functions to flush output when out of scope (link, link)
  • Simplify tracing enabling condition by checking only TRACE environment variable (link)
  • Use EnvFilter layer to allow user to specify target and level filters by environment variable (link)
  • Remove #[cfg(feature = "tracing")] attribute and always enable tracing feature (link)
  • Fix typo in smoke-example/basic path (link)

@changeset-bot
Copy link

changeset-bot bot commented May 4, 2023

⚠️ No Changeset found

Latest commit: cc2e630

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@github-actions github-actions bot added the team The issue/pr is created by the member of Rspack. label May 4, 2023
@IWANABETHATGUY IWANABETHATGUY force-pushed the chore/fine-grained-tracing branch from 0a93c14 to aac795b Compare May 4, 2023 10:46
@IWANABETHATGUY IWANABETHATGUY marked this pull request as ready for review May 4, 2023 10:47
@IWANABETHATGUY IWANABETHATGUY requested a review from hyf0 as a code owner May 4, 2023 10:47
@IWANABETHATGUY IWANABETHATGUY requested review from hardfist and h-a-n-a May 4, 2023 10:47
@IWANABETHATGUY IWANABETHATGUY added this pull request to the merge queue May 4, 2023
Merged via the queue into main with commit 11c97ad May 4, 2023
@IWANABETHATGUY IWANABETHATGUY deleted the chore/fine-grained-tracing branch May 4, 2023 11:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
team The issue/pr is created by the member of Rspack.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants