logging GzipSize

This commit is contained in:
Simon Martín 2018-06-05 13:02:14 +02:00
parent 02cc606be1
commit 29d1fb1274

View File

@ -110,11 +110,20 @@ module.exports = {
return cb(err);
}
})
.on('data', data => metrics.size += data.length)
.on('data', data => {
if (gzip) {
metrics.addGzipSize(data.length)
} else {
metrics.addSize(data.length)
}
})
.on('end', () => requestEnded = true);
if (gzip) {
req.pipe(zlib.createGunzip()).pipe(pgstream);
req
.pipe(zlib.createGunzip())
.on('data', data => metrics.addSize(data.length))
.pipe(pgstream);
} else {
req.pipe(pgstream);
}