Skip to content

Commit 853c9d8

Browse files
authored
chore: introduce tracing (#375)
* chore: add dependency * chore: update `Cargo.lock` * fix(cli): printing span events when verbose flag in enabled * stamp(sb_module_loader): apply tracing instrument
1 parent 88f8b77 commit 853c9d8

File tree

5 files changed

+13
-1
lines changed

5 files changed

+13
-1
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ glob = "0.3.1"
7979
httparse = "1.8"
8080
http = "0.2"
8181
faster-hex = "0.9.0"
82+
tracing = "0.1"
8283

8384
# DEBUG
8485
# [patch.crates-io]

crates/cli/src/main.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,21 +39,27 @@ fn main() -> Result<(), anyhow::Error> {
3939
let local = tokio::task::LocalSet::new();
4040
let res: Result<(), Error> = local.block_on(&runtime, async {
4141
let matches = get_cli().get_matches();
42+
let verbose = matches.get_flag("verbose");
4243

4344
if !matches.get_flag("quiet") {
4445
#[cfg(feature = "tracing")]
4546
{
47+
use tracing_subscriber::fmt::format::FmtSpan;
4648
use tracing_subscriber::EnvFilter;
4749

4850
tracing_subscriber::fmt()
4951
.with_env_filter(EnvFilter::from_default_env())
5052
.with_thread_names(true)
53+
.with_span_events(if verbose {
54+
FmtSpan::FULL
55+
} else {
56+
FmtSpan::NONE
57+
})
5158
.init()
5259
}
5360

5461
#[cfg(not(feature = "tracing"))]
5562
{
56-
let verbose = matches.get_flag("verbose");
5763
let include_source = matches.get_flag("log-source");
5864
logger::init(verbose, include_source);
5965
}

crates/sb_module_loader/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ once_cell.workspace = true
2525
deno_tls.workspace = true
2626
monch.workspace = true
2727
base64.workspace = true
28+
tracing.workspace = true
2829
sb_core = { version = "0.1.0", path = "../sb_core" }
2930
sb_node = { version = "0.1.0", path = "../node" }
3031
sb_npm = { version = "0.1.0", path = "../npm" }

crates/sb_module_loader/standalone/standalone_module_loader.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ use deno_core::{ModuleSpecifier, RequestedModuleType};
1414
use deno_semver::npm::NpmPackageReqReference;
1515
use eszip::deno_graph;
1616
use std::sync::Arc;
17+
use tracing::instrument;
1718

1819
use crate::node::cli_node_resolver::CliNodeResolver;
1920
use crate::util::arc_u8_to_arc_str;
@@ -33,6 +34,7 @@ pub struct EmbeddedModuleLoader {
3334
}
3435

3536
impl ModuleLoader for EmbeddedModuleLoader {
37+
#[instrument(level = "debug", skip(self))]
3638
fn resolve(
3739
&self,
3840
specifier: &str,
@@ -96,6 +98,7 @@ impl ModuleLoader for EmbeddedModuleLoader {
9698
Ok(specifier)
9799
}
98100

101+
#[instrument(level = "debug", skip_all, fields(specifier = original_specifier.as_str()))]
99102
fn load(
100103
&self,
101104
original_specifier: &ModuleSpecifier,

0 commit comments

Comments
 (0)