Add retry stats

This commit is contained in:
Jonathan Cremin 2016-06-06 21:05:30 +01:00
parent cb8f5f59d0
commit 9d75fcaa93

View file

@ -1,8 +1,12 @@
import { dirname, join } from 'path';
import StatsD from 'statsy';
import Client from './ssh2-sftp-client';
import debugname from 'debug';
const debug = debugname('hostr:sftp');
const statsdOpts = { prefix: 'hostr-api', host: process.env.STATSD_HOST };
const statsd = new StatsD(statsdOpts);
export function get(remotePath) {
debug('fetching', join('hostr', 'uploads', remotePath));
const sftp = new Client();
@ -41,6 +45,7 @@ export function *upload(localPath, remotePath) {
done = yield sendFile(localPath, remotePath);
break;
} catch (err) {
statsd.incr('file.upload.retry', 1);
debug('retry');
}
}