Wednesday, July 25th, 2007
End-to-End Tracing of Ajax/Java Applications Using DTrace
<p>We posted about using DTrace to profile Firefox in the past, and today Amit Hurvitz published a piece on Ajax, DTrace and Where They Meet.The article walks you through setting up dtrace on an an Ajax tracing example and then goes into detail on tracing Ajax and Java call flow where they are tracing the call flow of the JavaScript functions and the Java servlet methods, which responds to the Ajax calls using the script:
JAVASCRIPT:
-
-
#!/usr/sbin/dtrace -Zs
-
-
#pragma D option quiet
-
#pragma D option switchrate=10
-
-
dtrace:::BEGIN
-
{
-
jsIndent = 0;
-
jsFile = "ajax-validation";
-
javaMethodBoundary= "doGet";
-
startTimestamp = timestamp;
-
}
-
-
*mozilla$1:::js_function-entry
-
/basename(copyinstr(arg0)) == jsFile/
-
{
-
jsIndent += 2;
-
printf("%*s -> %s:%s (JavaScript)(elapsed ms: %d)n", jsIndent, "",
-
jsFile, copyinstr(arg2), (timestamp - startTimestamp) / 1000);
-
}
-
-
*mozilla$1:::js_function-return
-
/basename(copyinstr(arg0)) == jsFile/
-
{
-
printf("%*s <- %s:%s (JavaScript)(elapsed ms: %d)n", jsIndent, "",
-
jsFile, copyinstr(arg2), (timestamp - startTimestamp) / 1000);
-
jsIndent -= 2;
-
}
-
-
-
hotspot$2:::method-entry
-
{
-
self->strPtr = (char *)copyin(arg1, args[2]+1);
-
self->strPtr[(int)args[2]] = '