Use location and connectivity in WPT graphite keys and browser/connectivity for BT (#1010)

* use location and connectivity in keys #1008

* only use browser and connectivity for BT #1009 and set the right one for WPT #1008
This commit is contained in:
Peter Hedenskog 2016-06-19 20:39:21 +02:00 committed by GitHub
parent 3de4db6989
commit eda4f7a1ec
4 changed files with 24 additions and 12 deletions

View File

@ -20,8 +20,18 @@ class GraphiteDataGenerator {
let typeParts = message.type.split('.');
typeParts.push(typeParts.shift());
typeParts.splice(1, 0, options.connectivity);
typeParts.splice(1, 0, options.browser);
// always have browser and connectivity in Browsertime and related tools
if (message.type.match(/(^pagexray|^coach|^browsertime|^assets|^domains)/)) {
typeParts.splice(1, 0, options.connectivity);
typeParts.splice(1, 0, options.browser);
} else if (message.type.match(/(^webpagetest)/)) {
if (message.connectivity) {
typeParts.splice(2, 0, message.connectivity);
}
if (message.location) {
typeParts.splice(2, 0, message.location);
}
}
if (message.url) {
typeParts.splice(1, 0, flatten.keypathFromUrl(message.url, includeQueryParams));

View File

@ -8,12 +8,13 @@ const metrics = ['TTFB', 'render', 'fullyLoaded', 'SpeedIndex'];
module.exports = {
timingStats: {},
assetStats: {},
// TODO we also need browser, location and connectivity
connectivity: undefined,
location: undefined,
addToAggregate(wptData, connectivity, location) {
// TODO this will break if we run multiple locations/connectivity per run
this.location = location;
this.connectivity = connectivity;
// "location": "Dulles:Chrome",
// "connectivity": "Cable",
addToAggregate(wptData) {
forEach(wptData.data.runs, (run) => {
forEach(run, (viewData, viewName) => {

View File

@ -54,9 +54,10 @@ module.exports = {
runIndex: (parseInt(runKey) - 1)
}))
);
queue.postMessage(make('webpagetest.pageSummary', result, {url}));
aggregator.addToAggregate(result);
const location = result.data.location.replace(':', '-').replace(' ', '-').toLowerCase();
const connectivity = result.data.connectivity.toLowerCase();
queue.postMessage(make('webpagetest.pageSummary', result, {url, location, connectivity}));
aggregator.addToAggregate(result, connectivity, location);
})
.catch((err) => {
queue.postMessage(make('error', err, {url}));
@ -67,7 +68,7 @@ module.exports = {
{
let summary = aggregator.summarize();
if (summary && Object.keys(summary).length > 0) {
queue.postMessage(make('webpagetest.summary', summary));
queue.postMessage(make('webpagetest.summary', summary, {connectivity: aggregator.connectivity, location: aggregator.location}));
}
}
}

View File

@ -29,7 +29,7 @@ describe('graphite', function() {
var data = generator.dataFromMessage(message, moment());
expect(data).to.match(/ns.pageSummary.sub_domain_com/);
expect(data).to.match(/bar.chrome.cable.gpsi.median/);
expect(data).to.match(/bar.gpsi.median/);
expect(data).to.match(/foo_bar/);
});