Inject a Correlation Header into an HTTP Payload Example
The next example injects a correlation header into the socket-based HTTP payload.
<?php
$url = 'http://myhost.mydomain/continue.php';
$parts = parse_url($url);
$exitCall = appdynamics_begin_exit_call(
AD_EXIT_HTTP,
'HTTP Status Service',
array('HOST' => $parts['host'],
'PORT' => (string)$parts['port'])
);
$corrHeader = $exitCall->getCorrelationHeader();
doSocketHTTPCall($url, $corrHeader);
appdynamics_end_exit_call($exitCall);
?>
The next example shows how to use a non-exclusive flag to start an exit call that may be
wrapping other exit calls. The outer socket-HTTP call is started, then the
file_get_contents()
call is processed by the agent normally, and finally,
the outer call is finished. We also pass the exception object to report any errors. The end
result is that both backends are displayed on the flowmap.
<?php
class SocketHTTPException extends Exception
{
}
$url = 'http://httpstat.us/200';
$javaTierURL = 'http://myhost.mydomain/process.jsp';
$parts = parse_url($url);
$exitCall = appdynamics_begin_exit_call(
AD_EXIT_HTTP,
'HTTP Status Service',
array('HOST' => $parts['host'],
'PORT' => (string)$parts['port']),
false
);
$contents = file_get_contents($javaTierURL);
if (doSocketHTTPCall($url) == null) {
$error = new SocketHTTPException("something bad happened");
}
appdynamics_end_exit_call($exitCall, $error);
?>