From 9d75fcaa93333c13273fb3b6fac9c9b2b688819e Mon Sep 17 00:00:00 2001 From: Jonathan Cremin Date: Mon, 6 Jun 2016 21:05:30 +0100 Subject: [PATCH] Add retry stats --- lib/sftp.js | 5 +++++ 1 file changed, 5 insertions(+) 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'); } }