From 4c88c66fb79fc3742f4592252c260e7e012d5fcf Mon Sep 17 00:00:00 2001 From: Lucas Fernandes Nogueira Date: Thu, 9 May 2024 10:18:39 -0300 Subject: [PATCH] feat(tracing): IPC and custom protocol spans should not have a parent (#1247) --- .changes/force-ipc-span-parent-none.md | 5 +++++ src/android/binding.rs | 4 ++-- src/webkitgtk/mod.rs | 2 +- src/webkitgtk/web_context.rs | 3 +-- src/webview2/mod.rs | 4 ++-- src/wkwebview/mod.rs | 4 ++-- 6 files changed, 13 insertions(+), 9 deletions(-) create mode 100644 .changes/force-ipc-span-parent-none.md diff --git a/.changes/force-ipc-span-parent-none.md b/.changes/force-ipc-span-parent-none.md new file mode 100644 index 000000000..1d798731d --- /dev/null +++ b/.changes/force-ipc-span-parent-none.md @@ -0,0 +1,5 @@ +--- +"wry": patch +--- + +Force the IPC and custom protocol tracing spans to have no parent. diff --git a/src/android/binding.rs b/src/android/binding.rs index 5ec707516..8855f00b4 100644 --- a/src/android/binding.rs +++ b/src/android/binding.rs @@ -106,7 +106,7 @@ fn handle_request( if let Some(handler) = REQUEST_HANDLER.get() { #[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(); let mut request_builder = Request::builder(); @@ -309,7 +309,7 @@ pub unsafe fn ipc(mut env: JNIEnv, _: JClass, url: JString, body: JString) { match (env.get_string(&url), env.get_string(&body)) { (Ok(url), Ok(body)) => { #[cfg(feature = "tracing")] - let _span = tracing::info_span!("wry::ipc::handle").entered(); + let _span = tracing::info_span!(parent: None, "wry::ipc::handle").entered(); let url = url.to_string_lossy().to_string(); let body = body.to_string_lossy().to_string(); diff --git a/src/webkitgtk/mod.rs b/src/webkitgtk/mod.rs index f081bd17e..038d214a5 100644 --- a/src/webkitgtk/mod.rs +++ b/src/webkitgtk/mod.rs @@ -520,7 +520,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/webkitgtk/web_context.rs b/src/webkitgtk/web_context.rs index 3705fe82b..db9209d26 100644 --- a/src/webkitgtk/web_context.rs +++ b/src/webkitgtk/web_context.rs @@ -289,8 +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(); + let span = 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/webview2/mod.rs b/src/webview2/mod.rs index b7dfba99b..5cf0e43ab 100644 --- a/src/webview2/mod.rs +++ b/src/webview2/mod.rs @@ -744,7 +744,7 @@ impl InnerWebView { }; #[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(Request::builder().uri(url).body(js).unwrap()); Ok(()) @@ -785,7 +785,7 @@ impl InnerWebView { }; #[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(); // Request uri diff --git a/src/wkwebview/mod.rs b/src/wkwebview/mod.rs index 209c43922..31a434728 100644 --- a/src/wkwebview/mod.rs +++ b/src/wkwebview/mod.rs @@ -144,7 +144,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() { @@ -179,7 +179,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 webview_id = *this.get_ivar::("webview_id");