improve sentry reporting, add metrics for hydro
This commit is contained in:
14
lib/hydro.js
14
lib/hydro.js
@@ -1,5 +1,10 @@
|
||||
const crypto = require('crypto')
|
||||
const fetch = require('node-fetch')
|
||||
const statsd = require('../lib/statsd')
|
||||
|
||||
const hydroStats = statsd.childClient({
|
||||
prefix: 'hydro.'
|
||||
})
|
||||
|
||||
const SCHEMAS = {
|
||||
page: 'docs.v0.PageEvent',
|
||||
@@ -62,7 +67,7 @@ module.exports = class Hydro {
|
||||
})
|
||||
const token = this.generatePayloadHmac(body)
|
||||
|
||||
return fetch(this.endpoint, {
|
||||
const fn = () => fetch(this.endpoint, {
|
||||
method: 'POST',
|
||||
body,
|
||||
headers: {
|
||||
@@ -71,5 +76,12 @@ module.exports = class Hydro {
|
||||
'X-Hydro-App': 'docs-production'
|
||||
}
|
||||
})
|
||||
|
||||
const res = await hydroStats.asyncTimer(fn, 'response_time')
|
||||
|
||||
hydroStats.increment(`response_code.${res.statusCode}`, 1)
|
||||
hydroStats.increment('response_code.all', 1)
|
||||
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user