|
@@ -1,4 +1,5 @@
|
|
|
const crypto = require('crypto')
|
|
const crypto = require('crypto')
|
|
|
|
|
+const metrics = require('metrics-sharelatex')
|
|
|
const meter = require('stream-meter')
|
|
const meter = require('stream-meter')
|
|
|
const Stream = require('stream')
|
|
const Stream = require('stream')
|
|
|
const logger = require('logger-sharelatex')
|
|
const logger = require('logger-sharelatex')
|
|
@@ -54,16 +55,16 @@ async function verifyMd5(persistor, bucket, key, sourceMd5, destMd5 = null) {
|
|
|
|
|
|
|
|
// returns the next stream in the pipeline, and calls the callback with the byte count
|
|
// returns the next stream in the pipeline, and calls the callback with the byte count
|
|
|
// when the stream finishes or receives an error
|
|
// when the stream finishes or receives an error
|
|
|
-function getMeteredStream(stream, callback) {
|
|
|
|
|
|
|
+function getMeteredStream(stream, metricName) {
|
|
|
const meteredStream = meter()
|
|
const meteredStream = meter()
|
|
|
|
|
|
|
|
pipeline(stream, meteredStream)
|
|
pipeline(stream, meteredStream)
|
|
|
.then(() => {
|
|
.then(() => {
|
|
|
- callback(null, meteredStream.bytes)
|
|
|
|
|
|
|
+ metrics.count(metricName, meteredStream.bytes)
|
|
|
})
|
|
})
|
|
|
- .catch(err => {
|
|
|
|
|
|
|
+ .catch(() => {
|
|
|
// on error, just send how many bytes we received before the stream stopped
|
|
// on error, just send how many bytes we received before the stream stopped
|
|
|
- callback(err, meteredStream.bytes)
|
|
|
|
|
|
|
+ metrics.count(metricName, meteredStream.bytes)
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
return meteredStream
|
|
return meteredStream
|