packages/teraslice/lib/utils/api_utils.js
function makePrometheus(stats, defaultLabels = {}) {
    const metricMapping = {
        processed: 'teraslice_slices_processed',
        failed: 'teraslice_slices_failed',
        queued: 'teraslice_slices_queued',
        job_duration: '', // this isn't really useful, omitting
        workers_joined: 'teraslice_workers_joined',
        workers_disconnected: 'teraslice_workers_disconnected',
        workers_reconnected: 'teraslice_workers_reconnected'
    };

    let returnString = '';
    _.forEach(stats.controllers, (value, key) => {
        const name = metricMapping[key];
        if (name !== '') {
            returnString += `# TYPE ${name} counter\n`;
            const labels = makePrometheusLabels(defaultLabels);
            returnString += `${name}${labels} ${value}\n`;
        }
    });
    return returnString;
}
function makePrometheus(stats, defaultLabels = {}) {
    const metricMapping = {
        processed: 'teraslice_slices_processed',
        failed: 'teraslice_slices_failed',
        queued: 'teraslice_slices_queued',
        job_duration: '', // this isn't really useful, omitting
        workers_joined: 'teraslice_workers_joined',
        workers_disconnected: 'teraslice_workers_disconnected',
        workers_reconnected: 'teraslice_workers_reconnected'
    };

    let returnString = '';
    _.forEach(stats.controllers, (value, key) => {
        const name = metricMapping[key];
        if (name !== '') {
            returnString += `# TYPE ${name} counter\n`;
            const labels = makePrometheusLabels(defaultLabels);
            returnString += `${name}${labels} ${value}\n`;
        }
    });
    return returnString;
}
function makePrometheus ( stats , defaultLabels = { } ) { const metricMapping = { processed : 'teraslice_slices_processed' , failed : 'teraslice_slices_failed' , queued : 'teraslice_slices_queued' , job_duration : '' , // this isn't really useful, omitting workers_joined : 'teraslice_workers_joined' , workers_disconnected : 'teraslice_workers_disconnected' , workers_reconnected : 'teraslice_workers_reconnected' } ; let returnString = '' ; _ . forEach ( stats . controllers , ( value , key ) => { const name = metricMapping [ key ] ; if ( name !== '' ) { returnString += ` ${ name } \n ` ; const labels = makePrometheusLabels ( defaultLabels ) ; returnString += ` ${ name } ${ labels } ${ value } \n ` ; } } ) ; return returnString ; }
NOTE: This only works for counters, if you're trying to extend this, you should probably switch to using prom-client.
NOTE : This only works for counters if you re trying to extend this you should probably switch to using prom - client .