Skip to content

Commit 0ffffa8

Browse files
committed
chore: add more tracing instrumentations (#9220)
1 parent de65659 commit 0ffffa8

5 files changed

Lines changed: 109 additions & 3 deletions

File tree

crates/rolldown/src/bundler/impl_bundler_hmr.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ use std::sync::{Arc, atomic::AtomicU32};
99

1010
impl Bundler {
1111
#[cfg(feature = "experimental")]
12+
#[tracing::instrument(level = "debug", skip_all)]
1213
pub async fn compute_hmr_update_for_file_changes(
1314
&mut self,
1415
changed_file_paths: &FxIndexMap<String, WatcherChangeKind>,

crates/rolldown_dev/src/bundling_task.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ impl BundlingTask {
121121
Ok(())
122122
}
123123

124+
#[tracing::instrument(level = "trace", skip(self))]
124125
pub async fn generate_hmr_updates(
125126
&mut self,
126127
has_full_reload_update: &mut bool,
@@ -184,6 +185,7 @@ impl BundlingTask {
184185
}
185186
}
186187

188+
#[tracing::instrument(level = "trace", skip_all)]
187189
async fn rebuild(&mut self) -> BuildResult<()> {
188190
let mut bundler = self.bundler.lock().await;
189191

crates/rolldown_plugin/src/plugin_driver/build_hooks.rs

Lines changed: 41 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,11 @@ use string_wizard::{MagicString, SourceMapOptions};
2222
use tracing::{Instrument, debug_span};
2323

2424
impl PluginDriver {
25-
#[tracing::instrument(level = "trace", skip_all)]
25+
#[tracing::instrument(
26+
level = "trace",
27+
target = "rolldown_plugin::plugin_driver::build_hooks::total::build_start",
28+
skip_all
29+
)]
2630
pub async fn build_start(&self, opts: &SharedNormalizedBundlerOptions) -> HookNoopReturn {
2731
for (plugin_idx, plugin, ctx) in
2832
self.iter_plugin_with_context_by_order(&self.order_by_build_start_meta)
@@ -56,6 +60,11 @@ impl PluginDriver {
5660
skipped_plugins
5761
}
5862

63+
#[tracing::instrument(
64+
level = "trace",
65+
target = "rolldown_plugin::plugin_driver::build_hooks::total::resolve_id",
66+
skip_all
67+
)]
5968
pub async fn resolve_id(
6069
&self,
6170
args: &HookResolveIdArgs<'_>,
@@ -134,8 +143,13 @@ impl PluginDriver {
134143
Ok(None)
135144
}
136145

137-
#[expect(deprecated)]
138146
// Only for rollup compatibility
147+
#[expect(deprecated)]
148+
#[tracing::instrument(
149+
level = "trace",
150+
target = "rolldown_plugin::plugin_driver::build_hooks::total::resolve_dynamic_import",
151+
skip_all
152+
)]
139153
pub async fn resolve_dynamic_import(
140154
&self,
141155
args: &HookResolveIdArgs<'_>,
@@ -173,6 +187,11 @@ impl PluginDriver {
173187
Ok(None)
174188
}
175189

190+
#[tracing::instrument(
191+
level = "trace",
192+
target = "rolldown_plugin::plugin_driver::build_hooks::total::load",
193+
skip_all
194+
)]
176195
pub async fn load(&self, args: &HookLoadArgs<'_>) -> HookLoadReturn {
177196
for (plugin_idx, plugin, ctx) in
178197
self.iter_plugin_with_context_by_order(&self.order_by_load_meta)
@@ -224,7 +243,11 @@ impl PluginDriver {
224243
Ok(None)
225244
}
226245

227-
#[tracing::instrument(target = "devtool", level = "trace", skip_all)]
246+
#[tracing::instrument(
247+
level = "trace",
248+
target = "rolldown_plugin::plugin_driver::build_hooks::total::transform",
249+
skip_all
250+
)]
228251
#[expect(clippy::too_many_arguments)]
229252
pub async fn transform(
230253
&self,
@@ -350,6 +373,11 @@ impl PluginDriver {
350373
}
351374
}
352375

376+
#[tracing::instrument(
377+
level = "trace",
378+
target = "rolldown_plugin::plugin_driver::build_hooks::total::transform_ast",
379+
skip_all
380+
)]
353381
pub async fn transform_ast(&self, mut args: HookTransformAstArgs<'_>) -> HookTransformAstReturn {
354382
for (_, plugin, ctx) in
355383
self.iter_plugin_with_context_by_order(&self.order_by_transform_ast_meta)
@@ -373,6 +401,11 @@ impl PluginDriver {
373401
Ok(args.ast)
374402
}
375403

404+
#[tracing::instrument(
405+
level = "trace",
406+
target = "rolldown_plugin::plugin_driver::build_hooks::total::module_parsed",
407+
skip_all
408+
)]
376409
pub async fn module_parsed(
377410
&self,
378411
module_info: Arc<ModuleInfo>,
@@ -389,6 +422,11 @@ impl PluginDriver {
389422
Ok(())
390423
}
391424

425+
#[tracing::instrument(
426+
level = "trace",
427+
target = "rolldown_plugin::plugin_driver::build_hooks::total::build_end",
428+
skip_all
429+
)]
392430
pub async fn build_end(&self, args: Option<&HookBuildEndArgs<'_>>) -> HookNoopReturn {
393431
for (plugin_idx, plugin, ctx) in
394432
self.iter_plugin_with_context_by_order(&self.order_by_build_end_meta)

crates/rolldown_plugin/src/plugin_driver/output_hooks.rs

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@ use rolldown_sourcemap::SourceMap;
1212
use tracing::Instrument;
1313

1414
impl PluginDriver {
15+
#[tracing::instrument(
16+
level = "trace",
17+
target = "rolldown_plugin::plugin_driver::output_hooks::total::render_start",
18+
skip_all
19+
)]
1520
pub async fn render_start(&self, opts: &SharedNormalizedBundlerOptions) -> HookNoopReturn {
1621
for (plugin_idx, plugin, ctx) in
1722
self.iter_plugin_with_context_by_order(&self.order_by_render_start_meta)
@@ -25,6 +30,11 @@ impl PluginDriver {
2530
Ok(())
2631
}
2732

33+
#[tracing::instrument(
34+
level = "trace",
35+
target = "rolldown_plugin::plugin_driver::output_hooks::total::banner",
36+
skip_all
37+
)]
2838
pub async fn banner(&self, args: HookAddonArgs, mut banner: String) -> Result<Option<String>> {
2939
for (plugin_idx, plugin, ctx) in
3040
self.iter_plugin_with_context_by_order(&self.order_by_banner_meta)
@@ -43,6 +53,11 @@ impl PluginDriver {
4353
Ok(Some(banner))
4454
}
4555

56+
#[tracing::instrument(
57+
level = "trace",
58+
target = "rolldown_plugin::plugin_driver::output_hooks::total::footer",
59+
skip_all
60+
)]
4661
pub async fn footer(&self, args: HookAddonArgs, mut footer: String) -> Result<Option<String>> {
4762
for (plugin_idx, plugin, ctx) in
4863
self.iter_plugin_with_context_by_order(&self.order_by_footer_meta)
@@ -61,6 +76,11 @@ impl PluginDriver {
6176
Ok(Some(footer))
6277
}
6378

79+
#[tracing::instrument(
80+
level = "trace",
81+
target = "rolldown_plugin::plugin_driver::output_hooks::total::intro",
82+
skip_all
83+
)]
6484
pub async fn intro(&self, args: HookAddonArgs, mut intro: String) -> Result<Option<String>> {
6585
for (plugin_idx, plugin, ctx) in
6686
self.iter_plugin_with_context_by_order(&self.order_by_intro_meta)
@@ -79,6 +99,11 @@ impl PluginDriver {
7999
Ok(Some(intro))
80100
}
81101

102+
#[tracing::instrument(
103+
level = "trace",
104+
target = "rolldown_plugin::plugin_driver::output_hooks::total::outro",
105+
skip_all
106+
)]
82107
pub async fn outro(&self, args: HookAddonArgs, mut outro: String) -> Result<Option<String>> {
83108
for (plugin_idx, plugin, ctx) in
84109
self.iter_plugin_with_context_by_order(&self.order_by_outro_meta)
@@ -97,6 +122,11 @@ impl PluginDriver {
97122
Ok(Some(outro))
98123
}
99124

125+
#[tracing::instrument(
126+
level = "trace",
127+
target = "rolldown_plugin::plugin_driver::output_hooks::total::render_chunk",
128+
skip_all
129+
)]
100130
pub async fn render_chunk(
101131
&self,
102132
mut args: HookRenderChunkArgs<'_>,
@@ -149,6 +179,11 @@ impl PluginDriver {
149179
Ok((args.code, sourcemap_chain))
150180
}
151181

182+
#[tracing::instrument(
183+
level = "trace",
184+
target = "rolldown_plugin::plugin_driver::output_hooks::total::augment_chunk_hash",
185+
skip_all
186+
)]
152187
pub async fn augment_chunk_hash(
153188
&self,
154189
chunk: Arc<RollupRenderedChunk>,
@@ -167,6 +202,11 @@ impl PluginDriver {
167202
Ok(hash)
168203
}
169204

205+
#[tracing::instrument(
206+
level = "trace",
207+
target = "rolldown_plugin::plugin_driver::output_hooks::total::render_error",
208+
skip_all
209+
)]
170210
pub async fn render_error(&self, args: &HookRenderErrorArgs<'_>) -> HookNoopReturn {
171211
for (plugin_idx, plugin, ctx) in
172212
self.iter_plugin_with_context_by_order(&self.order_by_render_error_meta)
@@ -179,6 +219,11 @@ impl PluginDriver {
179219
Ok(())
180220
}
181221

222+
#[tracing::instrument(
223+
level = "trace",
224+
target = "rolldown_plugin::plugin_driver::output_hooks::total::generate_bundle",
225+
skip_all
226+
)]
182227
pub async fn generate_bundle(
183228
&self,
184229
bundle: &mut Vec<Output>,
@@ -199,6 +244,11 @@ impl PluginDriver {
199244
Ok(())
200245
}
201246

247+
#[tracing::instrument(
248+
level = "trace",
249+
target = "rolldown_plugin::plugin_driver::output_hooks::total::write_bundle",
250+
skip_all
251+
)]
202252
pub async fn write_bundle(
203253
&self,
204254
bundle: &mut Vec<Output>,
@@ -218,6 +268,11 @@ impl PluginDriver {
218268
Ok(())
219269
}
220270

271+
#[tracing::instrument(
272+
level = "trace",
273+
target = "rolldown_plugin::plugin_driver::output_hooks::total::close_bundle",
274+
skip_all
275+
)]
221276
pub async fn close_bundle(&self, args: Option<&HookCloseBundleArgs<'_>>) -> HookNoopReturn {
222277
for (plugin_idx, plugin, ctx) in
223278
self.iter_plugin_with_context_by_order(&self.order_by_close_bundle_meta)

crates/rolldown_plugin/src/plugin_driver/watch_hooks.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ use rolldown_common::WatcherChangeKind;
55
use rolldown_error::CausedPlugin;
66

77
impl PluginDriver {
8+
#[tracing::instrument(
9+
level = "trace",
10+
target = "rolldown_plugin::plugin_driver::watch_hooks::total::watch_change",
11+
skip(self)
12+
)]
813
pub async fn watch_change(&self, path: &str, event: WatcherChangeKind) -> HookNoopReturn {
914
for (plugin_idx, plugin, ctx) in
1015
self.iter_plugin_with_context_by_order(&self.order_by_watch_change_meta)
@@ -17,6 +22,11 @@ impl PluginDriver {
1722
Ok(())
1823
}
1924

25+
#[tracing::instrument(
26+
level = "trace",
27+
target = "rolldown_plugin::plugin_driver::watch_hooks::total::close_watcher",
28+
skip(self)
29+
)]
2030
pub async fn close_watcher(&self) -> HookNoopReturn {
2131
for (plugin_idx, plugin, ctx) in
2232
self.iter_plugin_with_context_by_order(&self.order_by_close_watcher_meta)

0 commit comments

Comments
 (0)