From a2f453746d9bdc228b915396b41f38ff8cb91491 Mon Sep 17 00:00:00 2001 From: Lucas Nogueira Date: Thu, 9 May 2024 10:04:07 -0300 Subject: [PATCH] feat(tracing): IPC and custom protocol spans should not have a parent --- .changes/force-ipc-parent-none.md | 5 +++++ src/webview/webkitgtk/mod.rs | 2 +- src/webview/webkitgtk/web_context.rs | 2 +- src/webview/webview2/mod.rs | 4 ++-- src/webview/wkwebview/mod.rs | 4 ++-- 5 files changed, 11 insertions(+), 6 deletions(-) create mode 100644 .changes/force-ipc-parent-none.md diff --git a/.changes/force-ipc-parent-none.md b/.changes/force-ipc-parent-none.md new file mode 100644 index 000000000..6390dc721 --- /dev/null +++ b/.changes/force-ipc-parent-none.md @@ -0,0 +1,5 @@ +--- +"wry": patch +--- + +Force the IPC and custom protocol tracing span to have no parent. diff --git a/src/webview/webkitgtk/mod.rs b/src/webview/webkitgtk/mod.rs index dd4305338..853bb30ec 100644 --- a/src/webview/webkitgtk/mod.rs +++ b/src/webview/webkitgtk/mod.rs @@ -90,7 +90,7 @@ impl InnerWebView { // Connect before registering as recommended by the docs manager.connect_script_message_received(None, move |_m, msg| { #[cfg(feature = "tracing")] - let _span = tracing::info_span!("wry::ipc::handle").entered(); + let _span = tracing::info_span!(parent: None, "wry::ipc::handle").entered(); if let Some(js) = msg.js_value() { if let Some(ipc_handler) = &ipc_handler { diff --git a/src/webview/webkitgtk/web_context.rs b/src/webview/webkitgtk/web_context.rs index 2e4c97bb6..1b4063993 100644 --- a/src/webview/webkitgtk/web_context.rs +++ b/src/webview/webkitgtk/web_context.rs @@ -289,7 +289,7 @@ where context.register_uri_scheme(name, move |request| { #[cfg(feature = "tracing")] let span = - tracing::info_span!("wry::custom_protocol::handle", uri = tracing::field::Empty).entered(); + tracing::info_span!(parent: None, "wry::custom_protocol::handle", uri = tracing::field::Empty).entered(); if let Some(uri) = request.uri() { let uri = uri.as_str(); diff --git a/src/webview/webview2/mod.rs b/src/webview/webview2/mod.rs index fd169dcb7..14d86e272 100644 --- a/src/webview/webview2/mod.rs +++ b/src/webview/webview2/mod.rs @@ -359,7 +359,7 @@ window.addEventListener('mousemove', (e) => window.chrome.webview.postMessage('_ if let Some(ipc_handler) = &ipc_handler { #[cfg(feature = "tracing")] - let _span = tracing::info_span!("wry::ipc::handle").entered(); + let _span = tracing::info_span!(parent: None, "wry::ipc::handle").entered(); ipc_handler(&window, js); } } @@ -518,7 +518,7 @@ window.addEventListener('mousemove', (e) => window.chrome.webview.postMessage('_ &WebResourceRequestedEventHandler::create(Box::new(move |_, args| { #[cfg(feature = "tracing")] let span = - tracing::info_span!("wry::custom_protocol::handle", uri = tracing::field::Empty) + tracing::info_span!(parent: None, "wry::custom_protocol::handle", uri = tracing::field::Empty) .entered(); if let Some(args) = args { let webview_request = args.Request()?; diff --git a/src/webview/wkwebview/mod.rs b/src/webview/wkwebview/mod.rs index 514b06adc..901dd13e3 100644 --- a/src/webview/wkwebview/mod.rs +++ b/src/webview/wkwebview/mod.rs @@ -94,7 +94,7 @@ impl InnerWebView { // Safety: objc runtime calls are unsafe unsafe { #[cfg(feature = "tracing")] - let _span = tracing::info_span!("wry::ipc::handle").entered(); + let _span = tracing::info_span!(parent: None, "wry::ipc::handle").entered(); let function = this.get_ivar::<*mut c_void>("function"); if !function.is_null() { @@ -122,7 +122,7 @@ impl InnerWebView { extern "C" fn start_task(this: &Object, _: Sel, _webview: id, task: id) { unsafe { #[cfg(feature = "tracing")] - let span = tracing::info_span!("wry::custom_protocol::handle", uri = tracing::field::Empty) + let span = tracing::info_span!(parent: None, "wry::custom_protocol::handle", uri = tracing::field::Empty) .entered(); let function = this.get_ivar::<*mut c_void>("function"); if !function.is_null() {