MCPcopy Create free account
hub / github.com/apache/skywalking-php / hook_pdo_construct

Method hook_pdo_construct

src/plugin/plugin_pdo.rs:87–115  ·  view source on GitHub ↗
(&self)

Source from the content-addressed store, hash-verified

85
86impl PdoPlugin {
87 fn hook_pdo_construct(&self) -> (Box<BeforeExecuteHook>, Box<AfterExecuteHook>) {
88 (
89 Box::new(|request_id, execute_data| {
90 validate_num_args(execute_data, 1)?;
91
92 let this = get_this_mut(execute_data)?;
93 let handle = this.handle();
94 hack_dtor(this, Some(pdo_dtor));
95
96 let dsn = execute_data.get_parameter(0);
97 let dsn = dsn.as_z_str().context("dsn isn't str")?.to_str()?;
98 debug!(dsn, handle, "construct PDO");
99
100 let dsn: Dsn = dsn.parse()?;
101 debug!(?dsn, "parse PDO dsn");
102
103 let span = create_exit_span_with_dsn(request_id, "PDO", "__construct", &dsn)?;
104
105 DSN_MAP.insert(handle, dsn);
106
107 Ok(Box::new(span))
108 }),
109 Box::new(move |_, span, _, _| {
110 let mut span = span.downcast::<Span>().unwrap();
111 log_exception(&mut *span);
112 Ok(())
113 }),
114 )
115 }
116
117 fn hook_pdo_methods(
118 &self, function_name: &str,

Callers 1

hookMethod · 0.80

Calls 5

validate_num_argsFunction · 0.85
get_this_mutFunction · 0.85
hack_dtorFunction · 0.85
log_exceptionFunction · 0.85

Tested by

no test coverage detected