1
0
mirror of synced 2025-12-25 02:17:36 -05:00

improve sentry reporting, add metrics for hydro

This commit is contained in:
Mike Surowiec
2021-04-06 16:08:51 -07:00
parent adb81ce5b5
commit 008faf57eb
2 changed files with 17 additions and 4 deletions

View File

@@ -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;
}
}