mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
Allow filtering of tracing events via SERVO_TRACING (#34236)
* Allow filtering of tracing events via SERVO_TRACING Signed-off-by: Delan Azabani <dazabani@igalia.com> * Assume SERVO_TRACING=off by default Signed-off-by: Delan Azabani <dazabani@igalia.com> --------- Signed-off-by: Delan Azabani <dazabani@igalia.com>
This commit is contained in:
parent
873e82a532
commit
c00804190c
4 changed files with 45 additions and 5 deletions
32
Cargo.lock
generated
32
Cargo.lock
generated
|
@ -4260,6 +4260,15 @@ dependencies = [
|
|||
"tendril",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "matchers"
|
||||
version = "0.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8263075bb86c5a1b1427b5ae862e8889656f126e9f77c484496e8b47cf5c5558"
|
||||
dependencies = [
|
||||
"regex-automata 0.1.10",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "matches"
|
||||
version = "0.1.10"
|
||||
|
@ -5803,7 +5812,16 @@ dependencies = [
|
|||
"aho-corasick",
|
||||
"memchr",
|
||||
"regex-automata 0.4.8",
|
||||
"regex-syntax",
|
||||
"regex-syntax 0.8.5",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "regex-automata"
|
||||
version = "0.1.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132"
|
||||
dependencies = [
|
||||
"regex-syntax 0.6.29",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -5823,9 +5841,15 @@ checksum = "368758f23274712b504848e9d5a6f010445cc8b87a7cdb4d7cbee666c1288da3"
|
|||
dependencies = [
|
||||
"aho-corasick",
|
||||
"memchr",
|
||||
"regex-syntax",
|
||||
"regex-syntax 0.8.5",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "regex-syntax"
|
||||
version = "0.6.29"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1"
|
||||
|
||||
[[package]]
|
||||
name = "regex-syntax"
|
||||
version = "0.8.5"
|
||||
|
@ -7533,10 +7557,14 @@ version = "0.3.18"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ad0f048c97dbd9faa9b7df56362b8ebcaa52adb06b498c050d2f4e32f90a7a8b"
|
||||
dependencies = [
|
||||
"matchers",
|
||||
"nu-ansi-term",
|
||||
"once_cell",
|
||||
"regex",
|
||||
"sharded-slab",
|
||||
"smallvec",
|
||||
"thread_local",
|
||||
"tracing",
|
||||
"tracing-core",
|
||||
"tracing-log",
|
||||
]
|
||||
|
|
|
@ -67,7 +67,7 @@ url = { workspace = true }
|
|||
servo-media = { workspace = true }
|
||||
tokio = { workspace = true }
|
||||
tracing = { workspace = true, optional = true }
|
||||
tracing-subscriber = { workspace = true, optional = true }
|
||||
tracing-subscriber = { workspace = true, optional = true, features = ["env-filter"] }
|
||||
tracing-perfetto = { workspace = true, optional = true }
|
||||
|
||||
[target.'cfg(target_os = "android")'.dependencies]
|
||||
|
|
|
@ -44,11 +44,11 @@ pub fn main() {
|
|||
pub fn init_tracing() {
|
||||
#[cfg(feature = "tracing")]
|
||||
{
|
||||
use tracing_subscriber::layer::SubscriberExt;
|
||||
let subscriber = tracing_subscriber::registry();
|
||||
|
||||
#[cfg(feature = "tracing-perfetto")]
|
||||
let subscriber = {
|
||||
use tracing_subscriber::layer::SubscriberExt;
|
||||
// Set up a PerfettoLayer for performance tracing.
|
||||
// The servo.pftrace file can be uploaded to https://ui.perfetto.dev for analysis.
|
||||
let file = std::fs::File::create("servo.pftrace").unwrap();
|
||||
|
@ -59,11 +59,18 @@ pub fn init_tracing() {
|
|||
|
||||
#[cfg(feature = "tracing-hitrace")]
|
||||
let subscriber = {
|
||||
use tracing_subscriber::layer::SubscriberExt;
|
||||
// Set up a HitraceLayer for performance tracing.
|
||||
subscriber.with(HitraceLayer::default())
|
||||
};
|
||||
|
||||
// Filter events and spans by the directives in SERVO_TRACING, using EnvFilter as a global filter.
|
||||
// <https://docs.rs/tracing-subscriber/0.3.18/tracing_subscriber/layer/index.html#global-filtering>
|
||||
let filter = tracing_subscriber::EnvFilter::builder()
|
||||
.with_default_directive(tracing::level_filters::LevelFilter::OFF.into())
|
||||
.with_env_var("SERVO_TRACING")
|
||||
.from_env_lossy();
|
||||
let subscriber = subscriber.with(filter);
|
||||
|
||||
// Same as SubscriberInitExt::init, but avoids initialising the tracing-log compat layer,
|
||||
// since it would break Servo’s FromScriptLogger and FromCompositorLogger.
|
||||
// <https://docs.rs/tracing-subscriber/0.3.18/tracing_subscriber/util/trait.SubscriberInitExt.html#method.init>
|
||||
|
|
|
@ -76,6 +76,11 @@ packages = [
|
|||
# tracing-subscriber -> matchers -> regex-automata 0.1.0
|
||||
"regex-automata",
|
||||
|
||||
# tracing-subscriber (tokio-rs/tracing#3033) uses old version
|
||||
# regex [-> regex-automata 0.4.7] -> regex-syntax 0.8.4
|
||||
# tracing-subscriber -> matchers -> regex-automata 0.1.0 -> regex-syntax 0.6.29
|
||||
"regex-syntax",
|
||||
|
||||
# gilrs is on 0.10.0, but Servo is still on 0.9.4
|
||||
"core-foundation",
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue