Add retry stats
This commit is contained in:
parent
cb8f5f59d0
commit
9d75fcaa93
1 changed files with 5 additions and 0 deletions
|
@ -1,8 +1,12 @@
|
||||||
import { dirname, join } from 'path';
|
import { dirname, join } from 'path';
|
||||||
|
import StatsD from 'statsy';
|
||||||
import Client from './ssh2-sftp-client';
|
import Client from './ssh2-sftp-client';
|
||||||
import debugname from 'debug';
|
import debugname from 'debug';
|
||||||
const debug = debugname('hostr:sftp');
|
const debug = debugname('hostr:sftp');
|
||||||
|
|
||||||
|
const statsdOpts = { prefix: 'hostr-api', host: process.env.STATSD_HOST };
|
||||||
|
const statsd = new StatsD(statsdOpts);
|
||||||
|
|
||||||
export function get(remotePath) {
|
export function get(remotePath) {
|
||||||
debug('fetching', join('hostr', 'uploads', remotePath));
|
debug('fetching', join('hostr', 'uploads', remotePath));
|
||||||
const sftp = new Client();
|
const sftp = new Client();
|
||||||
|
@ -41,6 +45,7 @@ export function *upload(localPath, remotePath) {
|
||||||
done = yield sendFile(localPath, remotePath);
|
done = yield sendFile(localPath, remotePath);
|
||||||
break;
|
break;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
statsd.incr('file.upload.retry', 1);
|
||||||
debug('retry');
|
debug('retry');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue