Skip to content

Commit

Permalink
fix(graphite): update indexed keys with names (#2701)
Browse files Browse the repository at this point in the history
  • Loading branch information
Kevin Lakotko authored and soulgalore committed Oct 14, 2019
1 parent 5397fce commit f803cde
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions lib/plugins/graphite/data-generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,44 @@ class GraphiteDataGenerator {
return reduce(
flatten.flattenMessageData(message),
(entries, value, key) => {
if (
this.options.graphite &&
this.options.graphite.experimental &&
this.options.graphite.experimental.perIteration
) {
if (message.type === 'browsertime.run') {
if (key.includes('timings') && key.includes('marks')) {
key = key.replace(/marks\.(\d+)/, function(match, idx) {
return (
'marks.' + message.data.timings.userTimings.marks[idx].name
);
});
}

if (key.includes('timings') && key.includes('measures')) {
key = key.replace(/measures\.(\d+)/, function(match, idx) {
return (
'measures.' +
message.data.timings.userTimings.measures[idx].name
);
});
}
}
if (message.type === 'pagexray.run') {
if (key.includes('assets')) {
key = key.replace(
/assets\.(\d+)/,
function(match, idx) {
let url = new URL(message.data.assets[idx].url);
url.search = '';
return 'assets.' + graphiteUtil.toSafeKey(url.toString());
},
{}
);
}
}
}

const fullKey = util.format('%s.%s.%s', this.namespace, keypath, key);
const args = [formatEntry(this.entryFormat), fullKey, value];
this.entryFormat === GRAPHITE && args.push(timestamp);
Expand Down

0 comments on commit f803cde

Please sign in to comment.