diff --git a/lib/plugins/graphite/data-generator.js b/lib/plugins/graphite/data-generator.js index c1431576e..2964e3ee2 100644 --- a/lib/plugins/graphite/data-generator.js +++ b/lib/plugins/graphite/data-generator.js @@ -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)); diff --git a/lib/plugins/webpagetest/aggregator.js b/lib/plugins/webpagetest/aggregator.js index 278db7ff7..842cca456 100644 --- a/lib/plugins/webpagetest/aggregator.js +++ b/lib/plugins/webpagetest/aggregator.js @@ -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) => { diff --git a/lib/plugins/webpagetest/index.js b/lib/plugins/webpagetest/index.js index 8ce7ac0e1..39f6d5a71 100644 --- a/lib/plugins/webpagetest/index.js +++ b/lib/plugins/webpagetest/index.js @@ -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})); } } } diff --git a/test/graphiteTests.js b/test/graphiteTests.js index 887be7a1d..2979f2093 100644 --- a/test/graphiteTests.js +++ b/test/graphiteTests.js @@ -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/); });