mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 17:28:26 -04:00
[ci-stats] Local metrics fixes (#113492)
* Rename `{ group: 'yarn start', id: 'started' }` to `{ group: 'scripts/kibana', id: 'dev server started' }` for consistency * Rename `{ group: '@kbn/optimizer' }` to `{ group: 'scripts/build_kibana_platform_plugins' }` for consistency * Include email for Elastic employees * Standardize on Unix paths * Set `subProcess: true` if the timing is already captured by a parent. * Move nestedTiming to global and use normalize-path
This commit is contained in:
parent
4b89e14884
commit
284732f058
7 changed files with 59 additions and 45 deletions
|
@ -289,8 +289,8 @@ export class CliDevMode {
|
|||
await reporter.timings({
|
||||
timings: [
|
||||
{
|
||||
group: 'yarn start',
|
||||
id: 'started',
|
||||
group: 'scripts/kibana',
|
||||
id: 'dev server started',
|
||||
ms: Date.now() - this.startTime!,
|
||||
meta: { success },
|
||||
},
|
||||
|
@ -313,7 +313,7 @@ export class CliDevMode {
|
|||
await reporter.timings({
|
||||
timings: [
|
||||
{
|
||||
group: 'yarn start',
|
||||
group: 'scripts/kibana',
|
||||
id: 'dev server restart',
|
||||
ms,
|
||||
meta: {
|
||||
|
|
|
@ -90,20 +90,24 @@ export class CiStatsReporter {
|
|||
this.log.debug(e.message);
|
||||
}
|
||||
|
||||
const isElasticCommitter = email && email.endsWith('@elastic.co') ? true : false;
|
||||
|
||||
const defaultMetadata = {
|
||||
osPlatform: Os.platform(),
|
||||
osRelease: Os.release(),
|
||||
osArch: Os.arch(),
|
||||
cpuCount: Os.cpus()?.length,
|
||||
cpuModel: Os.cpus()[0]?.model,
|
||||
cpuSpeed: Os.cpus()[0]?.speed,
|
||||
freeMem: Os.freemem(),
|
||||
totalMem: Os.totalmem(),
|
||||
committerHash: email
|
||||
? crypto.createHash('sha256').update(email).digest('hex').substring(0, 20)
|
||||
: undefined,
|
||||
isElasticCommitter: email ? email.endsWith('@elastic.co') : undefined,
|
||||
cpuCount: Os.cpus()?.length,
|
||||
cpuModel: Os.cpus()[0]?.model,
|
||||
cpuSpeed: Os.cpus()[0]?.speed,
|
||||
email: isElasticCommitter ? email : undefined,
|
||||
freeMem: Os.freemem(),
|
||||
isElasticCommitter,
|
||||
kibanaUuid,
|
||||
nestedTiming: process.env.CI_STATS_NESTED_TIMING ? true : false,
|
||||
osArch: Os.arch(),
|
||||
osPlatform: Os.platform(),
|
||||
osRelease: Os.release(),
|
||||
totalMem: Os.totalmem(),
|
||||
};
|
||||
|
||||
this.log.debug('CIStatsReporter committerHash: %s', defaultMetadata.committerHash);
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
|
||||
import path from 'path';
|
||||
import { REPO_ROOT } from '@kbn/utils';
|
||||
import normalizePath from 'normalize-path';
|
||||
import { CiStatsReporter } from '../ci_stats_reporter';
|
||||
import { ToolingLog } from '../tooling_log';
|
||||
|
||||
|
@ -23,39 +24,39 @@ export class Metrics {
|
|||
this.reporter = CiStatsReporter.fromEnv(log);
|
||||
this.meta = new Map();
|
||||
this.startTime = Date.now();
|
||||
this.filePath = path.relative(REPO_ROOT, process.argv[1]).replace('.js', '');
|
||||
|
||||
// standardize to unix path
|
||||
this.filePath = normalizePath(path.relative(REPO_ROOT, process.argv[1]).replace('.js', ''));
|
||||
}
|
||||
|
||||
createTiming(meta: object, command?: string) {
|
||||
return {
|
||||
group: `${command ? `${this.filePath} ${command}` : this.filePath}`,
|
||||
id: 'total',
|
||||
ms: Date.now() - this.startTime,
|
||||
meta: {
|
||||
nestedTiming: process.env.CI_STATS_NESTED_TIMING,
|
||||
...Object.fromEntries(this.meta),
|
||||
...meta,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
async reportCancelled(command?: string) {
|
||||
return await this.reporter.timings({
|
||||
timings: [this.createTiming({ cancelled: true }, command)],
|
||||
});
|
||||
}
|
||||
|
||||
async reportSuccess(command?: string) {
|
||||
return await this.reporter.timings({
|
||||
timings: [
|
||||
{
|
||||
group: `${command ? `${this.filePath} ${command}` : this.filePath}`,
|
||||
id: 'total',
|
||||
ms: Date.now() - this.startTime,
|
||||
meta: {
|
||||
success: true,
|
||||
...Object.fromEntries(this.meta),
|
||||
},
|
||||
},
|
||||
],
|
||||
timings: [this.createTiming({ success: true }, command)],
|
||||
});
|
||||
}
|
||||
|
||||
async reportError(errorMessage?: string, command?: string) {
|
||||
return await this.reporter.timings({
|
||||
timings: [
|
||||
{
|
||||
group: `${command ? `${this.filePath} ${command}` : this.filePath}`,
|
||||
id: 'total',
|
||||
ms: Date.now() - this.startTime,
|
||||
meta: {
|
||||
success: false,
|
||||
errorMessage,
|
||||
...Object.fromEntries(this.meta),
|
||||
},
|
||||
},
|
||||
],
|
||||
timings: [this.createTiming({ success: false, errorMessage }, command)],
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -46,7 +46,7 @@ export function reportOptimizerTimings(log: ToolingLog, config: OptimizerConfig)
|
|||
await reporter.timings({
|
||||
timings: [
|
||||
{
|
||||
group: '@kbn/optimizer',
|
||||
group: 'scripts/build_kibana_platform_plugins',
|
||||
id: 'total',
|
||||
ms: time,
|
||||
meta: {
|
||||
|
|
18
packages/kbn-pm/dist/index.js
vendored
18
packages/kbn-pm/dist/index.js
vendored
|
@ -9024,18 +9024,21 @@ class CiStatsReporter {
|
|||
this.log.debug(e.message);
|
||||
}
|
||||
|
||||
const isElasticCommitter = email && email.endsWith('@elastic.co') ? true : false;
|
||||
const defaultMetadata = {
|
||||
osPlatform: _os.default.platform(),
|
||||
osRelease: _os.default.release(),
|
||||
osArch: _os.default.arch(),
|
||||
committerHash: email ? _crypto.default.createHash('sha256').update(email).digest('hex').substring(0, 20) : undefined,
|
||||
cpuCount: (_Os$cpus = _os.default.cpus()) === null || _Os$cpus === void 0 ? void 0 : _Os$cpus.length,
|
||||
cpuModel: (_Os$cpus$ = _os.default.cpus()[0]) === null || _Os$cpus$ === void 0 ? void 0 : _Os$cpus$.model,
|
||||
cpuSpeed: (_Os$cpus$2 = _os.default.cpus()[0]) === null || _Os$cpus$2 === void 0 ? void 0 : _Os$cpus$2.speed,
|
||||
email: isElasticCommitter ? email : undefined,
|
||||
freeMem: _os.default.freemem(),
|
||||
totalMem: _os.default.totalmem(),
|
||||
committerHash: email ? _crypto.default.createHash('sha256').update(email).digest('hex').substring(0, 20) : undefined,
|
||||
isElasticCommitter: email ? email.endsWith('@elastic.co') : undefined,
|
||||
kibanaUuid
|
||||
isElasticCommitter,
|
||||
kibanaUuid,
|
||||
nestedTiming: process.env.CI_STATS_NESTED_TIMING ? true : false,
|
||||
osArch: _os.default.arch(),
|
||||
osPlatform: _os.default.platform(),
|
||||
osRelease: _os.default.release(),
|
||||
totalMem: _os.default.totalmem()
|
||||
};
|
||||
this.log.debug('CIStatsReporter committerHash: %s', defaultMetadata.committerHash);
|
||||
return await this.req({
|
||||
|
@ -60653,6 +60656,7 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
|
|||
|
||||
|
||||
|
||||
process.env.CI_STATS_NESTED_TIMING = 'true';
|
||||
async function runCommand(command, config) {
|
||||
const runStartTime = Date.now();
|
||||
let kbn;
|
||||
|
|
|
@ -145,7 +145,10 @@ export const BootstrapCommand: ICommand = {
|
|||
upstreamBranch: kbn.kibanaProject.json.branch,
|
||||
// prevent loading @kbn/utils by passing null
|
||||
kibanaUuid: kbn.getUuid() || null,
|
||||
timings: timings.map((t) => ({ group: 'scripts/kbn bootstrap', ...t })),
|
||||
timings: timings.map((t) => ({
|
||||
group: 'scripts/kbn bootstrap',
|
||||
...t,
|
||||
})),
|
||||
});
|
||||
},
|
||||
};
|
||||
|
|
|
@ -15,6 +15,8 @@ import { buildProjectGraph } from './utils/projects';
|
|||
import { renderProjectsTree } from './utils/projects_tree';
|
||||
import { Kibana } from './utils/kibana';
|
||||
|
||||
process.env.CI_STATS_NESTED_TIMING = 'true';
|
||||
|
||||
export async function runCommand(command: ICommand, config: Omit<ICommandConfig, 'kbn'>) {
|
||||
const runStartTime = Date.now();
|
||||
let kbn;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue