Skip to content
This repository was archived by the owner on Apr 24, 2018. It is now read-only.

Commit c225470

Browse files
committed
Revert "Disable unused Statistics"
This reverts commit 54e71ab.
1 parent 797f9c9 commit c225470

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

data/dataIO.js

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,19 @@ module.exports = {
2121
dataIOTests
2222
}
2323

24+
const url = require('url')
25+
const parsedStatsdUrl = url.parse(process.env.STATSD_URL, true, true)
26+
const StatsD = require('node-statsd')
27+
const statsClient = new StatsD(
28+
{
29+
host: parsedStatsdUrl.hostname,
30+
port: parsedStatsdUrl.port
31+
}
32+
)
33+
statsClient.socket.on('error', function (error) {
34+
_log_(`Error in socket: ${error}`)
35+
})
36+
2437
const firstEvent = 0
2538

2639
/**
@@ -168,6 +181,8 @@ dataIO.sendtoAPI = (title, agenda, social, place, regUrl, imgUrl, whenStart, whe
168181
'submitter_email': process.env.EMAIL
169182
})
170183

184+
statsClient.increment('eventsparser.sendToAPI.sends')
185+
171186
const options = {
172187
'hostname': process.env.HOSTNAME_URL,
173188
'port': process.env.HOSTNAME_PORT,
@@ -187,7 +202,11 @@ dataIO.sendtoAPI = (title, agenda, social, place, regUrl, imgUrl, whenStart, whe
187202
res.on('end', () => { _log_('No more data in response. \n') })
188203
}
189204
})
190-
req.on('error', (e) => { _log_(`problem with request: ${e.message}`) })
205+
req.on('error', (e) => {
206+
_log_(`problem with request: ${e.message}`)
207+
statsClient.increment('eventsparser.sendToAPI.errors')
208+
})
209+
191210
req.write(body)
192211
req.end()
193212
}

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@
2525
"moment": "~2.13.0",
2626
"node-statsd": "0.1.1",
2727
"sync-request": "~3.0.0",
28-
"xml2json": "~0.9.2",
28+
"url": "0.11.0",
29+
"xml2json": "0.9.2",
2930
"yandex-translate": "~2.1.0"
3031
},
3132
"devDependencies": {

0 commit comments

Comments
 (0)