Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
var log = options.log;
// Configure the metric collector.
var labels = {
datacenter: options.datacenter,
server: options.server_uuid,
zonename: mod_os.hostname(),
pid: process.pid
};
/* service_name includes the shard name in Manta deployments. */
if (options.service_name) {
labels.service = options.service_name;
}
var collector = mod_artedi.createCollector({
labels: labels
});
var dbopts, dbresolver, dbdomain;
if (options.standalone) {
/*
* Standalone mode takes a Postgres URL to determine what to connect
* to, which we pass directly to the client. Since this may not be a
* hostname (i.e., it could a path for using a Unix domain socket),
* we just provide dummy values here for cueball, and ignore them
* later on.
*/
dbopts = options.standalone;
dbdomain = 'standalone';
dbresolver = new mod_cueball.StaticIpResolver({
backends: [
dbresolver.once('added', function (_, primary) {
var collector = mod_artedi.createCollector({ labels: {} });
var db = mod_pg.createPool(mod_jsprim.mergeObjects(dbopts.pg, {
log: LOG,
domain: 'manatee',
user: 'postgres',
collector: collector,
resolver: dbresolver
}));
setupPostgres({
resolver: dbresolver,
primary: primary,
config: config,
db: db
}, function (err) {
db.close();
req.on('end', function () {
collector.collect(mod_artedi.FMT_PROM, function (err, metrics) {
if (err) {
next(new VError(err));
return;
}
res.setHeader('Content-Type', 'text/plain; version=0.0.4');
res.send(metrics);
});
next();
});
req.resume();