Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// ReportSlaMetrics
// Reports metrics to compute the SLA
var os = require('os');
var http = require('http');
var promClient = require('prom-client');
var _options;
var pluginName = "prometheus-collector";
var register = promClient.register;
var Histogram = promClient.histogram;
var Counter = promClient.counter;
var Gauge = promClient.gauge;
//Define metrics
var apiCallCounter = new Counter('api_calls_counter', 'Number of API calls', [ 'code' ]);
var execTimeGauge = new Gauge('api_exec_time_ms_gauge', 'Execution time ms.', [ 'method', 'code' ]);
var statusHistogram = new Histogram('status_code_histogram', 'HTTP Response Histogram', [ 'code' ]);
var load1minGauge = new Gauge('load_average_1min_gauge', 'Load average in the last minute.', [ 'code' ]);
var load5minGauge = new Gauge('load_average_5min_gauge', 'Load average in the last 5 minutes.', [ 'code' ]);
var load15minGauge = new Gauge('load_average_15min_gauge', 'Load average in the last 15 minutes.', [ 'code' ]);
var usedMemoryBytesGauge = new Gauge('memory_used_bytes_gauge', 'Used memory in bytes.', [ 'code' ]);
var freeMemoryBytesGauge = new Gauge('memory_free_bytes_gauge', 'Used memory in bytes.', [ 'code' ]);
//Options for plugig are passed here as options
function configure(configuration, options) {
_options = options;