Home Brewing R.U.M - Analyzing application performance with real user monitoring
- 1. Home
Brewing
R.U.M
Image source: http://en.wikipedia.org/wiki/Samuel_Adams_%28beer%29#mediaviewer/File:Samadams.jpg
- 2. Making
developers
happy since eternity
Image source: http://en.wikipedia.org/wiki/List_of_rum_producers#mediaviewer/File:Rum_display_in_liquor_store.jpg
- 3. Real
User
Monitoring
What is
Image source: https://www.flickr.com/photos/madmask/421679860/in/gallery-zrav-72157623823227993/
- 4. Real User Monitoring
It is a technology for collecting performance
metrics directly from the browser of an end
user and sending it to a collection point for
analysis.
- 7. There’s
Money
in the metrics
Image source: https://www.flickr.com/photos/epsos/8463683689
- 13. Measuring Page Load Performance
1. Request (Link clicked)
2. Request reaches server
3. Server finishes execution
4. Browser Receives HTML
5. HTML processing finished
6. Page Rendered
Network Server DOM Processing Page Rendering
- 15. Cookies
Network = Time between beforeunload event and first byte received.
DOM Processing
Page Rendering
= Time between first byte received & DOMContentLoaded event.
= Time between DOMContentLoaded event & load event.
- 19. AJAX call performance
var xmlhttp = new XMLHttpRequest();
xmlhttp.open("GET","remoteResource.txt",true);
xmlhttp.send();
- 20. Measuring AJAX Call Performance
0 1 2 3 4
Unsent Opened Headers
Received
Loading Done
Ready State value
Time to first byte = Time between when send method is called and
when first time ready state value is 3 (Loading)
Downloading Time = Time between first time ready state value is 3
(Loading) and when it is 4 (Done)
- 22. Monkey Patching XMLHttpRequest
_XMLHttpRequest = window.XMLHttpRequest;
// Monkey Patched XMLHttpRequest Version
window.XMLHttpRequest = function() {
var req = new _XMLHttpRequest;
// Monkey Patched version of open() and send() methods
return req;
};
- 23. Monkey Patching XMLHttpRequest
_open = req.open;
req.open = function(type, url, async) {
req.addEventListener('readystatechange', function() {
// Log timing for every state change
}, false);
req.addEventListener('loadend', function(event) {
// Send all timing data to remote server
}, false);
return _open.apply(req, arguments);
};
- 26. HTML5 Performance Api
window.performance.getEntriesByType('resource')
Redirect
App
Cache
DNS TCP Request Response
- 27. Error
handling
Image source: http://en.wikipedia.org/wiki/Coccinellidae#mediaviewer/File:Coccinella_magnifica01.jpg
- 29. try catch block
Error Message
Line Number
File Name
Stack trace
Char number
Work for cross origin scripts
- 30. Wrapper for Reporting Error
function wrapper(fn) {
return function() {
try{
return fn.apply(this,arguments);
}catch(e) {
repportError(e);
throw e;
}
};
}
- 32. Challenges
in error tracking
Image source: https://www.flickr.com/photos/chrismatos/6784152671
- 33. Challenges in Error Tracking
● Different browsers provide different stack trace information.
● Steps to reproduce Error.
● Need to manually wrap each function.
- 34. Challenges in Error Tracking
Different browser provides different stack trace information.
Tracekit.js / Stacktrace.js are well tested libraries which abstract
this.
- 35. Challenges in Error Tracking
Steps to reproduce error.
Capture last X events in array like Input or click event and report
them back along with error information.
- 36. Challenges in Error Tracking
document.querySelector('input').addEventListener('change',
function(e){
// Adding it to the event array
});
- 37. Challenges in Error Tracking
Need to manually wrap each function.
Using instrumentation at build time or script serving time it can be
automated.
- 40. Abstract Syntax Tree
Number
var a = 1 ;
Equal Sign
Identifier
Keyword
Variable
Declaration
Identifier
Literal
Constant
- 43. Analysis
&
Visualization
Image source: http://monster-solutions.net/2014/07/03/elk-stack-logging-solutions-now-available/
- 45. Other
use cases
of R.U.M
Image source: http://monster-solutions.net/2014/07/03/elk-stack-logging-solutions-now-available/