parent
c53ad53c30
commit
6a0889bd26
|
|
@ -6,7 +6,6 @@ import { readFileSync, statSync } from 'node:fs';
|
|||
import yargs from 'yargs';
|
||||
import { hideBin } from 'yargs/helpers';
|
||||
import merge from 'lodash.merge';
|
||||
import reduce from 'lodash.reduce';
|
||||
import set from 'lodash.set';
|
||||
import get from 'lodash.get';
|
||||
|
||||
|
|
@ -2136,14 +2135,10 @@ export async function parseCommandLine() {
|
|||
argv = parsed.argv;
|
||||
|
||||
// aliases are long options -> short option
|
||||
const aliasLookup = reduce(
|
||||
aliases,
|
||||
(lookup, value, key) => {
|
||||
lookup.set(value[0], key);
|
||||
return lookup;
|
||||
},
|
||||
new Map()
|
||||
);
|
||||
const aliasLookup = new Map();
|
||||
for (const [key, value] of Object.entries(aliases)) {
|
||||
aliasLookup.set(value[0], key);
|
||||
}
|
||||
|
||||
let explicitOptions = yargs(hideBin(process.argv)).argv;
|
||||
|
||||
|
|
@ -2152,9 +2147,8 @@ export async function parseCommandLine() {
|
|||
yargsInstance.getOptions().configObjects[0]
|
||||
);
|
||||
|
||||
explicitOptions = reduce(
|
||||
explicitOptions,
|
||||
(result, value, key) => {
|
||||
explicitOptions = Object.entries(explicitOptions).reduce(
|
||||
(result, [key, value]) => {
|
||||
if (aliasLookup.has(key)) {
|
||||
const fullKey = aliasLookup.get(key);
|
||||
result = set(result, fullKey, value);
|
||||
|
|
|
|||
|
|
@ -2,10 +2,8 @@ import { parse } from 'node:url';
|
|||
|
||||
import { Stats } from 'fast-stats';
|
||||
import { getLogger } from '@sitespeed.io/log';
|
||||
import reduce from 'lodash.reduce';
|
||||
|
||||
import { summarizeStats } from '../../support/statsHelpers.js';
|
||||
import { isEmpty } from '../../support/util.js';
|
||||
|
||||
const log = getLogger('sitespeedio.plugin.domains');
|
||||
|
||||
|
|
@ -39,22 +37,22 @@ function getDomain(domainName) {
|
|||
}
|
||||
|
||||
function calc(domains) {
|
||||
return reduce(
|
||||
domains,
|
||||
(summary, domainStats, domainName) => {
|
||||
return Object.entries(domains).reduce(
|
||||
(summary, [domainName, domainStats]) => {
|
||||
const domainSummary = {
|
||||
requestCount: domainStats.requestCount,
|
||||
domainName
|
||||
};
|
||||
|
||||
const stats = summarizeStats(domainStats.totalTime);
|
||||
if (!isEmpty(stats)) {
|
||||
if (stats && Object.keys(stats).length > 0) {
|
||||
domainSummary.totalTime = stats;
|
||||
}
|
||||
|
||||
for (const name of timingNames) {
|
||||
const stats = summarizeStats(domainStats[name]);
|
||||
if (!isEmpty(stats)) {
|
||||
domainSummary[name] = stats;
|
||||
const stat = summarizeStats(domainStats[name]);
|
||||
if (stat && Object.keys(stat).length > 0) {
|
||||
domainSummary[name] = stat;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
// eslint-disable-next-line unicorn/import-style
|
||||
import util, { format } from 'node:util';
|
||||
import reduce from 'lodash.reduce';
|
||||
import {
|
||||
getConnectivity,
|
||||
toSafeKey,
|
||||
|
|
@ -65,7 +64,7 @@ export class GraphiteDataGenerator {
|
|||
}
|
||||
|
||||
dataFromMessage(message, time, alias) {
|
||||
let timestamp = Math.round(time.valueOf() / 1000);
|
||||
const timestamp = Math.round(time.valueOf() / 1000);
|
||||
|
||||
const keypath = keyPathFromMessage(
|
||||
message,
|
||||
|
|
@ -74,12 +73,11 @@ export class GraphiteDataGenerator {
|
|||
alias
|
||||
);
|
||||
|
||||
return reduce(
|
||||
flattenMessageData(message),
|
||||
(entries, value, key) => {
|
||||
return Object.entries(flattenMessageData(message)).reduce(
|
||||
(entries, [key, value]) => {
|
||||
if (message.type === 'browsertime.run') {
|
||||
if (key.includes('timings') && key.includes('marks')) {
|
||||
key = key.replace(/marks\.(\d+)/, function (match, index) {
|
||||
key = key.replace(/marks\.(\d+)/, (match, index) => {
|
||||
return (
|
||||
'marks.' + message.data.timings.userTimings.marks[index].name
|
||||
);
|
||||
|
|
@ -87,7 +85,7 @@ export class GraphiteDataGenerator {
|
|||
}
|
||||
|
||||
if (key.includes('timings') && key.includes('measures')) {
|
||||
key = key.replace(/measures\.(\d+)/, function (match, index) {
|
||||
key = key.replace(/measures\.(\d+)/, (match, index) => {
|
||||
return (
|
||||
'measures.' +
|
||||
message.data.timings.userTimings.measures[index].name
|
||||
|
|
@ -96,20 +94,18 @@ export class GraphiteDataGenerator {
|
|||
}
|
||||
}
|
||||
if (message.type === 'pagexray.run' && key.includes('assets')) {
|
||||
key = key.replace(
|
||||
/assets\.(\d+)/,
|
||||
function (match, index) {
|
||||
let url = new URL(message.data.assets[index].url);
|
||||
url.search = '';
|
||||
return 'assets.' + toSafeKey(url.toString());
|
||||
},
|
||||
{}
|
||||
);
|
||||
key = key.replace(/assets\.(\d+)/, (match, index) => {
|
||||
const url = new URL(message.data.assets[index].url);
|
||||
url.search = '';
|
||||
return 'assets.' + toSafeKey(url.toString());
|
||||
});
|
||||
}
|
||||
|
||||
const fullKey = format('%s.%s.%s', this.namespace, keypath, key);
|
||||
const arguments_ = [formatEntry(this.entryFormat), fullKey, value];
|
||||
this.entryFormat === GRAPHITE && arguments_.push(timestamp);
|
||||
if (this.entryFormat === GRAPHITE) {
|
||||
arguments_.push(timestamp);
|
||||
}
|
||||
|
||||
entries.push(format.apply(util, arguments_));
|
||||
return entries;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
import merge from 'lodash.merge';
|
||||
import get from 'lodash.get';
|
||||
import reduce from 'lodash.reduce';
|
||||
import set from 'lodash.set';
|
||||
|
||||
export class DataCollector {
|
||||
|
|
@ -51,9 +50,8 @@ export class DataCollector {
|
|||
}
|
||||
|
||||
getWorkingUrls() {
|
||||
return reduce(
|
||||
this.urlPages,
|
||||
(validPages, urlInfo, url) => {
|
||||
return Object.entries(this.urlPages).reduce(
|
||||
(validPages, [url, urlInfo]) => {
|
||||
if (Object.keys(urlInfo.data).length > 0) {
|
||||
validPages[url] = urlInfo;
|
||||
}
|
||||
|
|
@ -64,16 +62,12 @@ export class DataCollector {
|
|||
}
|
||||
|
||||
getErrorUrls() {
|
||||
return reduce(
|
||||
this.urlPages,
|
||||
(errors, urlInfo, url) => {
|
||||
if (urlInfo.errors) {
|
||||
errors[url] = urlInfo.errors;
|
||||
}
|
||||
return errors;
|
||||
},
|
||||
{}
|
||||
);
|
||||
return Object.entries(this.urlPages).reduce((errors, [url, urlInfo]) => {
|
||||
if (urlInfo.errors) {
|
||||
errors[url] = urlInfo.errors;
|
||||
}
|
||||
return errors;
|
||||
}, {});
|
||||
}
|
||||
|
||||
getErrors() {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
import get from 'lodash.get';
|
||||
import set from 'lodash.set';
|
||||
import reduce from 'lodash.reduce';
|
||||
import { SitespeedioPlugin } from '@sitespeed.io/plugin';
|
||||
import { DataCollector } from './dataCollector.js';
|
||||
import { HTMLBuilder } from './htmlBuilder.js';
|
||||
|
|
@ -115,8 +114,7 @@ export default class HTMLPlugin extends SitespeedioPlugin {
|
|||
|
||||
case 'aggregateassets.summary': {
|
||||
if (message.group === 'total') {
|
||||
const assetList = reduce(
|
||||
message.data,
|
||||
const assetList = Object.values(message.data).reduce(
|
||||
(assetList, asset) => {
|
||||
assetList.push(asset);
|
||||
return assetList;
|
||||
|
|
@ -179,8 +177,7 @@ export default class HTMLPlugin extends SitespeedioPlugin {
|
|||
|
||||
case 'domains.summary': {
|
||||
if (message.group === 'total') {
|
||||
const domainList = reduce(
|
||||
message.data,
|
||||
const domainList = Object.values(message.data).reduce(
|
||||
(domainList, domainStats) => {
|
||||
domainList.push(domainStats);
|
||||
return domainList;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
import merge from 'lodash.merge';
|
||||
import reduce from 'lodash.reduce';
|
||||
|
||||
import { flattenMessageData } from '../../support/flattenMessage.js';
|
||||
import {
|
||||
|
|
@ -236,9 +235,8 @@ export class InfluxDBDataGenerator {
|
|||
|
||||
return tags;
|
||||
}
|
||||
return reduce(
|
||||
flattenMessageData(message),
|
||||
(entries, value, key) => {
|
||||
return Object.entries(flattenMessageData(message)).reduce(
|
||||
(entries, [key, value]) => {
|
||||
const fieldAndSeriesName = getFieldAndSeriesName(key);
|
||||
let tags = getTagsFromMessage(
|
||||
message,
|
||||
|
|
@ -246,11 +244,11 @@ export class InfluxDBDataGenerator {
|
|||
this.options,
|
||||
this.defaultTags
|
||||
);
|
||||
tags = merge(getAdditionalTags(key, message.type), tags);
|
||||
let point = {
|
||||
time: time.valueOf()
|
||||
tags = { ...getAdditionalTags(key, message.type), ...tags };
|
||||
const point = {
|
||||
time: time.valueOf(),
|
||||
[fieldAndSeriesName.field]: value
|
||||
};
|
||||
point[fieldAndSeriesName.field] = value;
|
||||
entries.push({
|
||||
tags,
|
||||
seriesName: fieldAndSeriesName.seriesName,
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
import get from 'lodash.get';
|
||||
import set from 'lodash.set';
|
||||
import merge from 'lodash.merge';
|
||||
import reduce from 'lodash.reduce';
|
||||
|
||||
import { toArray, isEmpty } from './util.js';
|
||||
|
||||
|
|
@ -30,20 +29,15 @@ export function filterMetrics(json, metricPaths) {
|
|||
} else if (firstWildcard === 0) {
|
||||
const leafPath = path.slice(2);
|
||||
|
||||
reduce(
|
||||
json,
|
||||
(result, value, key) => {
|
||||
if (typeof value === 'object') {
|
||||
const leaf = this.filterMetrics(value, leafPath);
|
||||
|
||||
if (!isEmpty(leaf)) {
|
||||
result[key] = leaf;
|
||||
}
|
||||
Object.entries(json).reduce((result, [key, value]) => {
|
||||
if (typeof value === 'object') {
|
||||
const leaf = this.filterMetrics(value, leafPath);
|
||||
if (leaf && Object.keys(leaf).length > 0) {
|
||||
result[key] = leaf;
|
||||
}
|
||||
return result;
|
||||
},
|
||||
result
|
||||
);
|
||||
}
|
||||
return result;
|
||||
}, result);
|
||||
} else {
|
||||
let branchPath = path.slice(0, Math.max(0, firstWildcard));
|
||||
if (branchPath.endsWith('.')) branchPath = branchPath.slice(0, -1);
|
||||
|
|
|
|||
|
|
@ -28,7 +28,6 @@
|
|||
"junit-report-builder": "3.2.1",
|
||||
"lodash.get": "4.4.2",
|
||||
"lodash.merge": "4.6.2",
|
||||
"lodash.reduce": "4.6.0",
|
||||
"lodash.set": "4.3.2",
|
||||
"markdown": "0.5.0",
|
||||
"node-scp": "0.0.23",
|
||||
|
|
@ -7018,11 +7017,6 @@
|
|||
"resolved": "https://registry.npmjs.org/lodash.merge/-/lodash.merge-4.6.2.tgz",
|
||||
"integrity": "sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ=="
|
||||
},
|
||||
"node_modules/lodash.reduce": {
|
||||
"version": "4.6.0",
|
||||
"resolved": "https://registry.npmjs.org/lodash.reduce/-/lodash.reduce-4.6.0.tgz",
|
||||
"integrity": "sha1-8atrg5KZrUj3hKu/R2WW8DuRTTs="
|
||||
},
|
||||
"node_modules/lodash.set": {
|
||||
"version": "4.3.2",
|
||||
"resolved": "https://registry.npmjs.org/lodash.set/-/lodash.set-4.3.2.tgz",
|
||||
|
|
|
|||
|
|
@ -99,7 +99,6 @@
|
|||
"junit-report-builder": "3.2.1",
|
||||
"lodash.get": "4.4.2",
|
||||
"lodash.merge": "4.6.2",
|
||||
"lodash.reduce": "4.6.0",
|
||||
"lodash.set": "4.3.2",
|
||||
"markdown": "0.5.0",
|
||||
"node-scp": "0.0.23",
|
||||
|
|
|
|||
Loading…
Reference in New Issue