You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by wu...@apache.org on 2022/11/11 08:27:40 UTC

[skywalking-php] branch master updated: Add missing request_id. (#31)

This is an automated email from the ASF dual-hosted git repository.

wusheng pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/skywalking-php.git


The following commit(s) were added to refs/heads/master by this push:
     new 5ba1c58  Add missing request_id. (#31)
5ba1c58 is described below

commit 5ba1c5817f32fea80198b1aa35e901a8a8ace3f2
Author: jmjoy <jm...@apache.org>
AuthorDate: Fri Nov 11 16:27:36 2022 +0800

    Add missing request_id. (#31)
---
 src/plugin/plugin_mysqli.rs |  8 ++++----
 src/plugin/plugin_pdo.rs    | 12 ++++++------
 src/plugin/plugin_predis.rs |  4 ++--
 3 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/src/plugin/plugin_mysqli.rs b/src/plugin/plugin_mysqli.rs
index e40ea98..d47f1a0 100644
--- a/src/plugin/plugin_mysqli.rs
+++ b/src/plugin/plugin_mysqli.rs
@@ -94,14 +94,14 @@ impl MySQLImprovedPlugin {
     ) -> (Box<BeforeExecuteHook>, Box<AfterExecuteHook>) {
         let function_name = function_name.to_owned();
         (
-            Box::new(move |_, execute_data| {
+            Box::new(move |request_id, execute_data| {
                 let this = get_this_mut(execute_data)?;
                 let handle = this.handle();
 
                 debug!(handle, function_name, "call mysql method");
 
                 let mut span = with_info(handle, |info| {
-                    create_mysqli_exit_span("mysqli", &function_name, info)
+                    create_mysqli_exit_span(request_id, "mysqli", &function_name, info)
                 })?;
 
                 if execute_data.num_args() >= 1 {
@@ -118,9 +118,9 @@ impl MySQLImprovedPlugin {
 }
 
 fn create_mysqli_exit_span(
-    class_name: &str, function_name: &str, info: &MySQLInfo,
+    request_id: Option<i64>, class_name: &str, function_name: &str, info: &MySQLInfo,
 ) -> anyhow::Result<Span> {
-    RequestContext::try_with_global_ctx(None, |ctx| {
+    RequestContext::try_with_global_ctx(request_id, |ctx| {
         let mut span = ctx.create_exit_span(
             &format!("{}->{}", class_name, function_name),
             &format!("{}:{}", info.hostname, info.port),
diff --git a/src/plugin/plugin_pdo.rs b/src/plugin/plugin_pdo.rs
index 21205c9..2a349bc 100644
--- a/src/plugin/plugin_pdo.rs
+++ b/src/plugin/plugin_pdo.rs
@@ -109,13 +109,13 @@ impl PdoPlugin {
     ) -> (Box<BeforeExecuteHook>, Box<AfterExecuteHook>) {
         let function_name = function_name.to_owned();
         (
-            Box::new(move |_, execute_data| {
+            Box::new(move |request_id, execute_data| {
                 let handle = get_this_mut(execute_data)?.handle();
 
                 debug!(handle, function_name, "call PDO method");
 
                 let mut span = with_dsn(handle, |dsn| {
-                    create_exit_span_with_dsn("PDO", &function_name, dsn)
+                    create_exit_span_with_dsn(request_id, "PDO", &function_name, dsn)
                 })?;
 
                 if execute_data.num_args() >= 1 {
@@ -135,14 +135,14 @@ impl PdoPlugin {
     ) -> (Box<BeforeExecuteHook>, Box<AfterExecuteHook>) {
         let function_name = function_name.to_owned();
         (
-            Box::new(move |_, execute_data| {
+            Box::new(move |request_id, execute_data| {
                 let this = get_this_mut(execute_data)?;
                 let handle = this.handle();
 
                 debug!(handle, function_name, "call PDOStatement method");
 
                 let mut span = with_dsn(handle, |dsn| {
-                    create_exit_span_with_dsn("PDOStatement", &function_name, dsn)
+                    create_exit_span_with_dsn(request_id, "PDOStatement", &function_name, dsn)
                 })?;
 
                 if let Some(query) = this.get_property("queryString").as_z_str() {
@@ -248,9 +248,9 @@ fn get_error_info_item(info: &ZArr, i: u64) -> anyhow::Result<&ZVal> {
 }
 
 fn create_exit_span_with_dsn(
-    class_name: &str, function_name: &str, dsn: &Dsn,
+    request_id: Option<i64>, class_name: &str, function_name: &str, dsn: &Dsn,
 ) -> anyhow::Result<Span> {
-    RequestContext::try_with_global_ctx(None, |ctx| {
+    RequestContext::try_with_global_ctx(request_id, |ctx| {
         let mut span =
             ctx.create_exit_span(&format!("{}->{}", class_name, function_name), &dsn.peer);
         span.with_span_object_mut(|obj| {
diff --git a/src/plugin/plugin_predis.rs b/src/plugin/plugin_predis.rs
index 79aceda..772dd3b 100644
--- a/src/plugin/plugin_predis.rs
+++ b/src/plugin/plugin_predis.rs
@@ -58,7 +58,7 @@ impl PredisPlugin {
     ) -> (Box<BeforeExecuteHook>, Box<AfterExecuteHook>) {
         let class_name = class_name.to_owned();
         (
-            Box::new(move |_, execute_data| {
+            Box::new(move |request_id, execute_data| {
                 validate_num_args(execute_data, 1)?;
 
                 let this = get_this_mut(execute_data)?;
@@ -87,7 +87,7 @@ impl PredisPlugin {
                     .context("call getArguments failed")?;
                 let arguments = arguments.expect_mut_z_arr()?;
 
-                let mut span = RequestContext::try_with_global_ctx(None, |ctx| {
+                let mut span = RequestContext::try_with_global_ctx(request_id, |ctx| {
                     Ok(ctx.create_exit_span(&format!("{}->{}", class_name, id), &peer))
                 })?;