in src/plugin/plugin_amqplib.rs [65:111]
fn hook_channel_basic_publish(
&self, class_name: &str, function_name: &str,
) -> (Box<BeforeExecuteHook>, Box<AfterExecuteHook>) {
let class_name = class_name.to_owned();
let function_name = function_name.to_owned();
(
Box::new(move |request_id, execute_data| {
validate_num_args(execute_data, 1)?;
let this = get_this_mut(execute_data)?;
let peer = Self::get_peer(this);
let exchange = execute_data
.get_parameter(1)
.as_z_str()
.and_then(|s| s.to_str().ok())
.map(ToOwned::to_owned)
.unwrap_or_else(|| "unknown".to_owned());
let routing_key = execute_data
.get_parameter(2)
.as_z_str()
.and_then(|s| s.to_str().ok())
.map(ToOwned::to_owned)
.unwrap_or_else(|| "unknown".to_owned());
let span = Self::create_exit_span(
request_id,
&class_name,
&function_name,
&peer,
&exchange,
&routing_key,
)?;
Self::inject_sw_header(request_id, execute_data, &peer)?;
Ok(Box::new(span))
}),
Box::new(move |_, span, _, _| {
let mut span = span.downcast::<Span>().unwrap();
log_exception(&mut *span);
Ok(())
}),
)
}