From b545026855e491c217d50bd54035fec5ee63db46 Mon Sep 17 00:00:00 2001 From: Max Stoiber Date: Tue, 11 Dec 2018 09:43:42 +0100 Subject: [PATCH 01/37] Add hot-shots dependency This is the recommended library to use for metrics reporting to datadog, see https://docs.datadoghq.com/integrations/node --- api/package.json | 5 +++-- api/yarn.lock | 7 ++++++- package.json | 3 ++- yarn.lock | 5 +++++ 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/api/package.json b/api/package.json index 42fb2f402d..8225ac8214 100644 --- a/api/package.json +++ b/api/package.json @@ -1,6 +1,6 @@ { "engines": { - "node": "10.7.0" + "node": "^10.0.0" }, "dependencies": { "algoliasearch": "^3.31.0", @@ -58,6 +58,7 @@ "history": "^4.6.1", "hoist-non-react-statics": "^2.5.5", "host-validation": "^1.2.0", + "hot-shots": "^5.9.2", "hpp": "^0.2.2", "hsts": "^2.1.0", "imgix-core-js": "^1.2.0", @@ -135,4 +136,4 @@ "scripts": { "start": "NODE_ENV=production node main.js" } -} \ No newline at end of file +} diff --git a/api/yarn.lock b/api/yarn.lock index 2eb98ce93d..e3c444f3a0 100644 --- a/api/yarn.lock +++ b/api/yarn.lock @@ -3659,7 +3659,7 @@ draft-js-prism@^1.0.6: extend "^3.0.0" immutable "*" -"draft-js-prism@github:ngs/draft-js-prism#6edb31c3805dd1de3fb897cc27fced6bac1bafbb": +draft-js-prism@ngs/draft-js-prism#6edb31c3805dd1de3fb897cc27fced6bac1bafbb: version "1.0.3" resolved "https://codeload.github.com/ngs/draft-js-prism/tar.gz/6edb31c3805dd1de3fb897cc27fced6bac1bafbb" dependencies: @@ -4930,6 +4930,11 @@ hosted-git-info@^2.1.4: resolved "https://registry.yarnpkg.com/hosted-git-info/-/hosted-git-info-2.7.1.tgz#97f236977bd6e125408930ff6de3eec6281ec047" integrity sha512-7T/BxH19zbcCTa8XkMlbK5lTo1WtgkFi3GvdWEyNuc4Vex7/9Dqbnpsf4JMydcfj9HCg4zUWFTL3Za6lapg5/w== +hot-shots@^5.9.2: + version "5.9.2" + resolved "https://registry.yarnpkg.com/hot-shots/-/hot-shots-5.9.2.tgz#1cff097706f40ba2c1350d4806deebbd16a5e8c8" + integrity sha512-ruHZvHaxZRVUCoCleiwwCcjdr9A2/Y97C7oc9LpyMg9ae39blHvsJJQQ0QtMtxKX+i4lig/7/BqZBjUUZPUp3A== + hpkp@2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/hpkp/-/hpkp-2.0.0.tgz#10e142264e76215a5d30c44ec43de64dee6d1672" diff --git a/package.json b/package.json index 1ad3011359..3c38929c7a 100644 --- a/package.json +++ b/package.json @@ -116,6 +116,7 @@ "history": "^4.6.1", "hoist-non-react-statics": "^2.3.1", "host-validation": "^1.1.0", + "hot-shots": "^5.9.2", "hpp": "^0.2.2", "hsts": "^2.1.0", "idx": "^2.4.0", @@ -280,4 +281,4 @@ ] }, "pre-commit": "lint:staged" -} \ No newline at end of file +} diff --git a/yarn.lock b/yarn.lock index f3f5ebce5a..e52b01903c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -7549,6 +7549,11 @@ hosted-git-info@^2.1.4: resolved "https://registry.yarnpkg.com/hosted-git-info/-/hosted-git-info-2.7.1.tgz#97f236977bd6e125408930ff6de3eec6281ec047" integrity sha512-7T/BxH19zbcCTa8XkMlbK5lTo1WtgkFi3GvdWEyNuc4Vex7/9Dqbnpsf4JMydcfj9HCg4zUWFTL3Za6lapg5/w== +hot-shots@^5.9.2: + version "5.9.2" + resolved "https://registry.yarnpkg.com/hot-shots/-/hot-shots-5.9.2.tgz#1cff097706f40ba2c1350d4806deebbd16a5e8c8" + integrity sha512-ruHZvHaxZRVUCoCleiwwCcjdr9A2/Y97C7oc9LpyMg9ae39blHvsJJQQ0QtMtxKX+i4lig/7/BqZBjUUZPUp3A== + hpack.js@^2.1.6: version "2.1.6" resolved "https://registry.yarnpkg.com/hpack.js/-/hpack.js-2.1.6.tgz#87774c0949e513f42e84575b3c45681fade2a0b2" From 94b023c59d6ba3b0e38af41e5a3fa90271559e2c Mon Sep 17 00:00:00 2001 From: Max Stoiber Date: Tue, 11 Dec 2018 10:22:13 +0100 Subject: [PATCH 02/37] Integrate StatsD tracking into API and hyperion This tracks response times and status codes, and also specificaly tracks GraphQL operations happening in the API. --- api/apollo-server.js | 3 +++ api/index.js | 4 ++++ api/package.json | 1 + api/yarn.lock | 31 +++++++++++++++++++++++++++++++ package.json | 1 + shared/middlewares/statsd.js | 30 ++++++++++++++++++++++++++++++ yarn.lock | 31 +++++++++++++++++++++++++++++++ 7 files changed, 101 insertions(+) create mode 100644 shared/middlewares/statsd.js diff --git a/api/apollo-server.js b/api/apollo-server.js index ea1daf51bc..52a9b91db7 100644 --- a/api/apollo-server.js +++ b/api/apollo-server.js @@ -51,6 +51,9 @@ const server = new ProtectedApolloServer({ }; } + // Override the default req.statsdKey with GraphQL info + req.statsdKey = `http.post.api.${req.body.operationName || + 'unnamed_query'}`; const loaders = createLoaders(); let currentUser = req.user && !req.user.bannedAt ? req.user : null; diff --git a/api/index.js b/api/index.js index cd6672a45f..8af4e33d02 100644 --- a/api/index.js +++ b/api/index.js @@ -13,6 +13,7 @@ import { ApolloEngine } from 'apollo-engine'; import toobusy from 'shared/middlewares/toobusy'; import addSecurityMiddleware from 'shared/middlewares/security'; import csrf from 'shared/middlewares/csrf'; +import statsd from 'shared/middlewares/statsd'; import { init as initPassport } from './authentication.js'; import apolloServer from './apollo-server'; import { corsOptions } from 'shared/middlewares/cors'; @@ -37,6 +38,9 @@ initPassport(); const app = express(); +// Instantiate the statsd middleware as soon as possible to get accurate time tracking +app.use(statsd); + // Trust the now proxy app.set('trust proxy', true); app.use(toobusy); diff --git a/api/package.json b/api/package.json index 8225ac8214..7bc51ef973 100644 --- a/api/package.json +++ b/api/package.json @@ -44,6 +44,7 @@ "express": "^4.16.4", "express-enforces-ssl": "^1.1.0", "express-session": "^1.15.2", + "express-statsd": "^0.3.0", "faker": "^4.1.0", "find-with-regex": "^1.1.3", "flow-typed": "^2.5.1", diff --git a/api/yarn.lock b/api/yarn.lock index e3c444f3a0..f80fc29bf2 100644 --- a/api/yarn.lock +++ b/api/yarn.lock @@ -4047,6 +4047,14 @@ express-session@^1.15.2: uid-safe "~2.1.5" utils-merge "1.0.1" +express-statsd@^0.3.0: + version "0.3.0" + resolved "https://registry.yarnpkg.com/express-statsd/-/express-statsd-0.3.0.tgz#cb60b8e4f633adc7eaaefb5819698b469c00b1bd" + integrity sha1-y2C45PYzrcfqrvtYGWmLRpwAsb0= + dependencies: + lynx "~0.0.11" + obj-extend "~0.1.0" + express@^4.16.4: version "4.16.4" resolved "https://registry.yarnpkg.com/express/-/express-4.16.4.tgz#fddef61926109e24c515ea97fd2f1bdbf62df12e" @@ -6419,6 +6427,14 @@ lru-cache@^5.0.0: dependencies: yallist "^3.0.2" +lynx@~0.0.11: + version "0.0.11" + resolved "https://registry.yarnpkg.com/lynx/-/lynx-0.0.11.tgz#2cfa14e443fd2d92a59b779f41567ce1cc6965a3" + integrity sha1-LPoU5EP9LZKlm3efQVZ84cxpZaM= + dependencies: + mersenne "~0.0.3" + statsd-parser "~0.0.4" + macos-release@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/macos-release/-/macos-release-2.0.0.tgz#7dddf4caf79001a851eb4fba7fb6034f251276ab" @@ -6541,6 +6557,11 @@ mersenne-twister@^1.0.1: resolved "https://registry.yarnpkg.com/mersenne-twister/-/mersenne-twister-1.1.0.tgz#f916618ee43d7179efcf641bec4531eb9670978a" integrity sha1-+RZhjuQ9cXnvz2Qb7EUx65Zwl4o= +mersenne@~0.0.3: + version "0.0.4" + resolved "https://registry.yarnpkg.com/mersenne/-/mersenne-0.0.4.tgz#401fdec7ec21cdb9e03cd3d3021398da21b27085" + integrity sha1-QB/ex+whzbngPNPTAhOY2iGycIU= + methods@~1.1.2: version "1.1.2" resolved "https://registry.yarnpkg.com/methods/-/methods-1.1.2.tgz#5529a4d67654134edcc5266656835b0f851afcee" @@ -6989,6 +7010,11 @@ oauth@0.9.x: resolved "https://registry.yarnpkg.com/oauth/-/oauth-0.9.15.tgz#bd1fefaf686c96b75475aed5196412ff60cfb9c1" integrity sha1-vR/vr2hslrdUda7VGWQS/2DPucE= +obj-extend@~0.1.0: + version "0.1.0" + resolved "https://registry.yarnpkg.com/obj-extend/-/obj-extend-0.1.0.tgz#bb448a4775fb95eb34a781f908bbac2df23dbb5b" + integrity sha1-u0SKR3X7les0p4H5CLusLfI9u1s= + object-assign@^4, object-assign@^4.0.1, object-assign@^4.1.0, object-assign@^4.1.1: version "4.1.1" resolved "https://registry.yarnpkg.com/object-assign/-/object-assign-4.1.1.tgz#2109adc7965887cfc05cbbd442cac8bfbb360863" @@ -8831,6 +8857,11 @@ static-extend@^0.1.1: define-property "^0.2.5" object-copy "^0.1.0" +statsd-parser@~0.0.4: + version "0.0.4" + resolved "https://registry.yarnpkg.com/statsd-parser/-/statsd-parser-0.0.4.tgz#cbd243953cc42effd548b5d22388ed689ec639bd" + integrity sha1-y9JDlTzELv/VSLXSI4jtaJ7GOb0= + "statuses@>= 1.4.0 < 2": version "1.5.0" resolved "https://registry.yarnpkg.com/statuses/-/statuses-1.5.0.tgz#161c7dac177659fd9811f43771fa99381478628c" diff --git a/package.json b/package.json index 3c38929c7a..90ee5534f8 100644 --- a/package.json +++ b/package.json @@ -101,6 +101,7 @@ "express": "^4.16.4", "express-enforces-ssl": "^1.1.0", "express-session": "^1.15.2", + "express-statsd": "^0.3.0", "faker": "^4.1.0", "find-with-regex": "^1.0.2", "flow-typed": "^2.5.1", diff --git a/shared/middlewares/statsd.js b/shared/middlewares/statsd.js new file mode 100644 index 0000000000..075f09ed5d --- /dev/null +++ b/shared/middlewares/statsd.js @@ -0,0 +1,30 @@ +// @flow +import statsdMiddleware from 'express-statsd'; +import StatsD from 'hot-shots'; + +export const client = new StatsD({ + mock: process.env.NODE_ENV !== 'production', + prefix: `${process.env.SENTRY_NAME || 'server'}.`, +}); + +client.socket.on('error', function(error) { + console.error('Error in socket: ', error); +}); + +const middleware = statsdMiddleware({ + client: new StatsD(), +}); + +export default ( + req: express$Request, + res: express$Response, + next: express$NextFunction +) => { + // Set a sensible default req.statsdKey, which is what will be shown in the DataDog UI. Example key: + // hyperion.http.get.spectrum.general + const pathname = req.path.replace(/\?.*/, ''); + req.statsdKey = `http.${req.method.toLowerCase()}${pathname + .toLowerCase() + .replace('/', '.')}`; + return middleware(req, res, next); +}; diff --git a/yarn.lock b/yarn.lock index e52b01903c..082c0c7c88 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6318,6 +6318,14 @@ express-session@^1.15.2: uid-safe "~2.1.5" utils-merge "1.0.1" +express-statsd@^0.3.0: + version "0.3.0" + resolved "https://registry.yarnpkg.com/express-statsd/-/express-statsd-0.3.0.tgz#cb60b8e4f633adc7eaaefb5819698b469c00b1bd" + integrity sha1-y2C45PYzrcfqrvtYGWmLRpwAsb0= + dependencies: + lynx "~0.0.11" + obj-extend "~0.1.0" + express@^4.16.2, express@^4.16.4: version "4.16.4" resolved "https://registry.yarnpkg.com/express/-/express-4.16.4.tgz#fddef61926109e24c515ea97fd2f1bdbf62df12e" @@ -9668,6 +9676,14 @@ lru-cache@^5.0.0: dependencies: yallist "^3.0.2" +lynx@~0.0.11: + version "0.0.11" + resolved "https://registry.yarnpkg.com/lynx/-/lynx-0.0.11.tgz#2cfa14e443fd2d92a59b779f41567ce1cc6965a3" + integrity sha1-LPoU5EP9LZKlm3efQVZ84cxpZaM= + dependencies: + mersenne "~0.0.3" + statsd-parser "~0.0.4" + macos-release@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/macos-release/-/macos-release-2.0.0.tgz#7dddf4caf79001a851eb4fba7fb6034f251276ab" @@ -9832,6 +9848,11 @@ mersenne-twister@^1.0.1: resolved "https://registry.yarnpkg.com/mersenne-twister/-/mersenne-twister-1.1.0.tgz#f916618ee43d7179efcf641bec4531eb9670978a" integrity sha1-+RZhjuQ9cXnvz2Qb7EUx65Zwl4o= +mersenne@~0.0.3: + version "0.0.4" + resolved "https://registry.yarnpkg.com/mersenne/-/mersenne-0.0.4.tgz#401fdec7ec21cdb9e03cd3d3021398da21b27085" + integrity sha1-QB/ex+whzbngPNPTAhOY2iGycIU= + methods@^1.1.1, methods@~1.1.2: version "1.1.2" resolved "https://registry.yarnpkg.com/methods/-/methods-1.1.2.tgz#5529a4d67654134edcc5266656835b0f851afcee" @@ -10432,6 +10453,11 @@ oauth@0.9.x: resolved "https://registry.yarnpkg.com/oauth/-/oauth-0.9.15.tgz#bd1fefaf686c96b75475aed5196412ff60cfb9c1" integrity sha1-vR/vr2hslrdUda7VGWQS/2DPucE= +obj-extend@~0.1.0: + version "0.1.0" + resolved "https://registry.yarnpkg.com/obj-extend/-/obj-extend-0.1.0.tgz#bb448a4775fb95eb34a781f908bbac2df23dbb5b" + integrity sha1-u0SKR3X7les0p4H5CLusLfI9u1s= + object-assign@4.1.1, object-assign@^4, object-assign@^4.0.1, object-assign@^4.1.0, object-assign@^4.1.1: version "4.1.1" resolved "https://registry.yarnpkg.com/object-assign/-/object-assign-4.1.1.tgz#2109adc7965887cfc05cbbd442cac8bfbb360863" @@ -13437,6 +13463,11 @@ static-extend@^0.1.1: define-property "^0.2.5" object-copy "^0.1.0" +statsd-parser@~0.0.4: + version "0.0.4" + resolved "https://registry.yarnpkg.com/statsd-parser/-/statsd-parser-0.0.4.tgz#cbd243953cc42effd548b5d22388ed689ec639bd" + integrity sha1-y9JDlTzELv/VSLXSI4jtaJ7GOb0= + "statuses@>= 1.4.0 < 2": version "1.5.0" resolved "https://registry.yarnpkg.com/statuses/-/statuses-1.5.0.tgz#161c7dac177659fd9811f43771fa99381478628c" From c17286c118fb096994127b617f86cb07f2296dec Mon Sep 17 00:00:00 2001 From: Max Stoiber Date: Tue, 11 Dec 2018 10:44:28 +0100 Subject: [PATCH 03/37] Dont double-create statsd clients --- shared/middlewares/statsd.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shared/middlewares/statsd.js b/shared/middlewares/statsd.js index 075f09ed5d..458e1b2060 100644 --- a/shared/middlewares/statsd.js +++ b/shared/middlewares/statsd.js @@ -12,7 +12,7 @@ client.socket.on('error', function(error) { }); const middleware = statsdMiddleware({ - client: new StatsD(), + client, }); export default ( From 77c07e0988e8a9ee1a702c53704d9962819ce952 Mon Sep 17 00:00:00 2001 From: Max Stoiber Date: Tue, 11 Dec 2018 10:49:27 +0100 Subject: [PATCH 04/37] Log statsd metrics in dev --- shared/middlewares/statsd.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/shared/middlewares/statsd.js b/shared/middlewares/statsd.js index 458e1b2060..bd3fa4db77 100644 --- a/shared/middlewares/statsd.js +++ b/shared/middlewares/statsd.js @@ -1,4 +1,5 @@ // @flow +const debug = require('debug')('shared:middlewares:statsd'); import statsdMiddleware from 'express-statsd'; import StatsD from 'hot-shots'; @@ -15,6 +16,13 @@ const middleware = statsdMiddleware({ client, }); +const log = () => { + client.mockBuffer.forEach(item => { + debug(item); + }); + client.mockBuffer = []; +}; + export default ( req: express$Request, res: express$Response, @@ -26,5 +34,7 @@ export default ( req.statsdKey = `http.${req.method.toLowerCase()}${pathname .toLowerCase() .replace('/', '.')}`; + // Log the StatsD metrics in development + if (debug.enabled) res.once('finish', log); return middleware(req, res, next); }; From 3fbbc2e95038c0b644fabe7b0ca9a5a976077d74 Mon Sep 17 00:00:00 2001 From: Max Stoiber Date: Tue, 11 Dec 2018 11:15:39 +0100 Subject: [PATCH 05/37] Fix flowtype --- flow-typed/npm/express-statsd_vx.x.x.js | 53 +++++++++++++++++++++++++ flow-typed/npm/hot-shots_vx.x.x.js | 52 ++++++++++++++++++++++++ shared/middlewares/statsd.js | 1 + 3 files changed, 106 insertions(+) create mode 100644 flow-typed/npm/express-statsd_vx.x.x.js create mode 100644 flow-typed/npm/hot-shots_vx.x.x.js diff --git a/flow-typed/npm/express-statsd_vx.x.x.js b/flow-typed/npm/express-statsd_vx.x.x.js new file mode 100644 index 0000000000..3d3fb7fcb9 --- /dev/null +++ b/flow-typed/npm/express-statsd_vx.x.x.js @@ -0,0 +1,53 @@ +// flow-typed signature: 1cdaa5e3b96efaeacdd3cbc4b45b40d3 +// flow-typed version: <>/express-statsd_vx.x.x/flow_v0.66.0 + +/** + * This is an autogenerated libdef stub for: + * + * 'express-statsd' + * + * Fill this stub out by replacing all the `any` types. + * + * Once filled out, we encourage you to share your work with the + * community by sending a pull request to: + * https://github.com/flowtype/flow-typed + */ + +declare module 'express-statsd' { + declare module.exports: any; +} + +/** + * We include stubs for each file inside this npm package in case you need to + * require those files directly. Feel free to delete any files that aren't + * needed. + */ +declare module 'express-statsd/Gruntfile' { + declare module.exports: any; +} + +declare module 'express-statsd/lib/express-statsd' { + declare module.exports: any; +} + +declare module 'express-statsd/test/express-statsd' { + declare module.exports: any; +} + +declare module 'express-statsd/test/utils' { + declare module.exports: any; +} + +// Filename aliases +declare module 'express-statsd/Gruntfile.js' { + declare module.exports: $Exports<'express-statsd/Gruntfile'>; +} +declare module 'express-statsd/lib/express-statsd.js' { + declare module.exports: $Exports<'express-statsd/lib/express-statsd'>; +} +declare module 'express-statsd/test/express-statsd.js' { + declare module.exports: $Exports<'express-statsd/test/express-statsd'>; +} +declare module 'express-statsd/test/utils.js' { + declare module.exports: $Exports<'express-statsd/test/utils'>; +} diff --git a/flow-typed/npm/hot-shots_vx.x.x.js b/flow-typed/npm/hot-shots_vx.x.x.js new file mode 100644 index 0000000000..c8c07c6213 --- /dev/null +++ b/flow-typed/npm/hot-shots_vx.x.x.js @@ -0,0 +1,52 @@ +// flow-typed signature: ddf4dd814629ae123ef685c9db868bef +// flow-typed version: <>/hot-shots_v5.x.x/flow_v0.66.0 + +/** + * This is an autogenerated libdef stub for: + * + * 'hot-shots' + * + * Fill this stub out by replacing all the `any` types. + * + * Once filled out, we encourage you to share your work with the + * community by sending a pull request to: + * https://github.com/flowtype/flow-typed + */ + +declare module 'hot-shots' { + declare module.exports: any; +} + +/** + * We include stubs for each file inside this npm package in case you need to + * require those files directly. Feel free to delete any files that aren't + * needed. + */ +declare module 'hot-shots/lib/helpers' { + declare module.exports: any; +} + +declare module 'hot-shots/lib/statsd' { + declare module.exports: any; +} + +declare module 'hot-shots/lib/statsFunctions' { + declare module.exports: any; +} + +// Filename aliases +declare module 'hot-shots/index' { + declare module.exports: $Exports<'hot-shots'>; +} +declare module 'hot-shots/index.js' { + declare module.exports: $Exports<'hot-shots'>; +} +declare module 'hot-shots/lib/helpers.js' { + declare module.exports: $Exports<'hot-shots/lib/helpers'>; +} +declare module 'hot-shots/lib/statsd.js' { + declare module.exports: $Exports<'hot-shots/lib/statsd'>; +} +declare module 'hot-shots/lib/statsFunctions.js' { + declare module.exports: $Exports<'hot-shots/lib/statsFunctions'>; +} diff --git a/shared/middlewares/statsd.js b/shared/middlewares/statsd.js index bd3fa4db77..fbeed2a072 100644 --- a/shared/middlewares/statsd.js +++ b/shared/middlewares/statsd.js @@ -31,6 +31,7 @@ export default ( // Set a sensible default req.statsdKey, which is what will be shown in the DataDog UI. Example key: // hyperion.http.get.spectrum.general const pathname = req.path.replace(/\?.*/, ''); + // $FlowFixMe req.statsdKey = `http.${req.method.toLowerCase()}${pathname .toLowerCase() .replace('/', '.')}`; From 00afdf1402b610f7bec64babb1ec252cff68c301 Mon Sep 17 00:00:00 2001 From: Max Stoiber Date: Tue, 11 Dec 2018 11:48:16 +0100 Subject: [PATCH 06/37] Track database connection count and queue size in DataDog MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is based on #4444 and adds tracking of the database connection count and query queue size over time. I'm not sure we should ship this as it happens _very_ often… --- shared/db/db.js | 11 +++++++++++ shared/middlewares/statsd.js | 23 ++--------------------- shared/statsd.js | 25 +++++++++++++++++++++++++ 3 files changed, 38 insertions(+), 21 deletions(-) create mode 100644 shared/statsd.js diff --git a/shared/db/db.js b/shared/db/db.js index bcfe99ebac..0ef90be352 100644 --- a/shared/db/db.js +++ b/shared/db/db.js @@ -4,6 +4,7 @@ */ import fs from 'fs'; import path from 'path'; +import { statsd } from '../statsd'; const IS_PROD = !process.env.FORCE_DEV && process.env.NODE_ENV === 'production'; @@ -50,6 +51,16 @@ const config = IS_PROD var r = require('rethinkhaberdashery')(config); +const poolMaster = r.getPoolMaster(); + +poolMaster.on('queueing', length => { + statsd.gauge('db.query_queue_length', length); +}); + +poolMaster.on('size', connections => { + statsd.gauge('db.connection_count', connections); +}); + // Exit the process on unhealthy db in test env if (process.env.TEST_DB) { r.getPoolMaster().on('healthy', healthy => { diff --git a/shared/middlewares/statsd.js b/shared/middlewares/statsd.js index fbeed2a072..cdf1f0b86e 100644 --- a/shared/middlewares/statsd.js +++ b/shared/middlewares/statsd.js @@ -1,28 +1,11 @@ // @flow -const debug = require('debug')('shared:middlewares:statsd'); import statsdMiddleware from 'express-statsd'; -import StatsD from 'hot-shots'; - -export const client = new StatsD({ - mock: process.env.NODE_ENV !== 'production', - prefix: `${process.env.SENTRY_NAME || 'server'}.`, -}); - -client.socket.on('error', function(error) { - console.error('Error in socket: ', error); -}); +import { statsd } from '../statsd'; const middleware = statsdMiddleware({ - client, + client: statsd, }); -const log = () => { - client.mockBuffer.forEach(item => { - debug(item); - }); - client.mockBuffer = []; -}; - export default ( req: express$Request, res: express$Response, @@ -35,7 +18,5 @@ export default ( req.statsdKey = `http.${req.method.toLowerCase()}${pathname .toLowerCase() .replace('/', '.')}`; - // Log the StatsD metrics in development - if (debug.enabled) res.once('finish', log); return middleware(req, res, next); }; diff --git a/shared/statsd.js b/shared/statsd.js new file mode 100644 index 0000000000..7133e02059 --- /dev/null +++ b/shared/statsd.js @@ -0,0 +1,25 @@ +// @flow +const debug = require('debug')('shared:middlewares:statsd'); +import StatsD from 'hot-shots'; + +export const statsd = new StatsD({ + mock: process.env.NODE_ENV !== 'production', + prefix: `${process.env.SENTRY_NAME || 'server'}.`, +}); + +statsd.socket.on('error', function(error) { + console.error('Error in socket: ', error); +}); + +// Log StatsD events in development by monkey-patching the internal _send method +// because hot-shots does not expose a way to listen to events as they happen +if (debug.enabled) { + const originalSend = statsd._send; + statsd._send = (...args) => { + statsd.mockBuffer.forEach(item => { + debug(item); + }); + statsd.mockBuffer = []; + return originalSend.call(statsd, ...args); + }; +} From 0e0fec81f99560e90f58ac934a84f0097906ec58 Mon Sep 17 00:00:00 2001 From: Max Stoiber Date: Tue, 11 Dec 2018 12:46:04 +0100 Subject: [PATCH 07/37] Switch to express-hot-shots fork Forked express-statsd to withspectrum/express-hot-shots to add support for tags in the metrics. --- api/package.json | 2 +- api/yarn.lock | 34 ++++---------- flow-typed/npm/express-hot-shots_vx.x.x.js | 53 ++++++++++++++++++++++ flow-typed/npm/express-statsd_vx.x.x.js | 53 ---------------------- package.json | 2 +- shared/middlewares/statsd.js | 2 +- shared/statsd.js | 4 +- yarn.lock | 34 ++++---------- 8 files changed, 75 insertions(+), 109 deletions(-) create mode 100644 flow-typed/npm/express-hot-shots_vx.x.x.js delete mode 100644 flow-typed/npm/express-statsd_vx.x.x.js diff --git a/api/package.json b/api/package.json index 7bc51ef973..559711787b 100644 --- a/api/package.json +++ b/api/package.json @@ -43,8 +43,8 @@ "emoji-regex": "^6.1.1", "express": "^4.16.4", "express-enforces-ssl": "^1.1.0", + "express-hot-shots": "^1.0.2", "express-session": "^1.15.2", - "express-statsd": "^0.3.0", "faker": "^4.1.0", "find-with-regex": "^1.1.3", "flow-typed": "^2.5.1", diff --git a/api/yarn.lock b/api/yarn.lock index f80fc29bf2..4e5820b7b7 100644 --- a/api/yarn.lock +++ b/api/yarn.lock @@ -4032,6 +4032,14 @@ express-enforces-ssl@^1.1.0: resolved "https://registry.yarnpkg.com/express-enforces-ssl/-/express-enforces-ssl-1.1.0.tgz#cf29c6a61c5bdd802e2c7ed265a4a98e7487d1ac" integrity sha1-zynGphxb3YAuLH7SZaSpjnSH0aw= +express-hot-shots@^1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/express-hot-shots/-/express-hot-shots-1.0.2.tgz#570c2d5f7c18b6e2c6d3fb48a0736e92af5ddc1d" + integrity sha512-EW/HoBhpTSaO0QCwcIHSQ2M39ugKr/l2jtH4+qRSCbFAc31qLsOlFt5TGXIGUmMyyb1ffv0kiFHDbaWCd21kzA== + dependencies: + hot-shots "^5.9.2" + obj-extend "~0.1.0" + express-session@^1.15.2: version "1.15.6" resolved "https://registry.yarnpkg.com/express-session/-/express-session-1.15.6.tgz#47b4160c88f42ab70fe8a508e31cbff76757ab0a" @@ -4047,14 +4055,6 @@ express-session@^1.15.2: uid-safe "~2.1.5" utils-merge "1.0.1" -express-statsd@^0.3.0: - version "0.3.0" - resolved "https://registry.yarnpkg.com/express-statsd/-/express-statsd-0.3.0.tgz#cb60b8e4f633adc7eaaefb5819698b469c00b1bd" - integrity sha1-y2C45PYzrcfqrvtYGWmLRpwAsb0= - dependencies: - lynx "~0.0.11" - obj-extend "~0.1.0" - express@^4.16.4: version "4.16.4" resolved "https://registry.yarnpkg.com/express/-/express-4.16.4.tgz#fddef61926109e24c515ea97fd2f1bdbf62df12e" @@ -6427,14 +6427,6 @@ lru-cache@^5.0.0: dependencies: yallist "^3.0.2" -lynx@~0.0.11: - version "0.0.11" - resolved "https://registry.yarnpkg.com/lynx/-/lynx-0.0.11.tgz#2cfa14e443fd2d92a59b779f41567ce1cc6965a3" - integrity sha1-LPoU5EP9LZKlm3efQVZ84cxpZaM= - dependencies: - mersenne "~0.0.3" - statsd-parser "~0.0.4" - macos-release@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/macos-release/-/macos-release-2.0.0.tgz#7dddf4caf79001a851eb4fba7fb6034f251276ab" @@ -6557,11 +6549,6 @@ mersenne-twister@^1.0.1: resolved "https://registry.yarnpkg.com/mersenne-twister/-/mersenne-twister-1.1.0.tgz#f916618ee43d7179efcf641bec4531eb9670978a" integrity sha1-+RZhjuQ9cXnvz2Qb7EUx65Zwl4o= -mersenne@~0.0.3: - version "0.0.4" - resolved "https://registry.yarnpkg.com/mersenne/-/mersenne-0.0.4.tgz#401fdec7ec21cdb9e03cd3d3021398da21b27085" - integrity sha1-QB/ex+whzbngPNPTAhOY2iGycIU= - methods@~1.1.2: version "1.1.2" resolved "https://registry.yarnpkg.com/methods/-/methods-1.1.2.tgz#5529a4d67654134edcc5266656835b0f851afcee" @@ -8857,11 +8844,6 @@ static-extend@^0.1.1: define-property "^0.2.5" object-copy "^0.1.0" -statsd-parser@~0.0.4: - version "0.0.4" - resolved "https://registry.yarnpkg.com/statsd-parser/-/statsd-parser-0.0.4.tgz#cbd243953cc42effd548b5d22388ed689ec639bd" - integrity sha1-y9JDlTzELv/VSLXSI4jtaJ7GOb0= - "statuses@>= 1.4.0 < 2": version "1.5.0" resolved "https://registry.yarnpkg.com/statuses/-/statuses-1.5.0.tgz#161c7dac177659fd9811f43771fa99381478628c" diff --git a/flow-typed/npm/express-hot-shots_vx.x.x.js b/flow-typed/npm/express-hot-shots_vx.x.x.js new file mode 100644 index 0000000000..0e866fd66a --- /dev/null +++ b/flow-typed/npm/express-hot-shots_vx.x.x.js @@ -0,0 +1,53 @@ +// flow-typed signature: 1cdaa5e3b96efaeacdd3cbc4b45b40d3 +// flow-typed version: <>/express-hot-shots_vx.x.x/flow_v0.66.0 + +/** + * This is an autogenerated libdef stub for: + * + * 'express-hot-shots' + * + * Fill this stub out by replacing all the `any` types. + * + * Once filled out, we encourage you to share your work with the + * community by sending a pull request to: + * https://github.com/flowtype/flow-typed + */ + +declare module 'express-hot-shots' { + declare module.exports: any; +} + +/** + * We include stubs for each file inside this npm package in case you need to + * require those files directly. Feel free to delete any files that aren't + * needed. + */ +declare module 'express-hot-shots/Gruntfile' { + declare module.exports: any; +} + +declare module 'express-hot-shots/lib/express-hot-shots' { + declare module.exports: any; +} + +declare module 'express-hot-shots/test/express-hot-shots' { + declare module.exports: any; +} + +declare module 'express-hot-shots/test/utils' { + declare module.exports: any; +} + +// Filename aliases +declare module 'express-hot-shots/Gruntfile.js' { + declare module.exports: $Exports<'express-hot-shots/Gruntfile'>; +} +declare module 'express-hot-shots/lib/express-hot-shots.js' { + declare module.exports: $Exports<'express-hot-shots/lib/express-hot-shots'>; +} +declare module 'express-hot-shots/test/express-hot-shots.js' { + declare module.exports: $Exports<'express-hot-shots/test/express-hot-shots'>; +} +declare module 'express-hot-shots/test/utils.js' { + declare module.exports: $Exports<'express-hot-shots/test/utils'>; +} diff --git a/flow-typed/npm/express-statsd_vx.x.x.js b/flow-typed/npm/express-statsd_vx.x.x.js deleted file mode 100644 index 3d3fb7fcb9..0000000000 --- a/flow-typed/npm/express-statsd_vx.x.x.js +++ /dev/null @@ -1,53 +0,0 @@ -// flow-typed signature: 1cdaa5e3b96efaeacdd3cbc4b45b40d3 -// flow-typed version: <>/express-statsd_vx.x.x/flow_v0.66.0 - -/** - * This is an autogenerated libdef stub for: - * - * 'express-statsd' - * - * Fill this stub out by replacing all the `any` types. - * - * Once filled out, we encourage you to share your work with the - * community by sending a pull request to: - * https://github.com/flowtype/flow-typed - */ - -declare module 'express-statsd' { - declare module.exports: any; -} - -/** - * We include stubs for each file inside this npm package in case you need to - * require those files directly. Feel free to delete any files that aren't - * needed. - */ -declare module 'express-statsd/Gruntfile' { - declare module.exports: any; -} - -declare module 'express-statsd/lib/express-statsd' { - declare module.exports: any; -} - -declare module 'express-statsd/test/express-statsd' { - declare module.exports: any; -} - -declare module 'express-statsd/test/utils' { - declare module.exports: any; -} - -// Filename aliases -declare module 'express-statsd/Gruntfile.js' { - declare module.exports: $Exports<'express-statsd/Gruntfile'>; -} -declare module 'express-statsd/lib/express-statsd.js' { - declare module.exports: $Exports<'express-statsd/lib/express-statsd'>; -} -declare module 'express-statsd/test/express-statsd.js' { - declare module.exports: $Exports<'express-statsd/test/express-statsd'>; -} -declare module 'express-statsd/test/utils.js' { - declare module.exports: $Exports<'express-statsd/test/utils'>; -} diff --git a/package.json b/package.json index 90ee5534f8..8ddac7d978 100644 --- a/package.json +++ b/package.json @@ -100,8 +100,8 @@ "expo-server-sdk": "^2.4.0", "express": "^4.16.4", "express-enforces-ssl": "^1.1.0", + "express-hot-shots": "^1.0.2", "express-session": "^1.15.2", - "express-statsd": "^0.3.0", "faker": "^4.1.0", "find-with-regex": "^1.0.2", "flow-typed": "^2.5.1", diff --git a/shared/middlewares/statsd.js b/shared/middlewares/statsd.js index cdf1f0b86e..ee9f83ef2b 100644 --- a/shared/middlewares/statsd.js +++ b/shared/middlewares/statsd.js @@ -1,5 +1,5 @@ // @flow -import statsdMiddleware from 'express-statsd'; +import statsdMiddleware from 'express-hot-shots'; import { statsd } from '../statsd'; const middleware = statsdMiddleware({ diff --git a/shared/statsd.js b/shared/statsd.js index 7133e02059..1a61fae94d 100644 --- a/shared/statsd.js +++ b/shared/statsd.js @@ -4,7 +4,9 @@ import StatsD from 'hot-shots'; export const statsd = new StatsD({ mock: process.env.NODE_ENV !== 'production', - prefix: `${process.env.SENTRY_NAME || 'server'}.`, + globalTags: { + server: process.env.SENTRY_NAME || 'unknown_server', + }, }); statsd.socket.on('error', function(error) { diff --git a/yarn.lock b/yarn.lock index 082c0c7c88..78f61b91a2 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6303,6 +6303,14 @@ express-enforces-ssl@^1.1.0: resolved "https://registry.yarnpkg.com/express-enforces-ssl/-/express-enforces-ssl-1.1.0.tgz#cf29c6a61c5bdd802e2c7ed265a4a98e7487d1ac" integrity sha1-zynGphxb3YAuLH7SZaSpjnSH0aw= +express-hot-shots@^1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/express-hot-shots/-/express-hot-shots-1.0.2.tgz#570c2d5f7c18b6e2c6d3fb48a0736e92af5ddc1d" + integrity sha512-EW/HoBhpTSaO0QCwcIHSQ2M39ugKr/l2jtH4+qRSCbFAc31qLsOlFt5TGXIGUmMyyb1ffv0kiFHDbaWCd21kzA== + dependencies: + hot-shots "^5.9.2" + obj-extend "~0.1.0" + express-session@^1.15.2: version "1.15.6" resolved "https://registry.yarnpkg.com/express-session/-/express-session-1.15.6.tgz#47b4160c88f42ab70fe8a508e31cbff76757ab0a" @@ -6318,14 +6326,6 @@ express-session@^1.15.2: uid-safe "~2.1.5" utils-merge "1.0.1" -express-statsd@^0.3.0: - version "0.3.0" - resolved "https://registry.yarnpkg.com/express-statsd/-/express-statsd-0.3.0.tgz#cb60b8e4f633adc7eaaefb5819698b469c00b1bd" - integrity sha1-y2C45PYzrcfqrvtYGWmLRpwAsb0= - dependencies: - lynx "~0.0.11" - obj-extend "~0.1.0" - express@^4.16.2, express@^4.16.4: version "4.16.4" resolved "https://registry.yarnpkg.com/express/-/express-4.16.4.tgz#fddef61926109e24c515ea97fd2f1bdbf62df12e" @@ -9676,14 +9676,6 @@ lru-cache@^5.0.0: dependencies: yallist "^3.0.2" -lynx@~0.0.11: - version "0.0.11" - resolved "https://registry.yarnpkg.com/lynx/-/lynx-0.0.11.tgz#2cfa14e443fd2d92a59b779f41567ce1cc6965a3" - integrity sha1-LPoU5EP9LZKlm3efQVZ84cxpZaM= - dependencies: - mersenne "~0.0.3" - statsd-parser "~0.0.4" - macos-release@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/macos-release/-/macos-release-2.0.0.tgz#7dddf4caf79001a851eb4fba7fb6034f251276ab" @@ -9848,11 +9840,6 @@ mersenne-twister@^1.0.1: resolved "https://registry.yarnpkg.com/mersenne-twister/-/mersenne-twister-1.1.0.tgz#f916618ee43d7179efcf641bec4531eb9670978a" integrity sha1-+RZhjuQ9cXnvz2Qb7EUx65Zwl4o= -mersenne@~0.0.3: - version "0.0.4" - resolved "https://registry.yarnpkg.com/mersenne/-/mersenne-0.0.4.tgz#401fdec7ec21cdb9e03cd3d3021398da21b27085" - integrity sha1-QB/ex+whzbngPNPTAhOY2iGycIU= - methods@^1.1.1, methods@~1.1.2: version "1.1.2" resolved "https://registry.yarnpkg.com/methods/-/methods-1.1.2.tgz#5529a4d67654134edcc5266656835b0f851afcee" @@ -13463,11 +13450,6 @@ static-extend@^0.1.1: define-property "^0.2.5" object-copy "^0.1.0" -statsd-parser@~0.0.4: - version "0.0.4" - resolved "https://registry.yarnpkg.com/statsd-parser/-/statsd-parser-0.0.4.tgz#cbd243953cc42effd548b5d22388ed689ec639bd" - integrity sha1-y9JDlTzELv/VSLXSI4jtaJ7GOb0= - "statuses@>= 1.4.0 < 2": version "1.5.0" resolved "https://registry.yarnpkg.com/statuses/-/statuses-1.5.0.tgz#161c7dac177659fd9811f43771fa99381478628c" From 5fa512cbe95e11b0a7de6c66d799cf827f573684 Mon Sep 17 00:00:00 2001 From: Max Stoiber Date: Tue, 11 Dec 2018 12:54:32 +0100 Subject: [PATCH 08/37] Switch to tagging the GraphQL operation name in StatsD --- api/apollo-server.js | 7 ++++--- shared/middlewares/statsd.js | 5 ++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/api/apollo-server.js b/api/apollo-server.js index 52a9b91db7..9e9c700c8e 100644 --- a/api/apollo-server.js +++ b/api/apollo-server.js @@ -51,9 +51,10 @@ const server = new ProtectedApolloServer({ }; } - // Override the default req.statsdKey with GraphQL info - req.statsdKey = `http.post.api.${req.body.operationName || - 'unnamed_query'}`; + // Add GraphQL operation information to the statsd tags + req.statsdTags = { + graphqlOperationName: req.body.operationName || 'unknown_operation', + }; const loaders = createLoaders(); let currentUser = req.user && !req.user.bannedAt ? req.user : null; diff --git a/shared/middlewares/statsd.js b/shared/middlewares/statsd.js index ee9f83ef2b..3fea777f31 100644 --- a/shared/middlewares/statsd.js +++ b/shared/middlewares/statsd.js @@ -15,8 +15,7 @@ export default ( // hyperion.http.get.spectrum.general const pathname = req.path.replace(/\?.*/, ''); // $FlowFixMe - req.statsdKey = `http.${req.method.toLowerCase()}${pathname - .toLowerCase() - .replace('/', '.')}`; + req.statsdKey = `http.${req.method.toLowerCase() || + 'unknown_method'}${pathname.toLowerCase().replace('/', '.')}`; return middleware(req, res, next); }; From 820d86fd9055cb8e40569d4009f1f32fb7e81955 Mon Sep 17 00:00:00 2001 From: Max Stoiber Date: Tue, 11 Dec 2018 13:02:08 +0100 Subject: [PATCH 09/37] More consistent naming for db metrics --- shared/db/db.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/shared/db/db.js b/shared/db/db.js index 0ef90be352..02e8b5e148 100644 --- a/shared/db/db.js +++ b/shared/db/db.js @@ -53,12 +53,12 @@ var r = require('rethinkhaberdashery')(config); const poolMaster = r.getPoolMaster(); -poolMaster.on('queueing', length => { - statsd.gauge('db.query_queue_length', length); +poolMaster.on('queueing', size => { + statsd.gauge('db.query_queue.size', size); }); poolMaster.on('size', connections => { - statsd.gauge('db.connection_count', connections); + statsd.gauge('db.connection_pool.size', connections); }); // Exit the process on unhealthy db in test env From f8525c38a8f06f48e432e246a5e7b635cc7def70 Mon Sep 17 00:00:00 2001 From: "depfu[bot]" Date: Tue, 18 Dec 2018 10:55:28 +0000 Subject: [PATCH 10/37] Update babel-plugin-styled-components to version 1.10.0 --- api/package.json | 2 +- api/yarn.lock | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/api/package.json b/api/package.json index 2791dfb2fc..b767c8c05e 100644 --- a/api/package.json +++ b/api/package.json @@ -11,7 +11,7 @@ "axios": "^0.16.2", "b2a": "^1.0.10", "babel-plugin-replace-dynamic-import-runtime": "^1.0.2", - "babel-plugin-styled-components": "^1.9.4", + "babel-plugin-styled-components": "^1.10.0", "babel-plugin-transform-flow-strip-types": "^6.22.0", "babel-plugin-transform-object-rest-spread": "^6.23.0", "babel-preset-env": "^1.7.0", diff --git a/api/yarn.lock b/api/yarn.lock index b76b33d700..308a62e018 100644 --- a/api/yarn.lock +++ b/api/yarn.lock @@ -1710,12 +1710,13 @@ babel-plugin-styled-components@^1.1.4: babel-plugin-syntax-jsx "^6.18.0" lodash "^4.17.10" -babel-plugin-styled-components@^1.9.4: - version "1.9.4" - resolved "https://registry.yarnpkg.com/babel-plugin-styled-components/-/babel-plugin-styled-components-1.9.4.tgz#5f2c34d31237c6ee1e86453cc5fa488b97136669" - integrity sha512-FIACAvgJsUasYA+CdhPMWUIXWCdUUirz7fL9FGQYNNuOls+bs9OUWWHYVM2W9gjVoS2TXdEMqcOVVyG3Hagd/g== +babel-plugin-styled-components@^1.10.0: + version "1.10.0" + resolved "https://registry.yarnpkg.com/babel-plugin-styled-components/-/babel-plugin-styled-components-1.10.0.tgz#ff1f42ad2cc78c21f26b62266b8f564dbc862939" + integrity sha512-sQVKG8irFXx14ZfaK1bBePirfkacl3j8nZwSZK+ZjsbnadRHKQTbhXbe/RB1vT6Vgkz45E+V95LBq4KqdhZUNw== dependencies: "@babel/helper-annotate-as-pure" "^7.0.0" + "@babel/helper-module-imports" "^7.0.0" babel-plugin-syntax-jsx "^6.18.0" lodash "^4.17.10" From f330c2fbef4519275ff3ddf4f16043186f940829 Mon Sep 17 00:00:00 2001 From: Max Stoiber Date: Tue, 18 Dec 2018 15:02:02 +0100 Subject: [PATCH 11/37] Switch to datadog-metrics package --- api/package.json | 1 + api/yarn.lock | 32 +++++++++++++++++++++++++- now.json | 2 +- package.json | 3 ++- shared/statsd.js | 59 +++++++++++++++++++++++++++++++----------------- yarn.lock | 32 +++++++++++++++++++++++++- 6 files changed, 104 insertions(+), 25 deletions(-) diff --git a/api/package.json b/api/package.json index 559711787b..e1fe093d03 100644 --- a/api/package.json +++ b/api/package.json @@ -25,6 +25,7 @@ "cookie-session": "^2.0.0-beta.3", "cors": "^2.8.5", "cryptr": "^3.0.0", + "datadog-metrics": "^0.8.1", "dataloader": "^1.4.0", "debounce": "^1.2.0", "debug": "^4.1.0", diff --git a/api/yarn.lock b/api/yarn.lock index 4e5820b7b7..edf920383e 100644 --- a/api/yarn.lock +++ b/api/yarn.lock @@ -2328,6 +2328,11 @@ big.js@^3.1.3: resolved "https://registry.yarnpkg.com/big.js/-/big.js-3.2.0.tgz#a5fc298b81b9e0dca2e458824784b65c52ba588e" integrity sha512-+hN/Zh2D08Mx65pZ/4g5bsmNiZUuChDiQfTUQ7qJr4/kuopCr88xZsAXv6mBoZEsUI4OuGHlX59qE94K2mMW8Q== +bignumber.js@~1.1.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/bignumber.js/-/bignumber.js-1.1.1.tgz#1a415d9ac014c13256af1feed9d1a3e5717a8cf7" + integrity sha1-GkFdmsAUwTJWrx/u2dGj5XF6jPc= + binary-extensions@^1.0.0: version "1.12.0" resolved "https://registry.yarnpkg.com/binary-extensions/-/binary-extensions-1.12.0.tgz#c2d780f53d45bba8317a8902d4ceeaf3a6385b14" @@ -3243,6 +3248,14 @@ dasherize@2.0.0: resolved "https://registry.yarnpkg.com/dasherize/-/dasherize-2.0.0.tgz#6d809c9cd0cf7bb8952d80fc84fa13d47ddb1308" integrity sha1-bYCcnNDPe7iVLYD8hPoT1H3bEwg= +datadog-metrics@^0.8.1: + version "0.8.1" + resolved "https://registry.yarnpkg.com/datadog-metrics/-/datadog-metrics-0.8.1.tgz#be87237109a7084193c668d80112533ef00e3f21" + integrity sha512-qTSKnddO6GxTJW9FYpmWjvvift3qfyMurDjwNjJnJhBk76pBdDhC0B5V9V+XwPdn4r42qu48kwXNuHJslXlDOA== + dependencies: + debug "3.1.0" + dogapi "1.1.0" + dataloader@^1.4.0: version "1.4.0" resolved "https://registry.yarnpkg.com/dataloader/-/dataloader-1.4.0.tgz#bca11d867f5d3f1b9ed9f737bd15970c65dff5c8" @@ -3480,6 +3493,16 @@ dns-prefetch-control@0.1.0: resolved "https://registry.yarnpkg.com/dns-prefetch-control/-/dns-prefetch-control-0.1.0.tgz#60ddb457774e178f1f9415f0cabb0e85b0b300b2" integrity sha1-YN20V3dOF48flBXwyrsOhbCzALI= +dogapi@1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/dogapi/-/dogapi-1.1.0.tgz#71a43865ad4bb4cb18bc3e13cf769971f501030a" + integrity sha1-caQ4Za1LtMsYvD4Tz3aZcfUBAwo= + dependencies: + extend "^3.0.0" + json-bigint "^0.1.4" + minimist "^1.1.1" + rc "^1.0.0" + dom-helpers@^3.3.1: version "3.4.0" resolved "https://registry.yarnpkg.com/dom-helpers/-/dom-helpers-3.4.0.tgz#e9b369700f959f62ecde5a6babde4bccd9169af8" @@ -5958,6 +5981,13 @@ jsesc@~0.5.0: resolved "https://registry.yarnpkg.com/jsesc/-/jsesc-0.5.0.tgz#e7dee66e35d6fc16f710fe91d5cf69f70f08911d" integrity sha1-597mbjXW/Bb3EP6R1c9p9w8IkR0= +json-bigint@^0.1.4: + version "0.1.4" + resolved "https://registry.yarnpkg.com/json-bigint/-/json-bigint-0.1.4.tgz#b5d40b8a9009e92f157f7c079db097001830e01e" + integrity sha1-tdQLipAJ6S8Vf3wHnbCXABgw4B4= + dependencies: + bignumber.js "~1.1.1" + json-loader@^0.5.7: version "0.5.7" resolved "https://registry.yarnpkg.com/json-loader/-/json-loader-0.5.7.tgz#dca14a70235ff82f0ac9a3abeb60d337a365185d" @@ -7774,7 +7804,7 @@ raw-body@2.3.3: iconv-lite "0.4.23" unpipe "1.0.0" -rc@^1.0.1, rc@^1.1.6, rc@^1.2.7: +rc@^1.0.0, rc@^1.0.1, rc@^1.1.6, rc@^1.2.7: version "1.2.8" resolved "https://registry.yarnpkg.com/rc/-/rc-1.2.8.tgz#cd924bf5200a075b83c188cd6b9e211b7fc0d3ed" integrity sha512-y3bGgqKj3QBdxLbLkomlohkvsA8gdAiUQlSBJnBhfn+BPxg4bc62d8TcBW15wavDfgexCgccckhcZvywyQYPOw== diff --git a/now.json b/now.json index 042264f766..f167581368 100644 --- a/now.json +++ b/now.json @@ -47,7 +47,7 @@ "API_TOKEN_SECRET": "@api-token-secret", "SENTRY_DSN_CLIENT": "@sentry-dsn-client", "SENTRY_DSN_SERVER": "@sentry-dsn-server", - + "DATADOG_API_KEY": "@datadog-api-key", "AMPLITUDE_API_KEY": "@amplitude-api-key", "AMPLITUDE_API_KEY_DEVELOPMENT": "@amplitude-api-key-development", "ENCRYPTION_KEY": "@encryption-key", diff --git a/package.json b/package.json index 8ddac7d978..6fc334d6aa 100644 --- a/package.json +++ b/package.json @@ -78,6 +78,7 @@ "cryptr": "^3.0.0", "css.escape": "^1.5.1", "cypress": "^3.1.3", + "datadog-metrics": "^0.8.1", "dataloader": "^1.3.0", "debounce": "^1.2.0", "debug": "^4.1.0", @@ -214,7 +215,7 @@ "start:analytics": "cross-env NODE_ENV=production node build-analytics/main.js", "start:api": "cross-env NODE_ENV=production node build-api/main.js", "dev:web": "cross-env NODE_PATH=./ react-app-rewired start", - "dev:api": "cross-env FILE_STORAGE=local cross-env NODE_PATH=./ cross-env NODE_ENV=development cross-env DEBUG=build*,api*,shared:middlewares*,shared:rethinkdb:db-query-cache,-api:resolvers cross-env DIR=api backpack", + "dev:api": "cross-env FILE_STORAGE=local cross-env NODE_PATH=./ cross-env NODE_ENV=development cross-env DEBUG=build*,api*,metrics*,shared:middlewares*,shared:rethinkdb:db-query-cache,-api:resolvers cross-env DIR=api backpack", "dev:api:s3": "cross-env FILE_STORAGE=s3 cross-env NODE_PATH=./ cross-env NODE_ENV=development cross-env DEBUG=build*,api*,shared:middlewares*,shared:rethinkdb:db-query-cache,-api:resolvers cross-env DIR=api backpack", "dev:athena": "cross-env NODE_PATH=./ cross-env NODE_ENV=development cross-env DEBUG=build*,athena*,shared:middlewares*,-athena:resolvers cross-env DIR=athena backpack", "dev:hermes": "cross-env NODE_PATH=./ cross-env NODE_ENV=development cross-env DEBUG=build*,hermes*,shared:middlewares*,-hermes:resolvers cross-env DIR=hermes backpack", diff --git a/shared/statsd.js b/shared/statsd.js index 1a61fae94d..57b78ef8e0 100644 --- a/shared/statsd.js +++ b/shared/statsd.js @@ -1,27 +1,44 @@ // @flow const debug = require('debug')('shared:middlewares:statsd'); -import StatsD from 'hot-shots'; +import metrics from 'datadog-metrics'; -export const statsd = new StatsD({ - mock: process.env.NODE_ENV !== 'production', - globalTags: { - server: process.env.SENTRY_NAME || 'unknown_server', - }, -}); - -statsd.socket.on('error', function(error) { - console.error('Error in socket: ', error); -}); +export let statsd; +if (!process.env.DATADOG_API_KEY) { + console.warn('No DATADOG_API_KEY provided, not tracking metrics.'); + statsd = { + histogram: () => {}, + timing: () => {}, + increment: () => {}, + gauge: () => {}, + }; +} else { + metrics.init({ + defaultTags: [`server:${process.env.SENTRY_NAME || 'unknown_server'}`], + }); -// Log StatsD events in development by monkey-patching the internal _send method -// because hot-shots does not expose a way to listen to events as they happen -if (debug.enabled) { - const originalSend = statsd._send; - statsd._send = (...args) => { - statsd.mockBuffer.forEach(item => { - debug(item); - }); - statsd.mockBuffer = []; - return originalSend.call(statsd, ...args); + const stringify = (obj?: { [key: string]: string }) => { + if (!obj) return obj; + return Object.keys(obj).reduce((arr, key) => { + return arr.concat([`${key}:${obj[key]}`]); + }, []); }; + // This is necessary for express-hot-shots to work + const handleObjectTags = method => { + const original = metrics[method]; + metrics[method] = (key, val, tags, timestamp) => { + return original.call( + metrics, + key, + val, + Array.isArray(tags) ? tags : stringify(tags), + timestamp + ); + }; + }; + handleObjectTags('histogram'); + handleObjectTags('gauge'); + handleObjectTags('increment'); + metrics.timing = (...args) => metrics.histogram.call(metrics, ...args); + + statsd = metrics; } diff --git a/yarn.lock b/yarn.lock index 78f61b91a2..9c2cb889fb 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3108,6 +3108,11 @@ big.js@^3.1.3: resolved "https://registry.yarnpkg.com/big.js/-/big.js-3.2.0.tgz#a5fc298b81b9e0dca2e458824784b65c52ba588e" integrity sha512-+hN/Zh2D08Mx65pZ/4g5bsmNiZUuChDiQfTUQ7qJr4/kuopCr88xZsAXv6mBoZEsUI4OuGHlX59qE94K2mMW8Q== +bignumber.js@~1.1.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/bignumber.js/-/bignumber.js-1.1.1.tgz#1a415d9ac014c13256af1feed9d1a3e5717a8cf7" + integrity sha1-GkFdmsAUwTJWrx/u2dGj5XF6jPc= + binary-extensions@^1.0.0: version "1.12.0" resolved "https://registry.yarnpkg.com/binary-extensions/-/binary-extensions-1.12.0.tgz#c2d780f53d45bba8317a8902d4ceeaf3a6385b14" @@ -4896,6 +4901,14 @@ data-urls@^1.0.0: whatwg-mimetype "^2.2.0" whatwg-url "^7.0.0" +datadog-metrics@^0.8.1: + version "0.8.1" + resolved "https://registry.yarnpkg.com/datadog-metrics/-/datadog-metrics-0.8.1.tgz#be87237109a7084193c668d80112533ef00e3f21" + integrity sha512-qTSKnddO6GxTJW9FYpmWjvvift3qfyMurDjwNjJnJhBk76pBdDhC0B5V9V+XwPdn4r42qu48kwXNuHJslXlDOA== + dependencies: + debug "3.1.0" + dogapi "1.1.0" + dataloader@^1.3.0: version "1.4.0" resolved "https://registry.yarnpkg.com/dataloader/-/dataloader-1.4.0.tgz#bca11d867f5d3f1b9ed9f737bd15970c65dff5c8" @@ -5275,6 +5288,16 @@ doctrine@^2.0.0, doctrine@^2.1.0: dependencies: esutils "^2.0.2" +dogapi@1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/dogapi/-/dogapi-1.1.0.tgz#71a43865ad4bb4cb18bc3e13cf769971f501030a" + integrity sha1-caQ4Za1LtMsYvD4Tz3aZcfUBAwo= + dependencies: + extend "^3.0.0" + json-bigint "^0.1.4" + minimist "^1.1.1" + rc "^1.0.0" + dom-converter@~0.2: version "0.2.0" resolved "https://registry.yarnpkg.com/dom-converter/-/dom-converter-0.2.0.tgz#6721a9daee2e293682955b6afe416771627bb768" @@ -8949,6 +8972,13 @@ jsesc@~0.5.0: resolved "https://registry.yarnpkg.com/jsesc/-/jsesc-0.5.0.tgz#e7dee66e35d6fc16f710fe91d5cf69f70f08911d" integrity sha1-597mbjXW/Bb3EP6R1c9p9w8IkR0= +json-bigint@^0.1.4: + version "0.1.4" + resolved "https://registry.yarnpkg.com/json-bigint/-/json-bigint-0.1.4.tgz#b5d40b8a9009e92f157f7c079db097001830e01e" + integrity sha1-tdQLipAJ6S8Vf3wHnbCXABgw4B4= + dependencies: + bignumber.js "~1.1.1" + json-loader@^0.5.4: version "0.5.7" resolved "https://registry.yarnpkg.com/json-loader/-/json-loader-0.5.7.tgz#dca14a70235ff82f0ac9a3abeb60d337a365185d" @@ -11818,7 +11848,7 @@ raw-loader@^0.5.1: resolved "https://registry.yarnpkg.com/raw-loader/-/raw-loader-0.5.1.tgz#0c3d0beaed8a01c966d9787bf778281252a979aa" integrity sha1-DD0L6u2KAclm2Xh793goElKpeao= -rc@^1.0.1, rc@^1.1.6, rc@^1.2.7: +rc@^1.0.0, rc@^1.0.1, rc@^1.1.6, rc@^1.2.7: version "1.2.8" resolved "https://registry.yarnpkg.com/rc/-/rc-1.2.8.tgz#cd924bf5200a075b83c188cd6b9e211b7fc0d3ed" integrity sha512-y3bGgqKj3QBdxLbLkomlohkvsA8gdAiUQlSBJnBhfn+BPxg4bc62d8TcBW15wavDfgexCgccckhcZvywyQYPOw== From 8b3e2cbf8262ea6c22f1c7982e8e099c8e6895a6 Mon Sep 17 00:00:00 2001 From: REDDY PRASAD Date: Tue, 18 Dec 2018 19:51:44 +0530 Subject: [PATCH 12/37] Disable GraphQL playground in production --- api/apollo-server.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/api/apollo-server.js b/api/apollo-server.js index ea1daf51bc..85975323db 100644 --- a/api/apollo-server.js +++ b/api/apollo-server.js @@ -93,7 +93,7 @@ const server = new ProtectedApolloServer({ }; }), }, - playground: { + playground: process.env.NODE_ENV !== 'production' && { settings: { 'editor.theme': 'light', }, @@ -109,6 +109,7 @@ const server = new ProtectedApolloServer({ }, ], }, + introspection: process.env.NODE_ENV !== 'production', maxFileSize: 25 * 1024 * 1024, // 25MB engine: false, tracing: false, From 88ae66b83384a89fda1d3e77fba5fcabb1e55ac8 Mon Sep 17 00:00:00 2001 From: "depfu[bot]" Date: Tue, 18 Dec 2018 14:55:42 +0000 Subject: [PATCH 13/37] Update algoliasearch to version 3.32.0 --- api/package.json | 2 +- api/yarn.lock | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/api/package.json b/api/package.json index b767c8c05e..815c7337a1 100644 --- a/api/package.json +++ b/api/package.json @@ -3,7 +3,7 @@ "node": "10.7.0" }, "dependencies": { - "algoliasearch": "^3.31.0", + "algoliasearch": "^3.32.0", "apollo-local-query": "^0.3.1", "apollo-server-express": "^2.3.1", "apollo-upload-client": "^9.1.0", diff --git a/api/yarn.lock b/api/yarn.lock index 308a62e018..c366e3121d 100644 --- a/api/yarn.lock +++ b/api/yarn.lock @@ -1014,10 +1014,10 @@ ajv@^6.0.1, ajv@^6.1.0, ajv@^6.5.5: json-schema-traverse "^0.4.1" uri-js "^4.2.2" -algoliasearch@^3.31.0: - version "3.31.0" - resolved "https://registry.yarnpkg.com/algoliasearch/-/algoliasearch-3.31.0.tgz#c4083375ff02538ef50d9ec73e6a72e5e19ed96f" - integrity sha512-RJ3m8bQEitEQvWVfJa8WCTM4B9WSt0D4PPEYoqOga7Q0GAfBOqXTWeFYyDO46o085SWBSBWBInVuKyr5BIFP3A== +algoliasearch@^3.32.0: + version "3.32.0" + resolved "https://registry.yarnpkg.com/algoliasearch/-/algoliasearch-3.32.0.tgz#5818168c26ff921bd0346a919071bac928b747ce" + integrity sha512-C8oQnPTf0wPuyD2jSZwtBAPvz+lHOE7zRIPpgXGBuNt6ZNcC4omsbytG26318rT77a8h4759vmIp6n9p8iw4NA== dependencies: agentkeepalive "^2.2.0" debug "^2.6.8" From 169feaa3368e0f0838a32d8d4c43587ee6c243b5 Mon Sep 17 00:00:00 2001 From: "depfu[bot]" Date: Tue, 18 Dec 2018 15:15:14 +0000 Subject: [PATCH 14/37] Update algoliasearch to version 3.32.0 --- vulcan/package.json | 2 +- vulcan/yarn.lock | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/vulcan/package.json b/vulcan/package.json index 2d884c8456..b0086baddb 100644 --- a/vulcan/package.json +++ b/vulcan/package.json @@ -3,7 +3,7 @@ "start": "NODE_ENV=production node main.js" }, "dependencies": { - "algoliasearch": "^3.31.0", + "algoliasearch": "^3.32.0", "aws-sdk": "^2.373.0", "bull": "^3.5.2", "debug": "^4.1.0", diff --git a/vulcan/yarn.lock b/vulcan/yarn.lock index 8d5a1e42b2..7ebc35f833 100644 --- a/vulcan/yarn.lock +++ b/vulcan/yarn.lock @@ -7,10 +7,10 @@ agentkeepalive@^2.2.0: resolved "https://registry.yarnpkg.com/agentkeepalive/-/agentkeepalive-2.2.0.tgz#c5d1bd4b129008f1163f236f86e5faea2026e2ef" integrity sha1-xdG9SxKQCPEWPyNvhuX66iAm4u8= -algoliasearch@^3.31.0: - version "3.31.0" - resolved "https://registry.yarnpkg.com/algoliasearch/-/algoliasearch-3.31.0.tgz#c4083375ff02538ef50d9ec73e6a72e5e19ed96f" - integrity sha512-RJ3m8bQEitEQvWVfJa8WCTM4B9WSt0D4PPEYoqOga7Q0GAfBOqXTWeFYyDO46o085SWBSBWBInVuKyr5BIFP3A== +algoliasearch@^3.32.0: + version "3.32.0" + resolved "https://registry.yarnpkg.com/algoliasearch/-/algoliasearch-3.32.0.tgz#5818168c26ff921bd0346a919071bac928b747ce" + integrity sha512-C8oQnPTf0wPuyD2jSZwtBAPvz+lHOE7zRIPpgXGBuNt6ZNcC4omsbytG26318rT77a8h4759vmIp6n9p8iw4NA== dependencies: agentkeepalive "^2.2.0" debug "^2.6.8" From 76abdf4e804b22b33ac0a928be9631c775094e21 Mon Sep 17 00:00:00 2001 From: Brian Lovin Date: Tue, 18 Dec 2018 10:25:24 -0800 Subject: [PATCH 15/37] Silence flow for now --- flow-typed/npm/datadog-metrics_vx.x.x.js | 59 ++++++++++++++++++++++++ shared/db/db.js | 2 + shared/statsd.js | 1 + 3 files changed, 62 insertions(+) create mode 100644 flow-typed/npm/datadog-metrics_vx.x.x.js diff --git a/flow-typed/npm/datadog-metrics_vx.x.x.js b/flow-typed/npm/datadog-metrics_vx.x.x.js new file mode 100644 index 0000000000..1bbb2fa429 --- /dev/null +++ b/flow-typed/npm/datadog-metrics_vx.x.x.js @@ -0,0 +1,59 @@ +// flow-typed signature: 4193c068fe558edea2fe8b024db8448c +// flow-typed version: <>/datadog-metrics_v0.8.1/flow_v0.66.0 + +/** + * This is an autogenerated libdef stub for: + * + * 'datadog-metrics' + * + * Fill this stub out by replacing all the `any` types. + * + * Once filled out, we encourage you to share your work with the + * community by sending a pull request to: + * https://github.com/flowtype/flow-typed + */ + +declare module 'datadog-metrics' { + declare module.exports: any; +} + +/** + * We include stubs for each file inside this npm package in case you need to + * require those files directly. Feel free to delete any files that aren't + * needed. + */ +declare module 'datadog-metrics/lib/aggregators' { + declare module.exports: any; +} + +declare module 'datadog-metrics/lib/loggers' { + declare module.exports: any; +} + +declare module 'datadog-metrics/lib/metrics' { + declare module.exports: any; +} + +declare module 'datadog-metrics/lib/reporters' { + declare module.exports: any; +} + +// Filename aliases +declare module 'datadog-metrics/index' { + declare module.exports: $Exports<'datadog-metrics'>; +} +declare module 'datadog-metrics/index.js' { + declare module.exports: $Exports<'datadog-metrics'>; +} +declare module 'datadog-metrics/lib/aggregators.js' { + declare module.exports: $Exports<'datadog-metrics/lib/aggregators'>; +} +declare module 'datadog-metrics/lib/loggers.js' { + declare module.exports: $Exports<'datadog-metrics/lib/loggers'>; +} +declare module 'datadog-metrics/lib/metrics.js' { + declare module.exports: $Exports<'datadog-metrics/lib/metrics'>; +} +declare module 'datadog-metrics/lib/reporters.js' { + declare module.exports: $Exports<'datadog-metrics/lib/reporters'>; +} diff --git a/shared/db/db.js b/shared/db/db.js index 61b69290ff..0e39c5acf7 100644 --- a/shared/db/db.js +++ b/shared/db/db.js @@ -55,10 +55,12 @@ var r = require('rethinkhaberdashery')(config); const poolMaster = r.getPoolMaster(); poolMaster.on('queueing', size => { + // $FlowFixMe statsd.gauge('db.query_queue.size', size); }); poolMaster.on('size', connections => { + // $FlowFixMe statsd.gauge('db.connection_pool.size', connections); }); diff --git a/shared/statsd.js b/shared/statsd.js index 57b78ef8e0..a890e9969c 100644 --- a/shared/statsd.js +++ b/shared/statsd.js @@ -16,6 +16,7 @@ if (!process.env.DATADOG_API_KEY) { defaultTags: [`server:${process.env.SENTRY_NAME || 'unknown_server'}`], }); + // $FlowFixMe const stringify = (obj?: { [key: string]: string }) => { if (!obj) return obj; return Object.keys(obj).reduce((arr, key) => { From 88d4136fd765ef7075f5e85ca29231860b2107ca Mon Sep 17 00:00:00 2001 From: Brian Lovin Date: Tue, 18 Dec 2018 10:29:20 -0800 Subject: [PATCH 16/37] Reenable toobusy --- shared/middlewares/toobusy.js | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/shared/middlewares/toobusy.js b/shared/middlewares/toobusy.js index 8424d786c0..243de242db 100644 --- a/shared/middlewares/toobusy.js +++ b/shared/middlewares/toobusy.js @@ -8,14 +8,13 @@ export default ( res: express$Response | http$ServerResponse, next: express$NextFunction | (() => void) ) => { - next(); // // Don't send 503s in testing, that's dumb, just wait it out - // if (process.env.NODE_ENV !== 'testing' && !process.env.TEST_DB && toobusy()) { - // res.statusCode = 503; - // res.end( - // 'It looks like Spectrum is very busy right now, please try again in a minute.' - // ); - // } else { - // next(); - // } + if (process.env.NODE_ENV !== 'testing' && !process.env.TEST_DB && toobusy()) { + res.statusCode = 503; + res.end( + 'It looks like Spectrum is very busy right now, please try again in a minute.' + ); + } else { + next(); + } }; From 7b7f439efc11f6b587848d1bc0f60fd8cb836f4c Mon Sep 17 00:00:00 2001 From: Brian Lovin Date: Tue, 18 Dec 2018 10:56:07 -0800 Subject: [PATCH 17/37] Remove trailing comma in now json --- now.json | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/now.json b/now.json index 181d1038e2..17c8cbb4ff 100644 --- a/now.json +++ b/now.json @@ -51,6 +51,5 @@ "ENCRYPTION_KEY": "@encryption-key", "IMGIX_PROXY_SECURITY_KEY": "@imgix-proxy-security-key", "IMGIX_SECURITY_KEY": "@imgix-security-key", - "DATADOG_API_KEY": "@datadog-api-key", - } -} \ No newline at end of file + "DATADOG_API_KEY": "@datadog-api-key" + } \ No newline at end of file From 503be0b7046dee4682919dc46ceba9b5fd021bc8 Mon Sep 17 00:00:00 2001 From: Brian Lovin Date: Tue, 18 Dec 2018 10:56:13 -0800 Subject: [PATCH 18/37] Add statsd to hyperion --- hyperion/index.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/hyperion/index.js b/hyperion/index.js index fca4d8c7f5..5018b01631 100644 --- a/hyperion/index.js +++ b/hyperion/index.js @@ -5,6 +5,7 @@ debug('Hyperion starting...'); debug('logging with debug enabled'); require('isomorphic-fetch'); // prevent https://github.com/withspectrum/spectrum/issues/3032 import fs from 'fs'; +import statsd from 'shared/middlewares/statsd'; import express from 'express'; import Loadable from 'react-loadable'; import path from 'path'; @@ -20,6 +21,9 @@ const ONE_HOUR = 3600; const app = express(); +// Instantiate the statsd middleware as soon as possible to get accurate time tracking +app.use(statsd); + // Trust the now proxy app.set('trust proxy', true); From f629501b80698578b439fc3b8e18dd5a3271f29c Mon Sep 17 00:00:00 2001 From: Brian Lovin Date: Tue, 18 Dec 2018 10:56:41 -0800 Subject: [PATCH 19/37] Fix missing bracket in now json --- now.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/now.json b/now.json index 17c8cbb4ff..243c5a63ce 100644 --- a/now.json +++ b/now.json @@ -52,4 +52,5 @@ "IMGIX_PROXY_SECURITY_KEY": "@imgix-proxy-security-key", "IMGIX_SECURITY_KEY": "@imgix-security-key", "DATADOG_API_KEY": "@datadog-api-key" - } \ No newline at end of file + } +} \ No newline at end of file From 71043b3770a1eacb7c5e954e01d1d8365e9b44ad Mon Sep 17 00:00:00 2001 From: Brian Lovin Date: Tue, 18 Dec 2018 10:59:27 -0800 Subject: [PATCH 20/37] Fix ordering of bodyparser in hyperion middlewares --- hyperion/index.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/hyperion/index.js b/hyperion/index.js index 5018b01631..aec8ad3df4 100644 --- a/hyperion/index.js +++ b/hyperion/index.js @@ -32,6 +32,9 @@ app.use(toobusy); // Security middleware. addSecurityMiddleware(app, { enableNonce: true, enableCSP: true }); +import bodyParser from 'body-parser'; +app.use(bodyParser.json()); + if (process.env.NODE_ENV === 'development') { const logging = require('shared/middlewares/logging'); app.use(logging); @@ -86,9 +89,6 @@ if (process.env.NODE_ENV === 'development') { import cookieParser from 'cookie-parser'; app.use(cookieParser()); -import bodyParser from 'body-parser'; -app.use(bodyParser.json()); - import session from 'shared/middlewares/session'; app.use(session); From 42d05ac8da7bf352f453bff15ee9627af80ba370 Mon Sep 17 00:00:00 2001 From: Brian Lovin Date: Tue, 18 Dec 2018 10:59:38 -0800 Subject: [PATCH 21/37] Dont let a missing req.body braek logging middleware --- shared/middlewares/logging.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shared/middlewares/logging.js b/shared/middlewares/logging.js index 21a524a98f..05bff05c12 100644 --- a/shared/middlewares/logging.js +++ b/shared/middlewares/logging.js @@ -7,7 +7,7 @@ module.exports = ( res: express$Response, next: express$NextFunction ) => { - if (req.body.operationName) { + if (req.body && req.body.operationName) { debug(`requesting ${req.url}: ${req.body.operationName}`); } else { debug(`requesting ${req.url}`); From 1c6bc92d14ac3c605ce21ed18402fe7dd319f066 Mon Sep 17 00:00:00 2001 From: "depfu[bot]" Date: Tue, 18 Dec 2018 21:25:37 +0000 Subject: [PATCH 22/37] Update electron to version 3.0.13 --- desktop/package.json | 2 +- desktop/yarn.lock | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/desktop/package.json b/desktop/package.json index dd5d4f510c..1d62f81233 100644 --- a/desktop/package.json +++ b/desktop/package.json @@ -18,7 +18,7 @@ "electron-window-state": "^5.0.3" }, "devDependencies": { - "electron": "^3.0.12", + "electron": "^3.0.13", "electron-builder": "^20.38.3", "nodemon": "^1.18.9", "rimraf": "^2.6.2" diff --git a/desktop/yarn.lock b/desktop/yarn.lock index 778946e047..bbf0f6d12e 100644 --- a/desktop/yarn.lock +++ b/desktop/yarn.lock @@ -823,10 +823,10 @@ electron-window-state@^5.0.3: jsonfile "^4.0.0" mkdirp "^0.5.1" -electron@^3.0.12: - version "3.0.12" - resolved "https://registry.yarnpkg.com/electron/-/electron-3.0.12.tgz#7486ff1c60e9c22d8aadaee620695c42c9ddb2ac" - integrity sha512-stvGbqYzWv5qHHtjZZgA7gET3NPGLuxs68IHTrJqsqujQfXGkhMOh8tstpXl86kBdRpzZn7GaDlTWcgeFSmsPw== +electron@^3.0.13: + version "3.0.13" + resolved "https://registry.yarnpkg.com/electron/-/electron-3.0.13.tgz#7b065a3d130c6b6379dc78d49515e03f392c1303" + integrity sha512-tfx5jFgXhCmpe6oPjcesaRj7geHqQxrJdbpseanRzL9BbyYUtsj0HoxwPAUvCx4+52P6XryBwWTvne/1eBVf9Q== dependencies: "@types/node" "^8.0.24" electron-download "^4.1.0" From 5ae798b915b04b67ff709635d826386c1b28b6de Mon Sep 17 00:00:00 2001 From: Brian Lovin Date: Tue, 18 Dec 2018 13:39:35 -0800 Subject: [PATCH 23/37] Set db min and max to the same amount --- shared/db/db.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/shared/db/db.js b/shared/db/db.js index 0e39c5acf7..576ba0c1b9 100644 --- a/shared/db/db.js +++ b/shared/db/db.js @@ -11,8 +11,8 @@ const IS_PROD = !process.env.FORCE_DEV && process.env.NODE_ENV === 'production'; const DEFAULT_CONFIG = { // Connect to the test database when, well, testing db: !process.env.TEST_DB ? 'spectrum' : 'testing', - max: 1000, // Maximum number of connections, default is 1000 - buffer: 50, // Minimum number of connections open at any given moment, default is 50 + max: 20, // Maximum number of connections, default is 1000 + buffer: 20, // Minimum number of connections open at any given moment, default is 50 timeoutGb: 60 * 60 * 1000, // How long should an unused connection stick around, default is an hour, this is a minute timeout: 30, // The number of seconds for a connection to be opened, default 20 }; From 5f9a21015816849484bdd90be1426c6930f3701c Mon Sep 17 00:00:00 2001 From: Brian Lovin Date: Tue, 18 Dec 2018 13:39:41 -0800 Subject: [PATCH 24/37] Add datadog to all workers --- analytics/package.json | 1 + analytics/yarn.lock | 67 +++++++++++++++++++++++++++++++++++++++ athena/package.json | 1 + athena/yarn.lock | 64 +++++++++++++++++++++++++++++++++++-- chronos/package.json | 1 + chronos/yarn.lock | 72 ++++++++++++++++++++++++++++++++++++++++++ hermes/package.json | 1 + hermes/yarn.lock | 69 +++++++++++++++++++++++++++++++++++++++- mercury/package.json | 1 + mercury/yarn.lock | 72 ++++++++++++++++++++++++++++++++++++++++++ vulcan/package.json | 1 + vulcan/yarn.lock | 72 ++++++++++++++++++++++++++++++++++++++++++ 12 files changed, 419 insertions(+), 3 deletions(-) diff --git a/analytics/package.json b/analytics/package.json index 6fb0ccb34a..d6814eaf6b 100644 --- a/analytics/package.json +++ b/analytics/package.json @@ -8,6 +8,7 @@ "amplitude": "^3.5.0", "aws-sdk": "^2.373.0", "bull": "3.3.10", + "datadog-metrics": "^0.8.1", "debug": "^4.1.0", "faker": "^4.1.0", "ioredis": "3.2.2", diff --git a/analytics/yarn.lock b/analytics/yarn.lock index 267fb34341..725cd66909 100644 --- a/analytics/yarn.lock +++ b/analytics/yarn.lock @@ -34,6 +34,11 @@ base64-js@^1.0.2: resolved "https://registry.yarnpkg.com/base64-js/-/base64-js-1.3.0.tgz#cab1e6118f051095e58b5281aea8c1cd22bfc0e3" integrity sha512-ccav/yGvoa80BQDljCxsmmQ3Xvx60/UpBIij5QN21W3wBi/hhIC9OoO+KLpu9IJTS9j4DRVJ3aDDF9cMSoa2lw== +bignumber.js@~1.1.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/bignumber.js/-/bignumber.js-1.1.1.tgz#1a415d9ac014c13256af1feed9d1a3e5717a8cf7" + integrity sha1-GkFdmsAUwTJWrx/u2dGj5XF6jPc= + "bluebird@>= 3.0.1", bluebird@^3.3.4, bluebird@^3.5.0: version "3.5.3" resolved "https://registry.yarnpkg.com/bluebird/-/bluebird-3.5.3.tgz#7d01c6f9616c9a51ab0f8c549a79dfe6ec33efa7" @@ -116,6 +121,21 @@ cron-parser@^2.4.1: resolved "https://registry.yarnpkg.com/crypt/-/crypt-0.0.2.tgz#88d7ff7ec0dfb86f713dc87bbb42d044d3e6c41b" integrity sha1-iNf/fsDfuG9xPch7u0LQRNPmxBs= +datadog-metrics@^0.8.1: + version "0.8.1" + resolved "https://registry.yarnpkg.com/datadog-metrics/-/datadog-metrics-0.8.1.tgz#be87237109a7084193c668d80112533ef00e3f21" + integrity sha512-qTSKnddO6GxTJW9FYpmWjvvift3qfyMurDjwNjJnJhBk76pBdDhC0B5V9V+XwPdn4r42qu48kwXNuHJslXlDOA== + dependencies: + debug "3.1.0" + dogapi "1.1.0" + +debug@3.1.0: + version "3.1.0" + resolved "https://registry.yarnpkg.com/debug/-/debug-3.1.0.tgz#5bb5a0672628b64149566ba16819e61518c67261" + integrity sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g== + dependencies: + ms "2.0.0" + debug@^2.6.9: version "2.6.9" resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.9.tgz#5d128515df134ff327e90a4c93f4e077a536341f" @@ -142,6 +162,11 @@ debuglog@^1.0.0: resolved "https://registry.yarnpkg.com/debuglog/-/debuglog-1.0.1.tgz#aa24ffb9ac3df9a2351837cfb2d279360cd78492" integrity sha1-qiT/uaw9+aI1GDfPstJ5NgzXhJI= +deep-extend@^0.6.0: + version "0.6.0" + resolved "https://registry.yarnpkg.com/deep-extend/-/deep-extend-0.6.0.tgz#c4fa7c95404a17a9c3e8ca7e1537312b736330ac" + integrity sha512-LOHxIOaPYdHlJRtCQfDIVZtfw/ufM8+rVj649RIHzcm/vGwQRXFt6OPqIFWsm2XEMrNIEtWR64sY1LEKD2vAOA== + define-properties@^1.1.1: version "1.1.3" resolved "https://registry.yarnpkg.com/define-properties/-/define-properties-1.1.3.tgz#cf88da6cbee26fe6db7094f61d870cbd84cee9f1" @@ -159,6 +184,16 @@ denque@^1.1.0: resolved "https://registry.yarnpkg.com/denque/-/denque-1.4.0.tgz#79e2f0490195502107f24d9553f374837dabc916" integrity sha512-gh513ac7aiKrAgjiIBWZG0EASyDF9p4JMWwKA8YU5s9figrL5SRNEMT6FDynsegakuhWd1wVqTvqvqAoDxw7wQ== +dogapi@1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/dogapi/-/dogapi-1.1.0.tgz#71a43865ad4bb4cb18bc3e13cf769971f501030a" + integrity sha1-caQ4Za1LtMsYvD4Tz3aZcfUBAwo= + dependencies: + extend "^3.0.0" + json-bigint "^0.1.4" + minimist "^1.1.1" + rc "^1.0.0" + events@1.1.1: version "1.1.1" resolved "https://registry.yarnpkg.com/events/-/events-1.1.1.tgz#9ebdb7635ad099c70dcc4c2a1f5004288e8bd924" @@ -208,6 +243,11 @@ inherits@~2.0.3: resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.3.tgz#633c2c83e3da42a502f52466022480f4208261de" integrity sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4= +ini@~1.3.0: + version "1.3.5" + resolved "https://registry.yarnpkg.com/ini/-/ini-1.3.5.tgz#eee25f56db1c9ec6085e0c22778083f596abf927" + integrity sha512-RZY5huIKCMRWDUqZlEi72f/lmXKMvuszcMBduliQ3nnWbx9X/ZBQO7DijMEYS9EhHBb2qacRUMtC7svLwe0lcw== + ioredis@3.2.2, ioredis@^3.1.4: version "3.2.2" resolved "https://registry.yarnpkg.com/ioredis/-/ioredis-3.2.2.tgz#b7d5ff3afd77bb9718bb2821329b894b9a44c00b" @@ -275,6 +315,13 @@ jmespath@0.15.0: resolved "https://registry.yarnpkg.com/jmespath/-/jmespath-0.15.0.tgz#a3f222a9aae9f966f5d27c796510e28091764217" integrity sha1-o/Iiqarp+Wb10nx5ZRDigJF2Qhc= +json-bigint@^0.1.4: + version "0.1.4" + resolved "https://registry.yarnpkg.com/json-bigint/-/json-bigint-0.1.4.tgz#b5d40b8a9009e92f157f7c079db097001830e01e" + integrity sha1-tdQLipAJ6S8Vf3wHnbCXABgw4B4= + dependencies: + bignumber.js "~1.1.1" + lodash.assign@^4.2.0: version "4.2.0" resolved "https://registry.yarnpkg.com/lodash.assign/-/lodash.assign-4.2.0.tgz#0d99f3ccd7a6d261d19bdaeb9245005d285808e7" @@ -396,6 +443,11 @@ mime@^1.4.1: resolved "https://registry.yarnpkg.com/mime/-/mime-1.6.0.tgz#32cd9e5c64553bd58d19a568af452acff04981b1" integrity sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg== +minimist@^1.1.1, minimist@^1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.0.tgz#a35008b20f41383eec1fb914f4cd5df79a264284" + integrity sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ= + moment-timezone@^0.5.23: version "0.5.23" resolved "https://registry.yarnpkg.com/moment-timezone/-/moment-timezone-0.5.23.tgz#7cbb00db2c14c71b19303cb47b0fb0a6d8651463" @@ -464,6 +516,16 @@ raven@^2.6.4: timed-out "4.0.1" uuid "3.3.2" +rc@^1.0.0: + version "1.2.8" + resolved "https://registry.yarnpkg.com/rc/-/rc-1.2.8.tgz#cd924bf5200a075b83c188cd6b9e211b7fc0d3ed" + integrity sha512-y3bGgqKj3QBdxLbLkomlohkvsA8gdAiUQlSBJnBhfn+BPxg4bc62d8TcBW15wavDfgexCgccckhcZvywyQYPOw== + dependencies: + deep-extend "^0.6.0" + ini "~1.3.0" + minimist "^1.2.0" + strip-json-comments "~2.0.1" + readable-stream@^2.3.5: version "2.3.6" resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-2.3.6.tgz#b11c27d88b8ff1fbe070643cf94b0c79ae1b0aaf" @@ -585,6 +647,11 @@ string_decoder@~1.1.1: dependencies: safe-buffer "~5.1.0" +strip-json-comments@~2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-2.0.1.tgz#3c531942e908c2697c0ec344858c286c7ca0a60a" + integrity sha1-PFMZQukIwml8DsNEhYwobHygpgo= + superagent@^3.3.1: version "3.8.3" resolved "https://registry.yarnpkg.com/superagent/-/superagent-3.8.3.tgz#460ea0dbdb7d5b11bc4f78deba565f86a178e128" diff --git a/athena/package.json b/athena/package.json index 52014ab8d6..82275ecef1 100644 --- a/athena/package.json +++ b/athena/package.json @@ -9,6 +9,7 @@ "axios": "^0.16.2", "bull": "3.3.10", "cryptr": "^3.0.0", + "datadog-metrics": "^0.8.1", "debug": "^4.1.0", "decode-uri-component": "^0.2.0", "draft-js": "^0.10.5", diff --git a/athena/yarn.lock b/athena/yarn.lock index d27e2214b9..62f56f0b03 100644 --- a/athena/yarn.lock +++ b/athena/yarn.lock @@ -51,6 +51,11 @@ base64-js@^1.0.2: resolved "https://registry.yarnpkg.com/base64-js/-/base64-js-1.3.0.tgz#cab1e6118f051095e58b5281aea8c1cd22bfc0e3" integrity sha512-ccav/yGvoa80BQDljCxsmmQ3Xvx60/UpBIij5QN21W3wBi/hhIC9OoO+KLpu9IJTS9j4DRVJ3aDDF9cMSoa2lw== +bignumber.js@~1.1.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/bignumber.js/-/bignumber.js-1.1.1.tgz#1a415d9ac014c13256af1feed9d1a3e5717a8cf7" + integrity sha1-GkFdmsAUwTJWrx/u2dGj5XF6jPc= + "bluebird@>= 3.0.1", bluebird@^3.3.4, bluebird@^3.5.0: version "3.5.3" resolved "https://registry.yarnpkg.com/bluebird/-/bluebird-3.5.3.tgz#7d01c6f9616c9a51ab0f8c549a79dfe6ec33efa7" @@ -141,7 +146,15 @@ cryptr@^3.0.0: resolved "https://registry.yarnpkg.com/cryptr/-/cryptr-3.0.0.tgz#4cdb1ac8b0b292c6ac1dcdf503bb27a05e4eba10" integrity sha512-ojvQNR6fiYVPVeRJbihzuHdJ4lU4zWa/A2heJuW54R8U51DnRBrMD7KA7gET9yPrTXkcKjntflx/wW5nohKRPQ== -debug@=3.1.0: +datadog-metrics@^0.8.1: + version "0.8.1" + resolved "https://registry.yarnpkg.com/datadog-metrics/-/datadog-metrics-0.8.1.tgz#be87237109a7084193c668d80112533ef00e3f21" + integrity sha512-qTSKnddO6GxTJW9FYpmWjvvift3qfyMurDjwNjJnJhBk76pBdDhC0B5V9V+XwPdn4r42qu48kwXNuHJslXlDOA== + dependencies: + debug "3.1.0" + dogapi "1.1.0" + +debug@3.1.0, debug@=3.1.0: version "3.1.0" resolved "https://registry.yarnpkg.com/debug/-/debug-3.1.0.tgz#5bb5a0672628b64149566ba16819e61518c67261" integrity sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g== @@ -179,6 +192,11 @@ decode-uri-component@^0.2.0: resolved "https://registry.yarnpkg.com/decode-uri-component/-/decode-uri-component-0.2.0.tgz#eb3913333458775cb84cd1a1fae062106bb87545" integrity sha1-6zkTMzRYd1y4TNGh+uBiEGu4dUU= +deep-extend@^0.6.0: + version "0.6.0" + resolved "https://registry.yarnpkg.com/deep-extend/-/deep-extend-0.6.0.tgz#c4fa7c95404a17a9c3e8ca7e1537312b736330ac" + integrity sha512-LOHxIOaPYdHlJRtCQfDIVZtfw/ufM8+rVj649RIHzcm/vGwQRXFt6OPqIFWsm2XEMrNIEtWR64sY1LEKD2vAOA== + define-properties@^1.1.1: version "1.1.3" resolved "https://registry.yarnpkg.com/define-properties/-/define-properties-1.1.3.tgz#cf88da6cbee26fe6db7094f61d870cbd84cee9f1" @@ -191,6 +209,16 @@ denque@^1.1.0: resolved "https://registry.yarnpkg.com/denque/-/denque-1.4.0.tgz#79e2f0490195502107f24d9553f374837dabc916" integrity sha512-gh513ac7aiKrAgjiIBWZG0EASyDF9p4JMWwKA8YU5s9figrL5SRNEMT6FDynsegakuhWd1wVqTvqvqAoDxw7wQ== +dogapi@1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/dogapi/-/dogapi-1.1.0.tgz#71a43865ad4bb4cb18bc3e13cf769971f501030a" + integrity sha1-caQ4Za1LtMsYvD4Tz3aZcfUBAwo= + dependencies: + extend "^3.0.0" + json-bigint "^0.1.4" + minimist "^1.1.1" + rc "^1.0.0" + draft-js@^0.10.5: version "0.10.5" resolved "https://registry.yarnpkg.com/draft-js/-/draft-js-0.10.5.tgz#bfa9beb018fe0533dbb08d6675c371a6b08fa742" @@ -241,6 +269,11 @@ events@1.1.1: resolved "https://registry.yarnpkg.com/events/-/events-1.1.1.tgz#9ebdb7635ad099c70dcc4c2a1f5004288e8bd924" integrity sha1-nr23Y1rQmccNzEwqH1AEKI6L2SQ= +extend@^3.0.0: + version "3.0.2" + resolved "https://registry.yarnpkg.com/extend/-/extend-3.0.2.tgz#f8b1136b4071fbd8eb140aff858b1019ec2915fa" + integrity sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g== + faker@^4.1.0: version "4.1.0" resolved "https://registry.yarnpkg.com/faker/-/faker-4.1.0.tgz#1e45bbbecc6774b3c195fad2835109c6d748cc3f" @@ -322,6 +355,11 @@ inherits@^2.0.1: resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.3.tgz#633c2c83e3da42a502f52466022480f4208261de" integrity sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4= +ini@~1.3.0: + version "1.3.5" + resolved "https://registry.yarnpkg.com/ini/-/ini-1.3.5.tgz#eee25f56db1c9ec6085e0c22778083f596abf927" + integrity sha512-RZY5huIKCMRWDUqZlEi72f/lmXKMvuszcMBduliQ3nnWbx9X/ZBQO7DijMEYS9EhHBb2qacRUMtC7svLwe0lcw== + ioredis@3.2.2, ioredis@^3.1.4: version "3.2.2" resolved "https://registry.yarnpkg.com/ioredis/-/ioredis-3.2.2.tgz#b7d5ff3afd77bb9718bb2821329b894b9a44c00b" @@ -412,6 +450,13 @@ js-base64@^2.1.9: resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-4.0.0.tgz#19203fb59991df98e3a287050d4647cdeaf32499" integrity sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ== +json-bigint@^0.1.4: + version "0.1.4" + resolved "https://registry.yarnpkg.com/json-bigint/-/json-bigint-0.1.4.tgz#b5d40b8a9009e92f157f7c079db097001830e01e" + integrity sha1-tdQLipAJ6S8Vf3wHnbCXABgw4B4= + dependencies: + bignumber.js "~1.1.1" + jwa@^1.1.5: version "1.1.6" resolved "https://registry.yarnpkg.com/jwa/-/jwa-1.1.6.tgz#87240e76c9808dbde18783cf2264ef4929ee50e6" @@ -540,7 +585,7 @@ minimalistic-assert@^1.0.0: resolved "https://registry.yarnpkg.com/minimalistic-assert/-/minimalistic-assert-1.0.1.tgz#2e194de044626d4a10e7f7fbc00ce73e83e4d5c7" integrity sha512-UtJcAD4yEaGtjPezWuO9wC4nwUnVH/8/Im3yEHQP4b67cXlD/Qr9hdITCU1xDbSEXg2XKNaP8jsReV7vQd00/A== -minimist@^1.2.0: +minimist@^1.1.1, minimist@^1.2.0: version "1.2.0" resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.0.tgz#a35008b20f41383eec1fb914f4cd5df79a264284" integrity sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ= @@ -623,6 +668,16 @@ raven@^2.6.4: timed-out "4.0.1" uuid "3.3.2" +rc@^1.0.0: + version "1.2.8" + resolved "https://registry.yarnpkg.com/rc/-/rc-1.2.8.tgz#cd924bf5200a075b83c188cd6b9e211b7fc0d3ed" + integrity sha512-y3bGgqKj3QBdxLbLkomlohkvsA8gdAiUQlSBJnBhfn+BPxg4bc62d8TcBW15wavDfgexCgccckhcZvywyQYPOw== + dependencies: + deep-extend "^0.6.0" + ini "~1.3.0" + minimist "^1.2.0" + strip-json-comments "~2.0.1" + redis-commands@1.4.0, redis-commands@^1.2.0: version "1.4.0" resolved "https://registry.yarnpkg.com/redis-commands/-/redis-commands-1.4.0.tgz#52f9cf99153efcce56a8f86af986bd04e988602f" @@ -725,6 +780,11 @@ standard-as-callback@^1.0.0: resolved "https://registry.yarnpkg.com/standard-as-callback/-/standard-as-callback-1.0.1.tgz#2e9e1e9d278d7d77580253faaec42269015e3c1d" integrity sha512-izxEITSyc7S+5oOiF/URiYaNkemPUxIndCNv66jJ548Y1TVxhBvioNMSPrZIQdaZDlhnguOdUzHA/7hJ3xFhuQ== +strip-json-comments@~2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-2.0.1.tgz#3c531942e908c2697c0ec344858c286c7ca0a60a" + integrity sha1-PFMZQukIwml8DsNEhYwobHygpgo= + timed-out@4.0.1: version "4.0.1" resolved "https://registry.yarnpkg.com/timed-out/-/timed-out-4.0.1.tgz#f32eacac5a175bea25d7fab565ab3ed8741ef56f" diff --git a/chronos/package.json b/chronos/package.json index 1c188b506b..75d3a529b5 100644 --- a/chronos/package.json +++ b/chronos/package.json @@ -5,6 +5,7 @@ "dependencies": { "aws-sdk": "^2.373.0", "bull": "^3.5.2", + "datadog-metrics": "^0.8.1", "debug": "^4.1.0", "decode-uri-component": "^0.2.0", "draft-js": "^0.10.5", diff --git a/chronos/yarn.lock b/chronos/yarn.lock index b5420eada8..9e481d7c6d 100644 --- a/chronos/yarn.lock +++ b/chronos/yarn.lock @@ -27,6 +27,11 @@ base64-js@^1.0.2: resolved "https://registry.yarnpkg.com/base64-js/-/base64-js-1.3.0.tgz#cab1e6118f051095e58b5281aea8c1cd22bfc0e3" integrity sha512-ccav/yGvoa80BQDljCxsmmQ3Xvx60/UpBIij5QN21W3wBi/hhIC9OoO+KLpu9IJTS9j4DRVJ3aDDF9cMSoa2lw== +bignumber.js@~1.1.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/bignumber.js/-/bignumber.js-1.1.1.tgz#1a415d9ac014c13256af1feed9d1a3e5717a8cf7" + integrity sha1-GkFdmsAUwTJWrx/u2dGj5XF6jPc= + "bluebird@>= 3.0.1", bluebird@^3.3.4, bluebird@^3.5.3: version "3.5.3" resolved "https://registry.yarnpkg.com/bluebird/-/bluebird-3.5.3.tgz#7d01c6f9616c9a51ab0f8c549a79dfe6ec33efa7" @@ -102,6 +107,21 @@ crypt@~0.0.1: resolved "https://registry.yarnpkg.com/crypt/-/crypt-0.0.2.tgz#88d7ff7ec0dfb86f713dc87bbb42d044d3e6c41b" integrity sha1-iNf/fsDfuG9xPch7u0LQRNPmxBs= +datadog-metrics@^0.8.1: + version "0.8.1" + resolved "https://registry.yarnpkg.com/datadog-metrics/-/datadog-metrics-0.8.1.tgz#be87237109a7084193c668d80112533ef00e3f21" + integrity sha512-qTSKnddO6GxTJW9FYpmWjvvift3qfyMurDjwNjJnJhBk76pBdDhC0B5V9V+XwPdn4r42qu48kwXNuHJslXlDOA== + dependencies: + debug "3.1.0" + dogapi "1.1.0" + +debug@3.1.0: + version "3.1.0" + resolved "https://registry.yarnpkg.com/debug/-/debug-3.1.0.tgz#5bb5a0672628b64149566ba16819e61518c67261" + integrity sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g== + dependencies: + ms "2.0.0" + debug@^2.6.9: version "2.6.9" resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.9.tgz#5d128515df134ff327e90a4c93f4e077a536341f" @@ -133,6 +153,11 @@ decode-uri-component@^0.2.0: resolved "https://registry.yarnpkg.com/decode-uri-component/-/decode-uri-component-0.2.0.tgz#eb3913333458775cb84cd1a1fae062106bb87545" integrity sha1-6zkTMzRYd1y4TNGh+uBiEGu4dUU= +deep-extend@^0.6.0: + version "0.6.0" + resolved "https://registry.yarnpkg.com/deep-extend/-/deep-extend-0.6.0.tgz#c4fa7c95404a17a9c3e8ca7e1537312b736330ac" + integrity sha512-LOHxIOaPYdHlJRtCQfDIVZtfw/ufM8+rVj649RIHzcm/vGwQRXFt6OPqIFWsm2XEMrNIEtWR64sY1LEKD2vAOA== + define-properties@^1.1.1: version "1.1.3" resolved "https://registry.yarnpkg.com/define-properties/-/define-properties-1.1.3.tgz#cf88da6cbee26fe6db7094f61d870cbd84cee9f1" @@ -145,6 +170,16 @@ denque@^1.1.0: resolved "https://registry.yarnpkg.com/denque/-/denque-1.4.0.tgz#79e2f0490195502107f24d9553f374837dabc916" integrity sha512-gh513ac7aiKrAgjiIBWZG0EASyDF9p4JMWwKA8YU5s9figrL5SRNEMT6FDynsegakuhWd1wVqTvqvqAoDxw7wQ== +dogapi@1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/dogapi/-/dogapi-1.1.0.tgz#71a43865ad4bb4cb18bc3e13cf769971f501030a" + integrity sha1-caQ4Za1LtMsYvD4Tz3aZcfUBAwo= + dependencies: + extend "^3.0.0" + json-bigint "^0.1.4" + minimist "^1.1.1" + rc "^1.0.0" + draft-js@^0.10.5: version "0.10.5" resolved "https://registry.yarnpkg.com/draft-js/-/draft-js-0.10.5.tgz#bfa9beb018fe0533dbb08d6675c371a6b08fa742" @@ -166,6 +201,11 @@ events@1.1.1: resolved "https://registry.yarnpkg.com/events/-/events-1.1.1.tgz#9ebdb7635ad099c70dcc4c2a1f5004288e8bd924" integrity sha1-nr23Y1rQmccNzEwqH1AEKI6L2SQ= +extend@^3.0.0: + version "3.0.2" + resolved "https://registry.yarnpkg.com/extend/-/extend-3.0.2.tgz#f8b1136b4071fbd8eb140aff858b1019ec2915fa" + integrity sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g== + faker@^4.1.0: version "4.1.0" resolved "https://registry.yarnpkg.com/faker/-/faker-4.1.0.tgz#1e45bbbecc6774b3c195fad2835109c6d748cc3f" @@ -220,6 +260,11 @@ immutable@~3.7.4: resolved "https://registry.yarnpkg.com/immutable/-/immutable-3.7.6.tgz#13b4d3cb12befa15482a26fe1b2ebae640071e4b" integrity sha1-E7TTyxK++hVIKib+Gy665kAHHks= +ini@~1.3.0: + version "1.3.5" + resolved "https://registry.yarnpkg.com/ini/-/ini-1.3.5.tgz#eee25f56db1c9ec6085e0c22778083f596abf927" + integrity sha512-RZY5huIKCMRWDUqZlEi72f/lmXKMvuszcMBduliQ3nnWbx9X/ZBQO7DijMEYS9EhHBb2qacRUMtC7svLwe0lcw== + ioredis@3.2.2, ioredis@^3.1.4: version "3.2.2" resolved "https://registry.yarnpkg.com/ioredis/-/ioredis-3.2.2.tgz#b7d5ff3afd77bb9718bb2821329b894b9a44c00b" @@ -310,6 +355,13 @@ js-base64@^2.1.9: resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-4.0.0.tgz#19203fb59991df98e3a287050d4647cdeaf32499" integrity sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ== +json-bigint@^0.1.4: + version "0.1.4" + resolved "https://registry.yarnpkg.com/json-bigint/-/json-bigint-0.1.4.tgz#b5d40b8a9009e92f157f7c079db097001830e01e" + integrity sha1-tdQLipAJ6S8Vf3wHnbCXABgw4B4= + dependencies: + bignumber.js "~1.1.1" + json-stringify-pretty-compact@^1.2.0: version "1.2.0" resolved "https://registry.yarnpkg.com/json-stringify-pretty-compact/-/json-stringify-pretty-compact-1.2.0.tgz#0bc316b5e6831c07041fc35612487fb4e9ab98b8" @@ -421,6 +473,11 @@ md5@^2.2.1: crypt "~0.0.1" is-buffer "~1.1.1" +minimist@^1.1.1, minimist@^1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.0.tgz#a35008b20f41383eec1fb914f4cd5df79a264284" + integrity sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ= + moment-timezone@^0.5.23: version "0.5.23" resolved "https://registry.yarnpkg.com/moment-timezone/-/moment-timezone-0.5.23.tgz#7cbb00db2c14c71b19303cb47b0fb0a6d8651463" @@ -494,6 +551,16 @@ raven@^2.6.4: timed-out "4.0.1" uuid "3.3.2" +rc@^1.0.0: + version "1.2.8" + resolved "https://registry.yarnpkg.com/rc/-/rc-1.2.8.tgz#cd924bf5200a075b83c188cd6b9e211b7fc0d3ed" + integrity sha512-y3bGgqKj3QBdxLbLkomlohkvsA8gdAiUQlSBJnBhfn+BPxg4bc62d8TcBW15wavDfgexCgccckhcZvywyQYPOw== + dependencies: + deep-extend "^0.6.0" + ini "~1.3.0" + minimist "^1.2.0" + strip-json-comments "~2.0.1" + redis-commands@1.4.0, redis-commands@^1.2.0: version "1.4.0" resolved "https://registry.yarnpkg.com/redis-commands/-/redis-commands-1.4.0.tgz#52f9cf99153efcce56a8f86af986bd04e988602f" @@ -591,6 +658,11 @@ standard-as-callback@^1.0.0: resolved "https://registry.yarnpkg.com/standard-as-callback/-/standard-as-callback-1.0.1.tgz#2e9e1e9d278d7d77580253faaec42269015e3c1d" integrity sha512-izxEITSyc7S+5oOiF/URiYaNkemPUxIndCNv66jJ548Y1TVxhBvioNMSPrZIQdaZDlhnguOdUzHA/7hJ3xFhuQ== +strip-json-comments@~2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-2.0.1.tgz#3c531942e908c2697c0ec344858c286c7ca0a60a" + integrity sha1-PFMZQukIwml8DsNEhYwobHygpgo= + timed-out@4.0.1: version "4.0.1" resolved "https://registry.yarnpkg.com/timed-out/-/timed-out-4.0.1.tgz#f32eacac5a175bea25d7fab565ab3ed8741ef56f" diff --git a/hermes/package.json b/hermes/package.json index 56c20db8f5..d874036531 100644 --- a/hermes/package.json +++ b/hermes/package.json @@ -6,6 +6,7 @@ "@sendgrid/mail": "^6.3.1", "aws-sdk": "^2.373.0", "bull": "3.3.10", + "datadog-metrics": "^0.8.1", "debug": "^4.1.0", "draft-js": "^0.10.5", "escape-html": "^1.0.3", diff --git a/hermes/yarn.lock b/hermes/yarn.lock index 7e2a4b9500..8ad3e6da55 100644 --- a/hermes/yarn.lock +++ b/hermes/yarn.lock @@ -135,6 +135,11 @@ bcrypt-pbkdf@^1.0.0: dependencies: tweetnacl "^0.14.3" +bignumber.js@~1.1.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/bignumber.js/-/bignumber.js-1.1.1.tgz#1a415d9ac014c13256af1feed9d1a3e5717a8cf7" + integrity sha1-GkFdmsAUwTJWrx/u2dGj5XF6jPc= + "bluebird@>= 3.0.1", bluebird@^3.3.4, bluebird@^3.5.0: version "3.5.3" resolved "https://registry.yarnpkg.com/bluebird/-/bluebird-3.5.3.tgz#7d01c6f9616c9a51ab0f8c549a79dfe6ec33efa7" @@ -245,6 +250,21 @@ dashdash@^1.12.0: dependencies: assert-plus "^1.0.0" +datadog-metrics@^0.8.1: + version "0.8.1" + resolved "https://registry.yarnpkg.com/datadog-metrics/-/datadog-metrics-0.8.1.tgz#be87237109a7084193c668d80112533ef00e3f21" + integrity sha512-qTSKnddO6GxTJW9FYpmWjvvift3qfyMurDjwNjJnJhBk76pBdDhC0B5V9V+XwPdn4r42qu48kwXNuHJslXlDOA== + dependencies: + debug "3.1.0" + dogapi "1.1.0" + +debug@3.1.0: + version "3.1.0" + resolved "https://registry.yarnpkg.com/debug/-/debug-3.1.0.tgz#5bb5a0672628b64149566ba16819e61518c67261" + integrity sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g== + dependencies: + ms "2.0.0" + debug@^2.6.9: version "2.6.9" resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.9.tgz#5d128515df134ff327e90a4c93f4e077a536341f" @@ -271,6 +291,11 @@ debuglog@^1.0.0: resolved "https://registry.yarnpkg.com/debuglog/-/debuglog-1.0.1.tgz#aa24ffb9ac3df9a2351837cfb2d279360cd78492" integrity sha1-qiT/uaw9+aI1GDfPstJ5NgzXhJI= +deep-extend@^0.6.0: + version "0.6.0" + resolved "https://registry.yarnpkg.com/deep-extend/-/deep-extend-0.6.0.tgz#c4fa7c95404a17a9c3e8ca7e1537312b736330ac" + integrity sha512-LOHxIOaPYdHlJRtCQfDIVZtfw/ufM8+rVj649RIHzcm/vGwQRXFt6OPqIFWsm2XEMrNIEtWR64sY1LEKD2vAOA== + deepmerge@^2.1.1: version "2.2.1" resolved "https://registry.yarnpkg.com/deepmerge/-/deepmerge-2.2.1.tgz#5d3ff22a01c00f645405a2fbc17d0778a1801170" @@ -293,6 +318,16 @@ denque@^1.1.0: resolved "https://registry.yarnpkg.com/denque/-/denque-1.4.0.tgz#79e2f0490195502107f24d9553f374837dabc916" integrity sha512-gh513ac7aiKrAgjiIBWZG0EASyDF9p4JMWwKA8YU5s9figrL5SRNEMT6FDynsegakuhWd1wVqTvqvqAoDxw7wQ== +dogapi@1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/dogapi/-/dogapi-1.1.0.tgz#71a43865ad4bb4cb18bc3e13cf769971f501030a" + integrity sha1-caQ4Za1LtMsYvD4Tz3aZcfUBAwo= + dependencies: + extend "^3.0.0" + json-bigint "^0.1.4" + minimist "^1.1.1" + rc "^1.0.0" + draft-js@^0.10.5: version "0.10.5" resolved "https://registry.yarnpkg.com/draft-js/-/draft-js-0.10.5.tgz#bfa9beb018fe0533dbb08d6675c371a6b08fa742" @@ -339,7 +374,7 @@ events@1.1.1: resolved "https://registry.yarnpkg.com/events/-/events-1.1.1.tgz#9ebdb7635ad099c70dcc4c2a1f5004288e8bd924" integrity sha1-nr23Y1rQmccNzEwqH1AEKI6L2SQ= -extend@~3.0.2: +extend@^3.0.0, extend@~3.0.2: version "3.0.2" resolved "https://registry.yarnpkg.com/extend/-/extend-3.0.2.tgz#f8b1136b4071fbd8eb140aff858b1019ec2915fa" integrity sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g== @@ -457,6 +492,11 @@ immutable@~3.7.4: resolved "https://registry.yarnpkg.com/immutable/-/immutable-3.7.6.tgz#13b4d3cb12befa15482a26fe1b2ebae640071e4b" integrity sha1-E7TTyxK++hVIKib+Gy665kAHHks= +ini@~1.3.0: + version "1.3.5" + resolved "https://registry.yarnpkg.com/ini/-/ini-1.3.5.tgz#eee25f56db1c9ec6085e0c22778083f596abf927" + integrity sha512-RZY5huIKCMRWDUqZlEi72f/lmXKMvuszcMBduliQ3nnWbx9X/ZBQO7DijMEYS9EhHBb2qacRUMtC7svLwe0lcw== + ioredis@3.2.2, ioredis@^3.1.4: version "3.2.2" resolved "https://registry.yarnpkg.com/ioredis/-/ioredis-3.2.2.tgz#b7d5ff3afd77bb9718bb2821329b894b9a44c00b" @@ -557,6 +597,13 @@ jsbn@~0.1.0: resolved "https://registry.yarnpkg.com/jsbn/-/jsbn-0.1.1.tgz#a5e654c2e5a2deb5f201d96cefbca80c0ef2f513" integrity sha1-peZUwuWi3rXyAdls77yoDA7y9RM= +json-bigint@^0.1.4: + version "0.1.4" + resolved "https://registry.yarnpkg.com/json-bigint/-/json-bigint-0.1.4.tgz#b5d40b8a9009e92f157f7c079db097001830e01e" + integrity sha1-tdQLipAJ6S8Vf3wHnbCXABgw4B4= + dependencies: + bignumber.js "~1.1.1" + json-schema-traverse@^0.4.1: version "0.4.1" resolved "https://registry.yarnpkg.com/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz#69f6a87d9513ab8bb8fe63bdb0979c448e684660" @@ -772,6 +819,11 @@ mime-types@^2.1.12, mime-types@~2.1.19: dependencies: mime-db "~1.37.0" +minimist@^1.1.1, minimist@^1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.0.tgz#a35008b20f41383eec1fb914f4cd5df79a264284" + integrity sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ= + moment-timezone@^0.5.23: version "0.5.23" resolved "https://registry.yarnpkg.com/moment-timezone/-/moment-timezone-0.5.23.tgz#7cbb00db2c14c71b19303cb47b0fb0a6d8651463" @@ -880,6 +932,16 @@ raven@^2.6.4: timed-out "4.0.1" uuid "3.3.2" +rc@^1.0.0: + version "1.2.8" + resolved "https://registry.yarnpkg.com/rc/-/rc-1.2.8.tgz#cd924bf5200a075b83c188cd6b9e211b7fc0d3ed" + integrity sha512-y3bGgqKj3QBdxLbLkomlohkvsA8gdAiUQlSBJnBhfn+BPxg4bc62d8TcBW15wavDfgexCgccckhcZvywyQYPOw== + dependencies: + deep-extend "^0.6.0" + ini "~1.3.0" + minimist "^1.2.0" + strip-json-comments "~2.0.1" + redis-commands@1.4.0, redis-commands@^1.2.0: version "1.4.0" resolved "https://registry.yarnpkg.com/redis-commands/-/redis-commands-1.4.0.tgz#52f9cf99153efcce56a8f86af986bd04e988602f" @@ -1023,6 +1085,11 @@ standard-as-callback@^1.0.0: resolved "https://registry.yarnpkg.com/standard-as-callback/-/standard-as-callback-1.0.1.tgz#2e9e1e9d278d7d77580253faaec42269015e3c1d" integrity sha512-izxEITSyc7S+5oOiF/URiYaNkemPUxIndCNv66jJ548Y1TVxhBvioNMSPrZIQdaZDlhnguOdUzHA/7hJ3xFhuQ== +strip-json-comments@~2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-2.0.1.tgz#3c531942e908c2697c0ec344858c286c7ca0a60a" + integrity sha1-PFMZQukIwml8DsNEhYwobHygpgo= + supports-color@^5.3.0: version "5.5.0" resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-5.5.0.tgz#e2e69a44ac8772f78a1ec0b35b689df6530efc8f" diff --git a/mercury/package.json b/mercury/package.json index 2b33ceda30..aeb0c229bc 100644 --- a/mercury/package.json +++ b/mercury/package.json @@ -4,6 +4,7 @@ }, "dependencies": { "bull": "^3.5.2", + "datadog-metrics": "^0.8.1", "debug": "^4.1.0", "ioredis": "3.2.2", "now-env": "^3.1.0", diff --git a/mercury/yarn.lock b/mercury/yarn.lock index f000be25a0..17b6f3e47b 100644 --- a/mercury/yarn.lock +++ b/mercury/yarn.lock @@ -2,6 +2,11 @@ # yarn lockfile v1 +bignumber.js@~1.1.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/bignumber.js/-/bignumber.js-1.1.1.tgz#1a415d9ac014c13256af1feed9d1a3e5717a8cf7" + integrity sha1-GkFdmsAUwTJWrx/u2dGj5XF6jPc= + "bluebird@>= 3.0.1", bluebird@^3.3.4, bluebird@^3.5.3: version "3.5.3" resolved "https://registry.yarnpkg.com/bluebird/-/bluebird-3.5.3.tgz#7d01c6f9616c9a51ab0f8c549a79dfe6ec33efa7" @@ -48,6 +53,21 @@ crypt@~0.0.1: resolved "https://registry.yarnpkg.com/crypt/-/crypt-0.0.2.tgz#88d7ff7ec0dfb86f713dc87bbb42d044d3e6c41b" integrity sha1-iNf/fsDfuG9xPch7u0LQRNPmxBs= +datadog-metrics@^0.8.1: + version "0.8.1" + resolved "https://registry.yarnpkg.com/datadog-metrics/-/datadog-metrics-0.8.1.tgz#be87237109a7084193c668d80112533ef00e3f21" + integrity sha512-qTSKnddO6GxTJW9FYpmWjvvift3qfyMurDjwNjJnJhBk76pBdDhC0B5V9V+XwPdn4r42qu48kwXNuHJslXlDOA== + dependencies: + debug "3.1.0" + dogapi "1.1.0" + +debug@3.1.0: + version "3.1.0" + resolved "https://registry.yarnpkg.com/debug/-/debug-3.1.0.tgz#5bb5a0672628b64149566ba16819e61518c67261" + integrity sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g== + dependencies: + ms "2.0.0" + debug@^2.6.9: version "2.6.9" resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.9.tgz#5d128515df134ff327e90a4c93f4e077a536341f" @@ -74,6 +94,11 @@ debuglog@^1.0.0: resolved "https://registry.yarnpkg.com/debuglog/-/debuglog-1.0.1.tgz#aa24ffb9ac3df9a2351837cfb2d279360cd78492" integrity sha1-qiT/uaw9+aI1GDfPstJ5NgzXhJI= +deep-extend@^0.6.0: + version "0.6.0" + resolved "https://registry.yarnpkg.com/deep-extend/-/deep-extend-0.6.0.tgz#c4fa7c95404a17a9c3e8ca7e1537312b736330ac" + integrity sha512-LOHxIOaPYdHlJRtCQfDIVZtfw/ufM8+rVj649RIHzcm/vGwQRXFt6OPqIFWsm2XEMrNIEtWR64sY1LEKD2vAOA== + define-properties@^1.1.1: version "1.1.3" resolved "https://registry.yarnpkg.com/define-properties/-/define-properties-1.1.3.tgz#cf88da6cbee26fe6db7094f61d870cbd84cee9f1" @@ -86,11 +111,31 @@ denque@^1.1.0: resolved "https://registry.yarnpkg.com/denque/-/denque-1.4.0.tgz#79e2f0490195502107f24d9553f374837dabc916" integrity sha512-gh513ac7aiKrAgjiIBWZG0EASyDF9p4JMWwKA8YU5s9figrL5SRNEMT6FDynsegakuhWd1wVqTvqvqAoDxw7wQ== +dogapi@1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/dogapi/-/dogapi-1.1.0.tgz#71a43865ad4bb4cb18bc3e13cf769971f501030a" + integrity sha1-caQ4Za1LtMsYvD4Tz3aZcfUBAwo= + dependencies: + extend "^3.0.0" + json-bigint "^0.1.4" + minimist "^1.1.1" + rc "^1.0.0" + +extend@^3.0.0: + version "3.0.2" + resolved "https://registry.yarnpkg.com/extend/-/extend-3.0.2.tgz#f8b1136b4071fbd8eb140aff858b1019ec2915fa" + integrity sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g== + flexbuffer@0.0.6: version "0.0.6" resolved "https://registry.yarnpkg.com/flexbuffer/-/flexbuffer-0.0.6.tgz#039fdf23f8823e440c38f3277e6fef1174215b30" integrity sha1-A5/fI/iCPkQMOPMnfm/vEXQhWzA= +ini@~1.3.0: + version "1.3.5" + resolved "https://registry.yarnpkg.com/ini/-/ini-1.3.5.tgz#eee25f56db1c9ec6085e0c22778083f596abf927" + integrity sha512-RZY5huIKCMRWDUqZlEi72f/lmXKMvuszcMBduliQ3nnWbx9X/ZBQO7DijMEYS9EhHBb2qacRUMtC7svLwe0lcw== + ioredis@3.2.2, ioredis@^3.1.4: version "3.2.2" resolved "https://registry.yarnpkg.com/ioredis/-/ioredis-3.2.2.tgz#b7d5ff3afd77bb9718bb2821329b894b9a44c00b" @@ -148,6 +193,13 @@ is-nan@^1.2.1: dependencies: define-properties "^1.1.1" +json-bigint@^0.1.4: + version "0.1.4" + resolved "https://registry.yarnpkg.com/json-bigint/-/json-bigint-0.1.4.tgz#b5d40b8a9009e92f157f7c079db097001830e01e" + integrity sha1-tdQLipAJ6S8Vf3wHnbCXABgw4B4= + dependencies: + bignumber.js "~1.1.1" + json-stringify-pretty-compact@^1.2.0: version "1.2.0" resolved "https://registry.yarnpkg.com/json-stringify-pretty-compact/-/json-stringify-pretty-compact-1.2.0.tgz#0bc316b5e6831c07041fc35612487fb4e9ab98b8" @@ -247,6 +299,11 @@ md5@^2.2.1: crypt "~0.0.1" is-buffer "~1.1.1" +minimist@^1.1.1, minimist@^1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.0.tgz#a35008b20f41383eec1fb914f4cd5df79a264284" + integrity sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ= + moment-timezone@^0.5.23: version "0.5.23" resolved "https://registry.yarnpkg.com/moment-timezone/-/moment-timezone-0.5.23.tgz#7cbb00db2c14c71b19303cb47b0fb0a6d8651463" @@ -290,6 +347,16 @@ raven@^2.6.4: timed-out "4.0.1" uuid "3.3.2" +rc@^1.0.0: + version "1.2.8" + resolved "https://registry.yarnpkg.com/rc/-/rc-1.2.8.tgz#cd924bf5200a075b83c188cd6b9e211b7fc0d3ed" + integrity sha512-y3bGgqKj3QBdxLbLkomlohkvsA8gdAiUQlSBJnBhfn+BPxg4bc62d8TcBW15wavDfgexCgccckhcZvywyQYPOw== + dependencies: + deep-extend "^0.6.0" + ini "~1.3.0" + minimist "^1.2.0" + strip-json-comments "~2.0.1" + redis-commands@1.4.0, redis-commands@^1.2.0: version "1.4.0" resolved "https://registry.yarnpkg.com/redis-commands/-/redis-commands-1.4.0.tgz#52f9cf99153efcce56a8f86af986bd04e988602f" @@ -360,6 +427,11 @@ standard-as-callback@^1.0.0: resolved "https://registry.yarnpkg.com/standard-as-callback/-/standard-as-callback-1.0.1.tgz#2e9e1e9d278d7d77580253faaec42269015e3c1d" integrity sha512-izxEITSyc7S+5oOiF/URiYaNkemPUxIndCNv66jJ548Y1TVxhBvioNMSPrZIQdaZDlhnguOdUzHA/7hJ3xFhuQ== +strip-json-comments@~2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-2.0.1.tgz#3c531942e908c2697c0ec344858c286c7ca0a60a" + integrity sha1-PFMZQukIwml8DsNEhYwobHygpgo= + timed-out@4.0.1: version "4.0.1" resolved "https://registry.yarnpkg.com/timed-out/-/timed-out-4.0.1.tgz#f32eacac5a175bea25d7fab565ab3ed8741ef56f" diff --git a/vulcan/package.json b/vulcan/package.json index b0086baddb..2c5d822b6e 100644 --- a/vulcan/package.json +++ b/vulcan/package.json @@ -6,6 +6,7 @@ "algoliasearch": "^3.32.0", "aws-sdk": "^2.373.0", "bull": "^3.5.2", + "datadog-metrics": "^0.8.1", "debug": "^4.1.0", "draft-js": "^0.10.3", "emoji-regex": "^6.1.1", diff --git a/vulcan/yarn.lock b/vulcan/yarn.lock index 7ebc35f833..672e20cae7 100644 --- a/vulcan/yarn.lock +++ b/vulcan/yarn.lock @@ -61,6 +61,11 @@ base64-js@^1.0.2: resolved "https://registry.yarnpkg.com/base64-js/-/base64-js-1.3.0.tgz#cab1e6118f051095e58b5281aea8c1cd22bfc0e3" integrity sha512-ccav/yGvoa80BQDljCxsmmQ3Xvx60/UpBIij5QN21W3wBi/hhIC9OoO+KLpu9IJTS9j4DRVJ3aDDF9cMSoa2lw== +bignumber.js@~1.1.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/bignumber.js/-/bignumber.js-1.1.1.tgz#1a415d9ac014c13256af1feed9d1a3e5717a8cf7" + integrity sha1-GkFdmsAUwTJWrx/u2dGj5XF6jPc= + "bluebird@>= 3.0.1", bluebird@^3.3.4, bluebird@^3.5.3: version "3.5.3" resolved "https://registry.yarnpkg.com/bluebird/-/bluebird-3.5.3.tgz#7d01c6f9616c9a51ab0f8c549a79dfe6ec33efa7" @@ -126,6 +131,21 @@ crypt@~0.0.1: resolved "https://registry.yarnpkg.com/crypt/-/crypt-0.0.2.tgz#88d7ff7ec0dfb86f713dc87bbb42d044d3e6c41b" integrity sha1-iNf/fsDfuG9xPch7u0LQRNPmxBs= +datadog-metrics@^0.8.1: + version "0.8.1" + resolved "https://registry.yarnpkg.com/datadog-metrics/-/datadog-metrics-0.8.1.tgz#be87237109a7084193c668d80112533ef00e3f21" + integrity sha512-qTSKnddO6GxTJW9FYpmWjvvift3qfyMurDjwNjJnJhBk76pBdDhC0B5V9V+XwPdn4r42qu48kwXNuHJslXlDOA== + dependencies: + debug "3.1.0" + dogapi "1.1.0" + +debug@3.1.0: + version "3.1.0" + resolved "https://registry.yarnpkg.com/debug/-/debug-3.1.0.tgz#5bb5a0672628b64149566ba16819e61518c67261" + integrity sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g== + dependencies: + ms "2.0.0" + debug@^2.6.8, debug@^2.6.9: version "2.6.9" resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.9.tgz#5d128515df134ff327e90a4c93f4e077a536341f" @@ -152,6 +172,11 @@ debuglog@^1.0.0: resolved "https://registry.yarnpkg.com/debuglog/-/debuglog-1.0.1.tgz#aa24ffb9ac3df9a2351837cfb2d279360cd78492" integrity sha1-qiT/uaw9+aI1GDfPstJ5NgzXhJI= +deep-extend@^0.6.0: + version "0.6.0" + resolved "https://registry.yarnpkg.com/deep-extend/-/deep-extend-0.6.0.tgz#c4fa7c95404a17a9c3e8ca7e1537312b736330ac" + integrity sha512-LOHxIOaPYdHlJRtCQfDIVZtfw/ufM8+rVj649RIHzcm/vGwQRXFt6OPqIFWsm2XEMrNIEtWR64sY1LEKD2vAOA== + define-properties@^1.1.1: version "1.1.3" resolved "https://registry.yarnpkg.com/define-properties/-/define-properties-1.1.3.tgz#cf88da6cbee26fe6db7094f61d870cbd84cee9f1" @@ -164,6 +189,16 @@ denque@^1.1.0: resolved "https://registry.yarnpkg.com/denque/-/denque-1.4.0.tgz#79e2f0490195502107f24d9553f374837dabc916" integrity sha512-gh513ac7aiKrAgjiIBWZG0EASyDF9p4JMWwKA8YU5s9figrL5SRNEMT6FDynsegakuhWd1wVqTvqvqAoDxw7wQ== +dogapi@1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/dogapi/-/dogapi-1.1.0.tgz#71a43865ad4bb4cb18bc3e13cf769971f501030a" + integrity sha1-caQ4Za1LtMsYvD4Tz3aZcfUBAwo= + dependencies: + extend "^3.0.0" + json-bigint "^0.1.4" + minimist "^1.1.1" + rc "^1.0.0" + dom-walk@^0.1.0: version "0.1.1" resolved "https://registry.yarnpkg.com/dom-walk/-/dom-walk-0.1.1.tgz#672226dc74c8f799ad35307df936aba11acd6018" @@ -213,6 +248,11 @@ events@1.1.1, events@^1.1.0: resolved "https://registry.yarnpkg.com/events/-/events-1.1.1.tgz#9ebdb7635ad099c70dcc4c2a1f5004288e8bd924" integrity sha1-nr23Y1rQmccNzEwqH1AEKI6L2SQ= +extend@^3.0.0: + version "3.0.2" + resolved "https://registry.yarnpkg.com/extend/-/extend-3.0.2.tgz#f8b1136b4071fbd8eb140aff858b1019ec2915fa" + integrity sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g== + faker@^4.1.0: version "4.1.0" resolved "https://registry.yarnpkg.com/faker/-/faker-4.1.0.tgz#1e45bbbecc6774b3c195fad2835109c6d748cc3f" @@ -276,6 +316,11 @@ inherits@^2.0.1: resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.3.tgz#633c2c83e3da42a502f52466022480f4208261de" integrity sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4= +ini@~1.3.0: + version "1.3.5" + resolved "https://registry.yarnpkg.com/ini/-/ini-1.3.5.tgz#eee25f56db1c9ec6085e0c22778083f596abf927" + integrity sha512-RZY5huIKCMRWDUqZlEi72f/lmXKMvuszcMBduliQ3nnWbx9X/ZBQO7DijMEYS9EhHBb2qacRUMtC7svLwe0lcw== + ioredis@3.2.2, ioredis@^3.1.4: version "3.2.2" resolved "https://registry.yarnpkg.com/ioredis/-/ioredis-3.2.2.tgz#b7d5ff3afd77bb9718bb2821329b894b9a44c00b" @@ -366,6 +411,13 @@ jmespath@0.15.0: resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-4.0.0.tgz#19203fb59991df98e3a287050d4647cdeaf32499" integrity sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ== +json-bigint@^0.1.4: + version "0.1.4" + resolved "https://registry.yarnpkg.com/json-bigint/-/json-bigint-0.1.4.tgz#b5d40b8a9009e92f157f7c079db097001830e01e" + integrity sha1-tdQLipAJ6S8Vf3wHnbCXABgw4B4= + dependencies: + bignumber.js "~1.1.1" + json-stringify-pretty-compact@^1.2.0: version "1.2.0" resolved "https://registry.yarnpkg.com/json-stringify-pretty-compact/-/json-stringify-pretty-compact-1.2.0.tgz#0bc316b5e6831c07041fc35612487fb4e9ab98b8" @@ -489,6 +541,11 @@ min-document@^2.19.0: dependencies: dom-walk "^0.1.0" +minimist@^1.1.1, minimist@^1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.0.tgz#a35008b20f41383eec1fb914f4cd5df79a264284" + integrity sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ= + moment-timezone@^0.5.23: version "0.5.23" resolved "https://registry.yarnpkg.com/moment-timezone/-/moment-timezone-0.5.23.tgz#7cbb00db2c14c71b19303cb47b0fb0a6d8651463" @@ -577,6 +634,16 @@ raven@^2.6.4: timed-out "4.0.1" uuid "3.3.2" +rc@^1.0.0: + version "1.2.8" + resolved "https://registry.yarnpkg.com/rc/-/rc-1.2.8.tgz#cd924bf5200a075b83c188cd6b9e211b7fc0d3ed" + integrity sha512-y3bGgqKj3QBdxLbLkomlohkvsA8gdAiUQlSBJnBhfn+BPxg4bc62d8TcBW15wavDfgexCgccckhcZvywyQYPOw== + dependencies: + deep-extend "^0.6.0" + ini "~1.3.0" + minimist "^1.2.0" + strip-json-comments "~2.0.1" + redis-commands@1.4.0, redis-commands@^1.2.0: version "1.4.0" resolved "https://registry.yarnpkg.com/redis-commands/-/redis-commands-1.4.0.tgz#52f9cf99153efcce56a8f86af986bd04e988602f" @@ -703,6 +770,11 @@ stopword@^0.1.13: resolved "https://registry.yarnpkg.com/stopword/-/stopword-0.1.13.tgz#92b26491c443b1a8d9709142ad64ae1af10cea55" integrity sha512-WteqDiQpRyn2yBAm1pwbkXn+SMa8L+WDesd33ovgs0JoheFcrrazMSet4P9LoTRteuUoqVxtEIwEKVZ/z/WHKg== +strip-json-comments@~2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-2.0.1.tgz#3c531942e908c2697c0ec344858c286c7ca0a60a" + integrity sha1-PFMZQukIwml8DsNEhYwobHygpgo= + through@~2.3.4: version "2.3.8" resolved "https://registry.yarnpkg.com/through/-/through-2.3.8.tgz#0dd4c9ffaabc357960b1b724115d7e0e86a2e1f5" From b70e40cb1e741d24bed7fe74d044db82321ed814 Mon Sep 17 00:00:00 2001 From: Brian Lovin Date: Tue, 18 Dec 2018 17:46:45 -0800 Subject: [PATCH 25/37] Fix dm composition --- src/views/directMessages/containers/newThread.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/views/directMessages/containers/newThread.js b/src/views/directMessages/containers/newThread.js index 6bb95fcfab..fe7d04cdd6 100644 --- a/src/views/directMessages/containers/newThread.js +++ b/src/views/directMessages/containers/newThread.js @@ -20,6 +20,7 @@ import { addToastWithTimeout } from '../../../actions/toasts'; import { clearDirectMessagesComposer } from '../../../actions/directMessageThreads'; import createDirectMessageThreadMutation from 'shared/graphql/mutations/directMessageThread/createDirectMessageThread'; import type { Dispatch } from 'redux'; +import { withCurrentUser } from 'src/components/withCurrentUser'; import { ComposerInputWrapper, Grow, @@ -866,6 +867,7 @@ export default compose( withApollo, withRouter, createDirectMessageThreadMutation, + withCurrentUser, // $FlowIssue connect(mapStateToProps) )(NewThread); From b3b64911539966224a45fe51be7519917774efc6 Mon Sep 17 00:00:00 2001 From: thomasroest Date: Wed, 19 Dec 2018 09:28:36 +0100 Subject: [PATCH 26/37] update background-jobs documentation --- docs/workers/background-jobs.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/workers/background-jobs.md b/docs/workers/background-jobs.md index 5e0ad41be1..3a49b1c403 100644 --- a/docs/workers/background-jobs.md +++ b/docs/workers/background-jobs.md @@ -2,7 +2,8 @@ # Background jobs -We use [`bull`](https://github.com/OptimalBits/bull) for all of our background job needs (at the moment that mostly means notification processing and emails). `bull` uses redis under the hood (see docs/setup.md for instructions on how to install redis) to store information about these jobs. +We use [`bull`](https://github.com/OptimalBits/bull) for all of our background job needs (at the moment that mostly means notification processing and emails). `bull` uses redis under the hood to store information about these jobs. You can install redis by following the instructions on +[redis.io/download](https://redis.io/download) or by using homebrew with `brew install redis`. All of our servers and workers connect to the same redis instance, adding and taking jobs as they see fit. In development, that's your local instance. In production, that's a remote instance hosted on [compose.com](https://compose.com). Thusly, redis acts kind of like shared global state that helps our disparate processes talk to each other. From 42b9abdd840abaac5e6a5099430e42daa27c7e2a Mon Sep 17 00:00:00 2001 From: Max Stoiber Date: Wed, 19 Dec 2018 11:26:34 +0100 Subject: [PATCH 27/37] Update background-jobs.md --- docs/workers/background-jobs.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/docs/workers/background-jobs.md b/docs/workers/background-jobs.md index 3a49b1c403..0b5cd41582 100644 --- a/docs/workers/background-jobs.md +++ b/docs/workers/background-jobs.md @@ -2,8 +2,7 @@ # Background jobs -We use [`bull`](https://github.com/OptimalBits/bull) for all of our background job needs (at the moment that mostly means notification processing and emails). `bull` uses redis under the hood to store information about these jobs. You can install redis by following the instructions on -[redis.io/download](https://redis.io/download) or by using homebrew with `brew install redis`. +We use [`bull`](https://github.com/OptimalBits/bull) for all of our background job needs (at the moment that mostly means notification processing and emails). `bull` uses redis under the hood to store information about these jobs. (follow the instructions on [redis.io/download](https://redis.io/download) to install Redis) All of our servers and workers connect to the same redis instance, adding and taking jobs as they see fit. In development, that's your local instance. In production, that's a remote instance hosted on [compose.com](https://compose.com). Thusly, redis acts kind of like shared global state that helps our disparate processes talk to each other. From 62dbb43773e9aeba807721ef9a59b00a5ea47ed9 Mon Sep 17 00:00:00 2001 From: Max Stoiber Date: Wed, 19 Dec 2018 15:13:19 +0100 Subject: [PATCH 28/37] Don't include the req path in the datadog key This is an anti-pattern, as it'll blow up our DataDog storage costs. Instead, we should be using a logging service like Splunk to dig into specific slow requests after noticing abnormalities in the metrics. Will tackle that next most likely, but this should be a good start! Thanks to the folks in #observability for pointing that out! --- shared/middlewares/statsd.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/shared/middlewares/statsd.js b/shared/middlewares/statsd.js index 3fea777f31..c9a0e13615 100644 --- a/shared/middlewares/statsd.js +++ b/shared/middlewares/statsd.js @@ -12,10 +12,8 @@ export default ( next: express$NextFunction ) => { // Set a sensible default req.statsdKey, which is what will be shown in the DataDog UI. Example key: - // hyperion.http.get.spectrum.general - const pathname = req.path.replace(/\?.*/, ''); + // hyperion.http.get // $FlowFixMe - req.statsdKey = `http.${req.method.toLowerCase() || - 'unknown_method'}${pathname.toLowerCase().replace('/', '.')}`; + req.statsdKey = `http.${req.method.toLowerCase() || 'unknown_method'}`; return middleware(req, res, next); }; From 47f0613674931fb6f83a3c6bdd0b82d177a14368 Mon Sep 17 00:00:00 2001 From: Max Stoiber Date: Wed, 19 Dec 2018 15:17:47 +0100 Subject: [PATCH 29/37] Dont track connection pool size in DataDog, track query response times and sizes --- shared/db/db.js | 34 +++++++++++++++------------------- shared/statsd.js | 13 ++++++------- 2 files changed, 21 insertions(+), 26 deletions(-) diff --git a/shared/db/db.js b/shared/db/db.js index 576ba0c1b9..97621d9e33 100644 --- a/shared/db/db.js +++ b/shared/db/db.js @@ -4,6 +4,7 @@ */ import fs from 'fs'; import path from 'path'; +import inspect from 'rethinkdb-inspector'; import { statsd } from '../statsd'; const IS_PROD = !process.env.FORCE_DEV && process.env.NODE_ENV === 'production'; @@ -50,36 +51,31 @@ const config = IS_PROD ...DEFAULT_CONFIG, }; -var r = require('rethinkhaberdashery')(config); - +let r = require('rethinkhaberdashery')(config); const poolMaster = r.getPoolMaster(); poolMaster.on('queueing', size => { - // $FlowFixMe statsd.gauge('db.query_queue.size', size); }); -poolMaster.on('size', connections => { - // $FlowFixMe - statsd.gauge('db.connection_pool.size', connections); -}); - // Exit the process on unhealthy db in test env if (process.env.TEST_DB) { - r.getPoolMaster().on('healthy', healthy => { + poolMaster.on('healthy', healthy => { if (!healthy) { process.exit(1); } }); } -if (process.env.NODE_ENV === 'development' && process.env.TRACK_DB_PERF) { - const fs = require('fs'); - const inspect = require('rethinkdb-inspector'); - const queries = []; - inspect(r, { - onQueryComplete: (query, { size, time }) => { - if (query.indexOf('.changes') > -1) return; +const queries = []; +inspect(r, { + onQueryComplete: (query, { size, time }) => { + if (query.indexOf('.changes') > -1) return; + statsd.increment('db.queries.count'); + statsd.histogram('db.queries.response_time', time); + statsd.histogram('db.queries.response_size', size); + // In development write out a file of the most expensive queries + if (process.env.NODE_ENV === 'development' && process.env.TRACK_DB_PERF) { queries.push({ query, time, size }); fs.writeFileSync( 'queries-by-time.js', @@ -89,8 +85,8 @@ if (process.env.NODE_ENV === 'development' && process.env.TRACK_DB_PERF) { 'queries-by-response-size.js', JSON.stringify(queries.sort((a, b) => b.size - a.size), null, 2) ); - }, - }); -} + } + }, +}); module.exports = { db: r }; diff --git a/shared/statsd.js b/shared/statsd.js index a890e9969c..1de33e9ea5 100644 --- a/shared/statsd.js +++ b/shared/statsd.js @@ -2,15 +2,14 @@ const debug = require('debug')('shared:middlewares:statsd'); import metrics from 'datadog-metrics'; -export let statsd; +export let statsd = { + histogram: (...args: Array) => {}, + timing: (...args: Array) => {}, + increment: (...args: Array) => {}, + gauge: (...args: Array) => {}, +}; if (!process.env.DATADOG_API_KEY) { console.warn('No DATADOG_API_KEY provided, not tracking metrics.'); - statsd = { - histogram: () => {}, - timing: () => {}, - increment: () => {}, - gauge: () => {}, - }; } else { metrics.init({ defaultTags: [`server:${process.env.SENTRY_NAME || 'unknown_server'}`], From 997b9baef6becdb6f3a9062ac59f082dd0ae3fec Mon Sep 17 00:00:00 2001 From: Max Stoiber Date: Wed, 19 Dec 2018 15:20:37 +0100 Subject: [PATCH 30/37] Properly flow-type statsd --- shared/statsd.js | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/shared/statsd.js b/shared/statsd.js index 1de33e9ea5..484e197619 100644 --- a/shared/statsd.js +++ b/shared/statsd.js @@ -2,11 +2,25 @@ const debug = require('debug')('shared:middlewares:statsd'); import metrics from 'datadog-metrics'; +type Tags = { + [key: string]: string, +}; + export let statsd = { - histogram: (...args: Array) => {}, - timing: (...args: Array) => {}, - increment: (...args: Array) => {}, - gauge: (...args: Array) => {}, + histogram: ( + key: string, + value: number, + tags?: Tags, + timestamp?: number + ) => {}, + timing: (key: string, value: number, tags?: Tags, timestamp?: number) => {}, + increment: ( + key: string, + value?: number, + tags?: Tags, + timestamp?: number + ) => {}, + gauge: (key: string, value: number, tags?: Tags, timestamp?: number) => {}, }; if (!process.env.DATADOG_API_KEY) { console.warn('No DATADOG_API_KEY provided, not tracking metrics.'); From 70b1fbedb80b51a78689b28a570ffbb99d3870a1 Mon Sep 17 00:00:00 2001 From: Max Stoiber Date: Wed, 19 Dec 2018 15:39:19 +0100 Subject: [PATCH 31/37] Add statsd logging in dev --- package.json | 2 +- shared/statsd.js | 84 +++++++++++++++++++++++++++++++++++------------- 2 files changed, 62 insertions(+), 24 deletions(-) diff --git a/package.json b/package.json index 5d3b65f191..ed61028f0a 100644 --- a/package.json +++ b/package.json @@ -215,7 +215,7 @@ "start:analytics": "cross-env NODE_ENV=production node build-analytics/main.js", "start:api": "cross-env NODE_ENV=production node build-api/main.js", "dev:web": "cross-env NODE_PATH=./ react-app-rewired start", - "dev:api": "cross-env FILE_STORAGE=local cross-env NODE_PATH=./ cross-env NODE_ENV=development cross-env DEBUG=build*,api*,metrics*,shared:middlewares*,shared:rethinkdb:db-query-cache,-api:resolvers cross-env DIR=api backpack", + "dev:api": "cross-env FILE_STORAGE=local cross-env NODE_PATH=./ cross-env NODE_ENV=development cross-env DEBUG=build*,api*,shared:middlewares*,shared:rethinkdb:db-query-cache,-api:resolvers cross-env DIR=api backpack", "dev:api:s3": "cross-env FILE_STORAGE=s3 cross-env NODE_PATH=./ cross-env NODE_ENV=development cross-env DEBUG=build*,api*,shared:middlewares*,shared:rethinkdb:db-query-cache,-api:resolvers cross-env DIR=api backpack", "dev:athena": "cross-env NODE_PATH=./ cross-env NODE_ENV=development cross-env DEBUG=build*,athena*,shared:middlewares*,-athena:resolvers cross-env DIR=athena backpack", "dev:hermes": "cross-env NODE_PATH=./ cross-env NODE_ENV=development cross-env DEBUG=build*,hermes*,shared:middlewares*,-hermes:resolvers cross-env DIR=hermes backpack", diff --git a/shared/statsd.js b/shared/statsd.js index 484e197619..2dcad88ffb 100644 --- a/shared/statsd.js +++ b/shared/statsd.js @@ -1,41 +1,79 @@ // @flow const debug = require('debug')('shared:middlewares:statsd'); -import metrics from 'datadog-metrics'; type Tags = { [key: string]: string, }; +const stringify = (obj?: { [key: string]: string }): Array => { + if (!obj) return []; + return Object.keys(obj).reduce((arr, key) => { + // $FlowFixMe + return arr.concat([`${key}:${obj[key]}`]); + }, []); +}; + +const log = ( + name: string, + key: string, + value?: number, + tags?: Tags, + timestamp?: number +) => { + let stringTags; + if (!tags && typeof value !== 'number') { + tags = value; + value = undefined; + } + if (tags) { + if (Array.isArray(tags)) { + stringTags = tags.join(','); + } else { + stringTags = stringify(tags).join(','); + } + } + debug( + `${name}: ${key}${value !== undefined ? `:${value}` : ''}${ + stringTags ? `#${stringTags}` : '' + }` + ); +}; + +let counts = {}; export let statsd = { - histogram: ( - key: string, - value: number, - tags?: Tags, - timestamp?: number - ) => {}, - timing: (key: string, value: number, tags?: Tags, timestamp?: number) => {}, - increment: ( - key: string, - value?: number, - tags?: Tags, - timestamp?: number - ) => {}, - gauge: (key: string, value: number, tags?: Tags, timestamp?: number) => {}, + histogram: (key: string, value: number, tags?: Tags, timestamp?: number) => { + log('histogram', key, value, tags, timestamp); + }, + timing: (key: string, value: number, tags?: Tags, timestamp?: number) => { + log('timing', key, value, tags, timestamp); + }, + increment: (key: string, value?: number, tags?: Tags, timestamp?: number) => { + if (!counts[key]) counts[key] = 0; + counts[key] += typeof value === 'number' ? value : 1; + log( + 'increment', + key, + counts[key], + tags || (typeof value !== 'number' && value) || undefined, + timestamp + ); + }, + gauge: (key: string, value: number, tags?: Tags, timestamp?: number) => { + log('gauge', key, value, tags, timestamp); + }, }; -if (!process.env.DATADOG_API_KEY) { +if ( + !process.env.DATADOG_API_KEY || + process.env.DATADOG_API_KEY === 'undefined' +) { console.warn('No DATADOG_API_KEY provided, not tracking metrics.'); } else { + console.warn('Tracking metrics to DataDog.'); + const metrics = require('datadog-metrics'); metrics.init({ defaultTags: [`server:${process.env.SENTRY_NAME || 'unknown_server'}`], }); - // $FlowFixMe - const stringify = (obj?: { [key: string]: string }) => { - if (!obj) return obj; - return Object.keys(obj).reduce((arr, key) => { - return arr.concat([`${key}:${obj[key]}`]); - }, []); - }; // This is necessary for express-hot-shots to work const handleObjectTags = method => { const original = metrics[method]; From 2235a38a7167bd8abd30c3075eddb84604c240d3 Mon Sep 17 00:00:00 2001 From: Brian Lovin Date: Wed, 19 Dec 2018 09:37:37 -0800 Subject: [PATCH 32/37] Log instance hostname --- shared/statsd.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/shared/statsd.js b/shared/statsd.js index 2dcad88ffb..091289a051 100644 --- a/shared/statsd.js +++ b/shared/statsd.js @@ -1,4 +1,5 @@ // @flow +const os = require('os'); const debug = require('debug')('shared:middlewares:statsd'); type Tags = { @@ -71,7 +72,10 @@ if ( console.warn('Tracking metrics to DataDog.'); const metrics = require('datadog-metrics'); metrics.init({ - defaultTags: [`server:${process.env.SENTRY_NAME || 'unknown_server'}`], + defaultTags: [ + `server:${process.env.SENTRY_NAME || 'unknown_server'}`, + `hostname: ${os.hostname() || 'unknown_instance_hostname'}`, + ], }); // This is necessary for express-hot-shots to work From 15b1606a0d335f35eaa27349819865323afdb1e0 Mon Sep 17 00:00:00 2001 From: Brian Lovin Date: Wed, 19 Dec 2018 09:59:23 -0800 Subject: [PATCH 33/37] Upgrade apollo-cache-inmemory --- package.json | 4 ++-- yarn.lock | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/package.json b/package.json index ed61028f0a..227ac35a9a 100644 --- a/package.json +++ b/package.json @@ -53,7 +53,7 @@ "algoliasearch": "^3.30.0", "amplitude": "^3.5.0", "amplitude-js": "^4.4.0", - "apollo-cache-inmemory": "^1.3.11", + "apollo-cache-inmemory": "1.3.12-beta.0", "apollo-client": "^2.4.7", "apollo-link": "^1.2.4", "apollo-link-http": "^1.5.7", @@ -283,4 +283,4 @@ ] }, "pre-commit": "lint:staged" -} \ No newline at end of file +} diff --git a/yarn.lock b/yarn.lock index f00d155b37..c7b5946e3e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1434,14 +1434,14 @@ apollo-cache-control@0.4.0: apollo-server-env "2.2.0" graphql-extensions "0.4.0" -apollo-cache-inmemory@^1.3.11: - version "1.3.11" - resolved "https://registry.yarnpkg.com/apollo-cache-inmemory/-/apollo-cache-inmemory-1.3.11.tgz#6cb8f24ec812715169f9acbb0b67833f9a19ec90" - integrity sha512-fSoyjBV5RV57J3i/VHDDB74ZgXc0PFiogheNFHEhC0mL6rg5e/DjTx0Vg+csIBk23gvlzTvV+eypx7Q2NJ+dYg== +apollo-cache-inmemory@1.3.12-beta.0: + version "1.3.12-beta.0" + resolved "https://registry.yarnpkg.com/apollo-cache-inmemory/-/apollo-cache-inmemory-1.3.12-beta.0.tgz#7c7e659fd0ad41f744ea977f24b471ff5a1ffc8b" + integrity sha512-bTQONAbg4KXPw64aj8xeifB4W50Hy2qsRqgsXfSbVDSg/799lFTuz9V3GWVi1PqUFyC7B3rzyEopGCVrRA1GUA== dependencies: apollo-cache "^1.1.21" apollo-utilities "^1.0.26" - optimism "^0.6.6" + optimism "^0.6.8" apollo-cache@1.1.21, apollo-cache@^1.1.21: version "1.1.21" @@ -10536,7 +10536,7 @@ opn@^5.1.0: dependencies: is-wsl "^1.1.0" -optimism@^0.6.6: +optimism@^0.6.8: version "0.6.8" resolved "https://registry.yarnpkg.com/optimism/-/optimism-0.6.8.tgz#0780b546da8cd0a72e5207e0c3706c990c8673a6" integrity sha512-bN5n1KCxSqwBDnmgDnzMtQTHdL+uea2HYFx1smvtE+w2AMl0Uy31g0aXnP/Nt85OINnMJPRpJyfRQLTCqn5Weg== From d2cb7d780e04eed5deaffeb17af74d74ca7aedf5 Mon Sep 17 00:00:00 2001 From: Brian Lovin Date: Wed, 19 Dec 2018 13:17:11 -0800 Subject: [PATCH 34/37] Dont use alpha version of new apollo inmemory --- package.json | 4 ++-- yarn.lock | 28 +++++++++++++++++++++------- 2 files changed, 23 insertions(+), 9 deletions(-) diff --git a/package.json b/package.json index 227ac35a9a..96d46798a3 100644 --- a/package.json +++ b/package.json @@ -53,7 +53,7 @@ "algoliasearch": "^3.30.0", "amplitude": "^3.5.0", "amplitude-js": "^4.4.0", - "apollo-cache-inmemory": "1.3.12-beta.0", + "apollo-cache-inmemory": "1.3.12", "apollo-client": "^2.4.7", "apollo-link": "^1.2.4", "apollo-link-http": "^1.5.7", @@ -283,4 +283,4 @@ ] }, "pre-commit": "lint:staged" -} +} \ No newline at end of file diff --git a/yarn.lock b/yarn.lock index c7b5946e3e..85031d3130 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1434,22 +1434,29 @@ apollo-cache-control@0.4.0: apollo-server-env "2.2.0" graphql-extensions "0.4.0" -apollo-cache-inmemory@1.3.12-beta.0: - version "1.3.12-beta.0" - resolved "https://registry.yarnpkg.com/apollo-cache-inmemory/-/apollo-cache-inmemory-1.3.12-beta.0.tgz#7c7e659fd0ad41f744ea977f24b471ff5a1ffc8b" - integrity sha512-bTQONAbg4KXPw64aj8xeifB4W50Hy2qsRqgsXfSbVDSg/799lFTuz9V3GWVi1PqUFyC7B3rzyEopGCVrRA1GUA== +apollo-cache-inmemory@1.3.12: + version "1.3.12" + resolved "https://registry.yarnpkg.com/apollo-cache-inmemory/-/apollo-cache-inmemory-1.3.12.tgz#cf7ef7c15730d0b6787d79047d5c06087ac31991" + integrity sha512-jxWcW64QoYQZ09UH6v3syvCCl3MWr6bsxT3wYYL6ORi8svdJUpnNrHTcv5qXqJYVg/a+NHhfEt+eGjJUG2ytXA== dependencies: - apollo-cache "^1.1.21" - apollo-utilities "^1.0.26" + apollo-cache "^1.1.22" + apollo-utilities "^1.0.27" optimism "^0.6.8" -apollo-cache@1.1.21, apollo-cache@^1.1.21: +apollo-cache@1.1.21: version "1.1.21" resolved "https://registry.yarnpkg.com/apollo-cache/-/apollo-cache-1.1.21.tgz#950025e2272741ba8e5064419906e3ac4072925d" integrity sha512-5ErNb78KHtrJNimkDBTEigcvHkIqUmS7QJIk4lpZZ+XLVVgvk2fD+GhD1PLP+s8vHfAKVbO6vdbRxCCjGGrh5w== dependencies: apollo-utilities "^1.0.26" +apollo-cache@^1.1.22: + version "1.1.22" + resolved "https://registry.yarnpkg.com/apollo-cache/-/apollo-cache-1.1.22.tgz#d4682ea6e8b2508a934f61c2fd9e36b4a65041d9" + integrity sha512-8PoxhQLISj2oHwT7i/r4l+ly4y3RKZls+dtXzAewu3U77P9dNZKhYkRNAhx9iEfsrNoHgXBV8vMp64hb1uYh+g== + dependencies: + apollo-utilities "^1.0.27" + apollo-client@^2.4.7: version "2.4.7" resolved "https://registry.yarnpkg.com/apollo-client/-/apollo-client-2.4.7.tgz#b6712fd4c9ba346e3c44cfec7e6868e532b6a957" @@ -1654,6 +1661,13 @@ apollo-utilities@1.0.26, apollo-utilities@^1.0.0, apollo-utilities@^1.0.1, apoll dependencies: fast-json-stable-stringify "^2.0.0" +apollo-utilities@^1.0.27: + version "1.0.27" + resolved "https://registry.yarnpkg.com/apollo-utilities/-/apollo-utilities-1.0.27.tgz#77c550f9086552376eca3a48e234a1466b5b057e" + integrity sha512-nzrMQ89JMpNmYnVGJ4t8zN75gQbql27UDhlxNi+3OModp0Masx5g+fQmQJ5B4w2dpRuYOsdwFLmj3lQbwOKV1Q== + dependencies: + fast-json-stable-stringify "^2.0.0" + app-root-path@^2.0.0: version "2.1.0" resolved "https://registry.yarnpkg.com/app-root-path/-/app-root-path-2.1.0.tgz#98bf6599327ecea199309866e8140368fd2e646a" From 47dd328e7f05b628103f80b8c646cb3a14c43563 Mon Sep 17 00:00:00 2001 From: Brian Lovin Date: Wed, 19 Dec 2018 13:18:44 -0800 Subject: [PATCH 35/37] 2.5.5 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index ad9f7a76bd..f617c42f37 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "Spectrum", - "version": "2.5.4", + "version": "2.5.5", "license": "BSD-3-Clause", "devDependencies": { "@babel/preset-flow": "^7.0.0", From 91259060475308c2b32e9214238b9967b5ffdbdf Mon Sep 17 00:00:00 2001 From: Brian Lovin Date: Wed, 19 Dec 2018 14:05:25 -0800 Subject: [PATCH 36/37] Add codesandbox to explore --- src/views/explore/collections.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/views/explore/collections.js b/src/views/explore/collections.js index 02eefaff22..6e2aa7b365 100644 --- a/src/views/explore/collections.js +++ b/src/views/explore/collections.js @@ -5,6 +5,7 @@ export const collections = [ communities: [ 'spectrum', 'zeit', + 'codesandbox', 'codepen', 'next-js', 'figma', @@ -77,6 +78,7 @@ export const collections = [ 'react', 'next-js', 'node', + 'codesandbox', 'vue-js', 'angular', 'ember-js', From 104ad9525634b8acae746500ea2b10e4c89025f2 Mon Sep 17 00:00:00 2001 From: Brian Lovin Date: Wed, 19 Dec 2018 14:05:47 -0800 Subject: [PATCH 37/37] Add codesandbox url regex for better embeds --- src/components/rich-text-editor/Embed.js | 9 +++++++++ src/helpers/regexps.js | 4 +++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/components/rich-text-editor/Embed.js b/src/components/rich-text-editor/Embed.js index 3948f76a41..fbe8adb761 100644 --- a/src/components/rich-text-editor/Embed.js +++ b/src/components/rich-text-editor/Embed.js @@ -11,6 +11,7 @@ import { YOUTUBE_URLS, VIMEO_URLS, CODEPEN_URLS, + CODESANDBOX_URLS, } from '../../helpers/regexps'; import addProtocolToString from 'shared/normalize-url'; @@ -82,6 +83,14 @@ export const parseEmbedUrl = incomingUrl => { }; } + const isCodeSandboxUrl = url.match(CODESANDBOX_URLS); + if (isCodeSandboxUrl) { + return { + url, + height: 500, + }; + } + if (!isURL(url)) return null; return { diff --git a/src/helpers/regexps.js b/src/helpers/regexps.js index 5ffa993954..7a7829f290 100644 --- a/src/helpers/regexps.js +++ b/src/helpers/regexps.js @@ -3,7 +3,7 @@ export const URLS = /https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,4 // eslint-disable-next-line export const FIGMA_URLS = /https:\/\/([w.-]+.)?figma.com\/(file|proto)\/([0-9a-zA-Z]{22,128})(?:\/.*)?$/gi; // eslint-disable-next-line -export const YOUTUBE_URLS = /(?:[?&]v=|\/embed\/|\/1\/|\/v\/|https:\/\/(?:www\.)?youtu\.be\/)([^&\n?#]+)/gi; +export const YOUTUBE_URLS = /http(?:s?):\/\/(?:www\.)?youtu(?:be\.com\/watch\?v=|\.be\/)([\w\-\_]*)(&(amp;)?‌​[\w\?‌​=]*)?/gi; // eslint-disable-next-line export const VIMEO_URLS = /\/\/(?:www\.)?vimeo.com\/([0-9a-z\-_]+)/gi; // eslint-disable-next-line @@ -13,4 +13,6 @@ export const FRAMER_URLS = /(https?:\/\/(.+?\.)?framer\.cloud(\/[A-Za-z0-9\-\._~ // eslint-disable-next-line export const CODEPEN_URLS = /(https?:\/\/)?(.+?\.)?codepen\.io(\/[A-Za-z0-9\-\._~:\/\?#\[\]@!$&'\(\)\*\+,;\=]*)?/gi; // eslint-disable-next-line +export const CODESANDBOX_URLS = /(https?:\/\/)?(.+?\.)?codesandbox\.io(\/[A-Za-z0-9\-\._~:\/\?#\[\]@!$&'\(\)\*\+,;\=]*)?/gi; +// eslint-disable-next-line export const ENDS_IN_WHITESPACE = /(\s|\n)$/;