From a98177eab653cc0eacf78413337b87ed55ddfeb6 Mon Sep 17 00:00:00 2001 From: Artem Khaidarov Date: Tue, 19 Sep 2023 14:28:39 +0300 Subject: [PATCH] ci: new endpoint for perftool-send-report --- .github/workflows/performance-test-pr.yml | 1 + scripts/perftool-send-report.js | 30 ++++++++++++----------- 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/.github/workflows/performance-test-pr.yml b/.github/workflows/performance-test-pr.yml index 9706cf41aa..2f3a939f42 100644 --- a/.github/workflows/performance-test-pr.yml +++ b/.github/workflows/performance-test-pr.yml @@ -227,5 +227,6 @@ jobs: run: > ./scripts/perftool-send-report.js --reportPath /home/runner/work/plasma/plasma/perftest/comparison.json + --referrer https://github.com/${{ github.repository }}/pull/${{ github.event.number }} env: GITHUB_SHA: ${{ github.sha }} diff --git a/scripts/perftool-send-report.js b/scripts/perftool-send-report.js index b1fdfca27c..08f3bb6263 100755 --- a/scripts/perftool-send-report.js +++ b/scripts/perftool-send-report.js @@ -11,12 +11,12 @@ const getMetadata = (data) => { return JSON.stringify(result); }; -const METRICS_URL = 'https://metrics.prom.third-party-app.sberdevices.ru/create-canvas-app-metrics'; +const METRICS_URL = 'https://metrics.prom.third-party-app.sberdevices.ru/perftool'; -program.option('--reportPath ').parse(); +program.option('--reportPath ').option('--referrer ').parse(); async function perftoolSendReport() { - const { reportPath } = program.opts(); + const { reportPath, referrer } = program.opts(); // eslint-disable-next-line global-require, import/no-dynamic-require const { staticTaskChange, result, isVersionChanged } = require(reportPath); @@ -40,30 +40,32 @@ async function perftoolSendReport() { } const body = []; - const sessionId = crypto.randomUUID(); + const runId = crypto.randomUUID(); const commitHash = process.env.GITHUB_SHA; // e.g. subjectId = src/components/Carousel/Carousel.perftest.tsx#CarouselLiteBasic - for (const [subjectId, subject] of Object.entries(data)) { + for (const [componentId, subject] of Object.entries(data)) { // e.g. taskId = rerender | render for (const [taskId, task] of Object.entries(subject)) { const filteredMetrics = Object.entries(task).filter(([k]) => !k.startsWith('_')); // e.g. metricId = median | mean for (const [metricId, metric] of filteredMetrics) { - for (const typeId of ['old', 'new', 'change']) { + for (const kind of ['old', 'new', 'change']) { // change, old are optional - if (!metric[typeId]) { + if (!metric[kind]) { // eslint-disable-next-line no-continue continue; } const item = { - ua: 'perftest/packages/plasma', - hostname: commitHash, - sessionId, - path: subjectId, - key: `${taskId}_${metricId}`, - valueStr: typeId, - metadata: getMetadata(metric[typeId]), + commitHash, + runId, + componentId, + taskId, + metricId, + kind, + referrer, + service: 'perftest/packages/plasma', + payload: getMetadata(metric[kind]), }; body.push(item); }