Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
static setup(jobName) {
const defaultMetrics = Prometheus.defaultMetrics;
// Skip `osMemoryHeap` probe, and probe every 5th second.
const defaultInterval = defaultMetrics(['osMemoryHeap'], 10000);
process.on('exit', () => { clearInterval(defaultInterval); });
if (Context.hasConfig('metrics.gateway') &&
Context.hasConfig('metrics.gateway.active') &&
Context.getConfig('metrics.gateway.active')
) {
const gateway = new Prometheus.Pushgateway(Object.assign(Context.getConfig('metrics.gateway.hostport'), { timeout: 2000 }));
const tags = {
jobName
};
const interval = setInterval(() => {
gateway.pushAdd(tags, (err) => {
if (err) {
static setup(appName: string, context: Context) {
const defaultMetrics = prometheus.defaultMetrics;
// Skip `osMemoryHeap` probe, and probe every 5th second.
const defaultInterval = defaultMetrics(['osMemoryHeap'], 10000);
process.on('exit', () => { clearInterval(defaultInterval); });
if (context.hasConfig('metrics.gateway') &&
context.hasConfig('metrics.gateway.active') &&
context.getConfig('metrics.gateway.active')
) {
const gateway = new prometheus.Pushgateway(context.getConfig('metrics.gateway.hostport'));
const tags = {
jobName: 'msPush',
appName,
};
const interval = setInterval(() => {
gateway.pushAdd(tags, (err) => {