<?php

include_once './Whatap.php';

$start_memory = memory_get_usage();
$start_memory1 = memory_get_usage(true);
echo "start=".$start_memory.",start1=".$start_memory1."<br/>";

$mtrace_httpc_host="http://localhost";

// Start whatap_begin_spot(string, boolean);
$url = $mtrace_httpc_host."/sample.php";

echo "Whatap - multi transaction trace <hr/>";

$ch = curl_init();
$headers = array();

echo "Get Mtrace opt and set curl header(x-wtap-mst, x-wtap-inf, x-wtap-tx) <hr/>";
//==================================================================
$whatap_mtrace = Whatap::whatap_get_mtrace();
foreach ($whatap_mtrace as $key => $value){
	//echo $key."=".$value."<br/>";
	array_push($headers, "$key:$value");
}
unset($value);

echo "MTID=".Whatap::whatap_mtid();
//==================================================================

echo "<hr/>";

curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_HEADER, TRUE);

$ret = curl_exec($ch);

curl_close($ch);
//echo "Result=".$ret;

$end_memory = memory_get_usage();
$end_memory1 = memory_get_usage(true);
echo "end=".$end_memory.",end1=".$end_memory1."<br/>";
echo ($end_memory - $start_memory)."<br/>";
echo ($end_memory1 - $start_memory1)."<br/>";

?>
