Ember addon that will report boot time, transition times and errors to your api.
You will have to create this api yourself as this addon provides only client part and example schema.
For more info look into logger.js
and reporter.js
services inside addon folder.
ember install ember-cli-logger
Configuration is done through environment.js
file.
ENV.logger: {
isReportingEnabled: false,
isErrorHookEnabled: false,
isConsoleEnabled: false,
endpoint: null,
server: 'development',
},
When enabled addon will report events to your api.
When enabled addon will overwrite default event hook.
When enabled addon will log all events to console too.
Place to send events (for example: https://example/reporter
).
Your identification to know where the event come from.
This addon also modifies build pipeline to inject timer into index.html and polyfill. You can toggle these with flags in ember-cli-build.js
.
new EmberApp(defaults, {
measureBootTime: false,
isPerformancePolyfillEnabled: true,
});
If disabled index.html
file wont be affected in any way note that performance polyfill wont be also included.
If enabled polyfill for performance.now is included.
Every event contains tick
and instance
property.
- tick - used to number events one by one.
- instance - each application gets random instance number so you can track application flow.
After boot is completed event is created and reported(if enabled).
- start - time of performance.now() executed from index.html
- ready - time of performance.now() executed application ready hook
- finish - time of performance.now() executed from first didTransition hook
- browser - navigator.userAgent
- server - value specified from config
Each transition is logged and measured.
- time - delta time between willTransition and didTransition hooks
- name - name of the route
- params - parameters for route
When isErrorHookEnabled
errors are reported as well.
- message - message of the error
- stack - stack trace (although not very useful)
You can log custom events via logger
service: Logger.log(severity, message, time)
import Ember from 'ember';
const {computed, inject: {service}, K} = Ember;
Ember.Controller.extend({
logger: service(),
filteredModel: computed('model', {
get() {
const start = performance.now();
const filteredModel = model.filter(K);
this.get('logger').log('info', 'Delta time to filter model', performance.now() - start);
return filteredModel;
}
});
});
Sql tables may look like this.
CREATE TABLE `boot` (
`instance` int(11) NOT NULL,
`tick` int(11) NOT NULL,
`server` varchar(255) NOT NULL,
`start` float NOT NULL,
`ready` float NOT NULL,
`finish` float NOT NULL,
`browser` varchar(255) NOT NULL,
`timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `error` (
`instance` int(11) NOT NULL,
`tick` int(11) NOT NULL,
`message` text NOT NULL,
`stack` text NOT NULL,
`timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `transition` (
`instance` int(11) NOT NULL,
`tick` int(11) NOT NULL,
`name` varchar(255) NOT NULL,
`time` float NOT NULL,
`timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`params` varchar(255) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `log` (
`instance` int(11) NOT NULL,
`tick` int(11) NOT NULL,
`message` text NOT NULL,
`severity` varchar(255) NOT NULL,
`time` float NOT NULL,
`timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
ALTER TABLE `boot` ADD PRIMARY KEY (`instance`);
ALTER TABLE `error` ADD PRIMARY KEY (`tick`,`instance`);
ALTER TABLE `transition` ADD PRIMARY KEY (`tick`,`instance`);
ALTER TABLE `log` ADD PRIMARY KEY (`tick`,`instance`);