Skip to content
This repository has been archived by the owner on Oct 11, 2022. It is now read-only.

Add StatsD tracking #4444

Merged
merged 29 commits into from
Dec 19, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
b545026
Add hot-shots dependency
Dec 11, 2018
94b023c
Integrate StatsD tracking into API and hyperion
Dec 11, 2018
c17286c
Dont double-create statsd clients
Dec 11, 2018
77c07e0
Log statsd metrics in dev
Dec 11, 2018
3fbbc2e
Fix flowtype
Dec 11, 2018
00afdf1
Track database connection count and queue size in DataDog
Dec 11, 2018
935500c
Merge pull request #4445 from withspectrum/track-db-connection-count-…
mxstbr Dec 11, 2018
0e0fec8
Switch to express-hot-shots fork
Dec 11, 2018
5fa512c
Switch to tagging the GraphQL operation name in StatsD
Dec 11, 2018
820d86f
More consistent naming for db metrics
Dec 11, 2018
f330c2f
Switch to datadog-metrics package
Dec 18, 2018
138ad62
Merge alpha and fix conflicts
brianlovin Dec 18, 2018
76abdf4
Silence flow for now
brianlovin Dec 18, 2018
0bffb3d
Merge branch 'alpha' of github.com:withspectrum/spectrum into statsd
brianlovin Dec 18, 2018
7b7f439
Remove trailing comma in now json
brianlovin Dec 18, 2018
503be0b
Add statsd to hyperion
brianlovin Dec 18, 2018
f629501
Fix missing bracket in now json
brianlovin Dec 18, 2018
71043b3
Fix ordering of bodyparser in hyperion middlewares
brianlovin Dec 18, 2018
42d05ac
Dont let a missing req.body braek logging middleware
brianlovin Dec 18, 2018
5ae798b
Set db min and max to the same amount
brianlovin Dec 18, 2018
5f9a210
Add datadog to all workers
brianlovin Dec 18, 2018
2ffc3c1
Merge branch 'alpha' of github.com:withspectrum/spectrum into statsd
brianlovin Dec 19, 2018
62dbb43
Don't include the req path in the datadog key
Dec 19, 2018
47f0613
Dont track connection pool size in DataDog, track query response time…
Dec 19, 2018
997b9ba
Properly flow-type statsd
Dec 19, 2018
70b1fbe
Add statsd logging in dev
Dec 19, 2018
30f6d08
Merge branch 'statsd' of github.com:withspectrum/spectrum into statsd
brianlovin Dec 19, 2018
6e28e4b
Merge branch 'alpha' of github.com:withspectrum/spectrum into statsd
brianlovin Dec 19, 2018
2235a38
Log instance hostname
brianlovin Dec 19, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions analytics/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
67 changes: 67 additions & 0 deletions analytics/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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"

[email protected]:
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"
Expand All @@ -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"
Expand All @@ -159,6 +184,16 @@ denque@^1.1.0:
resolved "https://registry.yarnpkg.com/denque/-/denque-1.4.0.tgz#79e2f0490195502107f24d9553f374837dabc916"
integrity sha512-gh513ac7aiKrAgjiIBWZG0EASyDF9p4JMWwKA8YU5s9figrL5SRNEMT6FDynsegakuhWd1wVqTvqvqAoDxw7wQ==

[email protected]:
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"

[email protected]:
version "1.1.1"
resolved "https://registry.yarnpkg.com/events/-/events-1.1.1.tgz#9ebdb7635ad099c70dcc4c2a1f5004288e8bd924"
Expand Down Expand Up @@ -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==

[email protected], ioredis@^3.1.4:
version "3.2.2"
resolved "https://registry.yarnpkg.com/ioredis/-/ioredis-3.2.2.tgz#b7d5ff3afd77bb9718bb2821329b894b9a44c00b"
Expand Down Expand Up @@ -275,6 +315,13 @@ [email protected]:
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"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down
4 changes: 4 additions & 0 deletions api/apollo-server.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ const server = new ProtectedApolloServer({
};
}

// 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;

Expand Down
4 changes: 4 additions & 0 deletions api/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import Raven from 'shared/raven';
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';
Expand All @@ -36,6 +37,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);
Expand Down
5 changes: 4 additions & 1 deletion api/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"engines": {
"node": "10.7.0"
"node": "^10.0.0"
},
"dependencies": {
"algoliasearch": "^3.32.0",
Expand All @@ -24,6 +24,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",
Expand All @@ -42,6 +43,7 @@
"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",
"faker": "^4.1.0",
"find-with-regex": "^1.1.3",
Expand All @@ -57,6 +59,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",
Expand Down
50 changes: 49 additions & 1 deletion api/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2201,6 +2201,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"
Expand Down Expand Up @@ -3116,6 +3121,14 @@ [email protected]:
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"
Expand Down Expand Up @@ -3353,6 +3366,16 @@ [email protected]:
resolved "https://registry.yarnpkg.com/dns-prefetch-control/-/dns-prefetch-control-0.1.0.tgz#60ddb457774e178f1f9415f0cabb0e85b0b300b2"
integrity sha1-YN20V3dOF48flBXwyrsOhbCzALI=

[email protected]:
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"
Expand Down Expand Up @@ -3895,6 +3918,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"
Expand Down Expand Up @@ -4795,6 +4826,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==

[email protected]:
version "2.0.0"
resolved "https://registry.yarnpkg.com/hpkp/-/hpkp-2.0.0.tgz#10e142264e76215a5d30c44ec43de64dee6d1672"
Expand Down Expand Up @@ -5821,6 +5857,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"
Expand Down Expand Up @@ -6860,6 +6903,11 @@ [email protected]:
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"
Expand Down Expand Up @@ -7625,7 +7673,7 @@ [email protected]:
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==
Expand Down
1 change: 1 addition & 0 deletions athena/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Loading