diff --git a/lib/sftp.js b/lib/sftp.js index d61cb8a..7193159 100644 --- a/lib/sftp.js +++ b/lib/sftp.js @@ -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'); } }