mirror of
https://github.com/grafana/grafana.git
synced 2024-11-29 20:24:18 -06:00
0124dc8e6b
* reintroduce type assertion test + change emitted metric names * rename test to better eslint to be more generic
35 lines
1.0 KiB
TypeScript
35 lines
1.0 KiB
TypeScript
import { betterer } from '@betterer/betterer';
|
|
import { camelCase } from 'lodash';
|
|
|
|
function logStat(name: string, value: number) {
|
|
// Note that this output format must match the parsing in ci-frontend-metrics.sh
|
|
// which expects the two values to be separated by a space
|
|
console.log(`${name} ${value}`);
|
|
}
|
|
|
|
async function main() {
|
|
const results = await betterer.results();
|
|
|
|
for (const testResults of results.resultSummaries) {
|
|
const countByMessage = {};
|
|
const name = camelCase(testResults.name);
|
|
Object.values(testResults.details)
|
|
.flatMap((v) => v)
|
|
.forEach((detail) => {
|
|
const message = camelCase(detail.message);
|
|
const metricName = `${name}_${message}`;
|
|
if (metricName in countByMessage) {
|
|
countByMessage[metricName]++;
|
|
} else {
|
|
countByMessage[metricName] = 1;
|
|
}
|
|
});
|
|
|
|
for (const [metricName, count] of Object.entries<number>(countByMessage)) {
|
|
logStat(metricName, count);
|
|
}
|
|
}
|
|
}
|
|
|
|
main().catch(console.error);
|