From d46418bb470761db48cd1a3e50578d4e1e82e577 Mon Sep 17 00:00:00 2001 From: OJ Kwon <1210596+kwonoj@users.noreply.github.com> Date: Wed, 17 Aug 2022 14:54:17 -0700 Subject: [PATCH] feat(es/plugin/runner): Add more traces for the plugin host (#5538) --- crates/swc/src/plugin.rs | 1 + crates/swc_common/src/plugin/serialized.rs | 6 ++++++ crates/swc_plugin_runner/src/transform_executor.rs | 1 + 3 files changed, 8 insertions(+) diff --git a/crates/swc/src/plugin.rs b/crates/swc/src/plugin.rs index ff3ada7d006..e8f63f0b722 100644 --- a/crates/swc/src/plugin.rs +++ b/crates/swc/src/plugin.rs @@ -159,6 +159,7 @@ impl RustPlugins { } #[cfg(all(feature = "plugin", target_arch = "wasm32"))] + #[tracing::instrument(level = "info", skip_all)] fn apply_inner(&mut self, n: Program) -> Result { use std::{path::PathBuf, sync::Arc}; diff --git a/crates/swc_common/src/plugin/serialized.rs b/crates/swc_common/src/plugin/serialized.rs index e3b29d869c5..4e4fea6d827 100644 --- a/crates/swc_common/src/plugin/serialized.rs +++ b/crates/swc_common/src/plugin/serialized.rs @@ -42,6 +42,7 @@ impl PluginSerializedBytes { * Constructs an instance from already serialized byte * slices. */ + #[tracing::instrument(level = "info", skip_all)] pub fn from_slice(bytes: &[u8]) -> PluginSerializedBytes { let mut field = rkyv::AlignedVec::new(); field.extend_from_slice(bytes); @@ -54,6 +55,7 @@ impl PluginSerializedBytes { * This is sort of mimic TryFrom behavior, since we can't use generic * to implement TryFrom trait */ + #[tracing::instrument(level = "info", skip_all)] pub fn try_serialize(t: &W) -> Result where W: rkyv::Serialize>, @@ -74,6 +76,7 @@ impl PluginSerializedBytes { /* * Internal fn to constructs an instance from raw bytes ptr. */ + #[tracing::instrument(level = "info", skip_all)] fn from_raw_ptr( raw_allocated_ptr: *const u8, raw_allocated_ptr_len: usize, @@ -92,6 +95,7 @@ impl PluginSerializedBytes { (self.field.as_ptr(), self.field.len()) } + #[tracing::instrument(level = "info", skip_all)] pub fn deserialize(&self) -> Result where W: rkyv::Archive, @@ -113,6 +117,7 @@ impl PluginSerializedBytes { /// /// # Safety /// This is naturally unsafe by constructing bytes slice from raw ptr. +#[tracing::instrument(level = "info", skip_all)] pub unsafe fn deserialize_from_ptr( raw_allocated_ptr: *const u8, raw_allocated_ptr_len: i32, @@ -136,6 +141,7 @@ where /// # Safety /// This is unsafe by construting bytes slice from raw ptr also deserialize /// it without slice bound check. +#[tracing::instrument(level = "info", skip_all)] pub unsafe fn deserialize_from_ptr_into_fallible( raw_allocated_ptr: *const u8, raw_allocated_ptr_len: i32, diff --git a/crates/swc_plugin_runner/src/transform_executor.rs b/crates/swc_plugin_runner/src/transform_executor.rs index eb8acbc273c..9868a3bdb87 100644 --- a/crates/swc_plugin_runner/src/transform_executor.rs +++ b/crates/swc_plugin_runner/src/transform_executor.rs @@ -88,6 +88,7 @@ impl TransformExecutor { /// Copy host's serialized bytes into guest (plugin)'s allocated memory. /// Once transformation completes, host should free allocated memory. + #[tracing::instrument(level = "info", skip_all)] fn write_bytes_into_guest( &mut self, serialized_bytes: &PluginSerializedBytes,