Download PDF
Download page Ajax Requests Not Monitored.
Ajax Requests Not Monitored
You may find that some Ajax requests have not been monitored as expected. The page may help you determine why these pages have not been monitored.
Check Exclude Rules
It the agent has been injected, the Ajax event may have been excluded from monitoring by custom exclude rules. You can check and modify these rules.
To access custom exclude rules for pages:
Click Configuration > Instrumentation.
From the AJAX tab, check the custom rules under the Exclude Rules section.
- To examine and/or modify a custom exclude rule select it in the list and click the
icon:
- If you want to remove a custom exclude rule, select and click Delete.
Verify That XHR Objects Were Reused Correctly
Browser RUM can monitor multiple Ajax calls made from a reused XMLHttpRequest
object, but if the XMLHttpRequest
object is reused (opened) before the last request is completed, the JavaScript agent cannot collect all the metrics for all the Ajax requests.
Incorrect Method to Reuse XMLHttpRequest Object
In the example below, the xhr
object is making a request to /multi-bt
before the request to /xhr/uptime
has completed, so the JavaScript Agent only reports the second Ajax request to /multi-bt
.
function reuseXHRBeforeReady() {
var xhr = newXhr();
xhr.open("GET", "/xhr/uptime");
xhr.onreadystatechange = safe(function() {
if (xhr.readyState == 4) {
if (typeof(console) !== "undefined" && console !== null && console.log)
console.log("onreadystatechange for xh1: " + xhr.responseText);
document.getElementById("result").innerHTML = xhr.responseText;
}
});
xhr.send(null);
xhr.open("GET", "/multi-bt");
xhr.onreadystatechange = safe(function() {
if (xhr.readyState == 4) {
if (typeof(console) !== "undefined" && console !== null && console.log)
console.log("onreadystatechange for xhr2: " + xhr.responseText);
document.getElementById("result").innerHTML = xhr.responseText;
}
});
xhr.send(null);
}
When an Ajax request cannot be reported because the XMLHttpRequest
object is reused (opened) before the last request is completed, the JavaScript Agent logs that an Ajax request was not reported in a message similar to the one below. You will most likely have to modify your JavaScript so that new Ajax requests are only made after previous requests are completed.
EXT~ The reused XHR object calls open() before finishes last job. No event of XHR to '" + this._adrumAjaxT.url() + "' is reported.
Correct Method to Reuse XMLHttpRequest Object
The correct method to reuse the XMLHttpRequest
object to make more than one request is to nest the calls so that new calls are only made when previous calls have been completed. In the example below, the call to /xhr/multi-bt2
is only made when the call to /multi-bt
has completed, so both calls are reported as Ajax requests.
function reuseXHR() {
var xhr = newXhr();
xhr.open("GET", "/xhr/uptime");
xhr.onreadystatechange = safe(function() {
if (xhr.readyState == 4) {
document.getElementById("result").innerHTML = xhr.responseText;
xhr.open("GET", "/multi-bt");
xhr.onreadystatechange = safe(function() {
if (xhr.readyState == 4) {
if (typeof(console) !== "undefined" && console !== null && console.log)
console.log("onreadystatechange for xhr2: " + xhr.responseText);
document.getElementById("result").innerHTML = xhr.responseText;
// Reuse xhr again
xhr.open("GET", "/xhr/multi-bt2");
xhr.onreadystatechange = safe(function() {
console.log("/xhr/multi-bt2 responded.");
});
xhr.send(null);
}
});
xhr.send(null);
}
});
xhr.send(null);
}
Check Injection Configuration
In addition, certain Ajax requests could have been filtered out by the injection configuration. This can happen when the injection uses XHR filters to limit which Ajax requests are monitored. Check your injection configuration to verify that the filtering did not prevent the calls from being monitored.