mirror of
https://github.com/compiler-explorer/compiler-explorer.git
synced 2026-12-01 23:49:22 -06:00
Get statistics on tools usage per language / compiler (#3851)
This commit is contained in:
@@ -24,12 +24,15 @@
|
||||
|
||||
import path from 'path';
|
||||
|
||||
import PromClient from 'prom-client';
|
||||
import _ from 'underscore';
|
||||
|
||||
import * as exec from '../exec';
|
||||
import {logger} from '../logger';
|
||||
import * as utils from '../utils';
|
||||
|
||||
const countersPerTool = {};
|
||||
|
||||
export class BaseTool {
|
||||
constructor(toolInfo, env) {
|
||||
this.tool = toolInfo;
|
||||
@@ -37,6 +40,15 @@ export class BaseTool {
|
||||
this.tool.exclude = this.tool.exclude ? this.tool.exclude.split(':') : [];
|
||||
this.addOptionsToToolArgs = true;
|
||||
this.parseOutput = utils.parseOutput;
|
||||
|
||||
const toolName = this.tool.name;
|
||||
if (toolName && !(toolName in countersPerTool)) {
|
||||
countersPerTool[toolName] = new PromClient.Counter({
|
||||
name: `${toolName.replaceAll(/\W/g, '_').toLowerCase()}_compilation_total`,
|
||||
help: `Number of compilations with ${toolName} active`,
|
||||
labelNames: ['language', 'compiler'],
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
getId() {
|
||||
@@ -121,6 +133,12 @@ export class BaseTool {
|
||||
}
|
||||
|
||||
async runTool(compilationInfo, inputFilepath, args, stdin /*, supportedLibraries*/) {
|
||||
if (this.tool.name) {
|
||||
countersPerTool[this.tool.name].inc({
|
||||
language: compilationInfo.compiler.lang,
|
||||
compiler: compilationInfo.compiler.name,
|
||||
});
|
||||
}
|
||||
let execOptions = this.getDefaultExecOptions();
|
||||
if (inputFilepath) execOptions.customCwd = path.dirname(inputFilepath);
|
||||
execOptions.input = stdin;
|
||||
|
||||
Reference in New Issue
Block a user