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

Method hook_memcached_key_methods

src/plugin/plugin_memcached.rs:205–252  ·  view source on GitHub ↗
(
        &self, class_name: &str, function_name: &str,
    )

Source from the content-addressed store, hash-verified

203
204 #[instrument(skip_all)]
205 fn hook_memcached_key_methods(
206 &self, class_name: &str, function_name: &str,
207 ) -> (Box<BeforeExecuteHook>, Box<AfterExecuteHook>) {
208 let class_name = class_name.to_owned();
209 let function_name = function_name.to_owned();
210 (
211 Box::new(move |request_id, execute_data| {
212 let key = {
213 let key = execute_data.get_parameter(0);
214 if key.get_type_info().is_string() {
215 Some(key.clone())
216 } else {
217 // The `*Multi` methods will failed here.
218 warn!("The argument key of {} isn't string", &function_name);
219 None
220 }
221 };
222
223 let key_str = key
224 .as_ref()
225 .and_then(|key| key.as_z_str())
226 .and_then(|key| key.to_str().ok())
227 .map(ToOwned::to_owned);
228
229 let this = get_this_mut(execute_data)?;
230
231 let peer = key.map(|key| get_peer(this, key)).unwrap_or_default();
232
233 debug!(peer, "Get memcached peer");
234
235 let tag_info = MEMCACHE_KEY_METHOD_MAPPING
236 .get(&*function_name.to_ascii_lowercase())
237 .unwrap();
238
239 let span = create_exit_span(
240 request_id,
241 &class_name,
242 &function_name,
243 &peer,
244 tag_info,
245 key_str.as_deref(),
246 )?;
247
248 Ok(Box::new(span))
249 }),
250 Box::new(after_hook),
251 )
252 }
253
254 #[instrument(skip_all)]
255 fn hook_memcached_server_key_methods(

Callers 1

hookMethod · 0.80

Calls 3

get_this_mutFunction · 0.85
get_peerFunction · 0.70
create_exit_spanFunction · 0.70

Tested by

no test coverage detected