Skip to content

Commit

Permalink
feat(apm): added apm configuration setup (#167)
Browse files Browse the repository at this point in the history
* feat(apm): added apm configuration setup

* chore(core): moved apm setup inside separate function
  • Loading branch information
michaelmass committed Sep 3, 2021
1 parent df8b354 commit a1cc6a0
Show file tree
Hide file tree
Showing 4 changed files with 102 additions and 2 deletions.
1 change: 1 addition & 0 deletions packages/server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
},
"dependencies": {
"@botpress/messaging-base": "0.0.1",
"@sentry/node": "^6.11.0",
"@slack/events-api": "^2.3.2",
"@slack/interactive-messages": "^1.5.0",
"@slack/rtm-api": "^5.0.3",
Expand Down
25 changes: 25 additions & 0 deletions packages/server/src/api.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import * as Sentry from '@sentry/node'
import cors from 'cors'
import express, { Request, Response, Router } from 'express'
import yn from 'yn'
import { App } from './app'
import { ChannelApi } from './channels/api'
import { ChatApi } from './chat/api'
Expand Down Expand Up @@ -50,6 +52,7 @@ export class Api {
}

async setup() {
this.setupApm()
await this.setupPassword()

this.root.get('/version', this.version)
Expand All @@ -66,6 +69,28 @@ export class Api {
await this.conversations.setup()
await this.messages.setup()
await this.channels.setup()

this.setupApmErrorHandler()
}

setupApm() {
const apmEnabled = yn(process.env.APM_ENABLED)

if (apmEnabled) {
Sentry.init({
integrations: [new Sentry.Integrations.Http({})]
})

this.root.use(Sentry.Handlers.requestHandler())
}
}

setupApmErrorHandler() {
const apmEnabled = yn(process.env.APM_ENABLED)

if (apmEnabled) {
this.root.use(Sentry.Handlers.errorHandler())
}
}

async setupPassword() {
Expand Down
1 change: 1 addition & 0 deletions packages/server/src/global.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export interface MessagingEnv {
BATCHING_ENABLED?: string
NO_LOGO?: string
SINGLE_LINE_LOGGING?: string
APM_ENABLED?: string
DISABLE_LOGGING_TIMESTAMP?: string
AUTO_MIGRATE?: string
MIGRATE_TARGET?: string
Expand Down
77 changes: 75 additions & 2 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1311,6 +1311,74 @@
chrome-trace-event "^1.0.2"
nullthrows "^1.1.1"

"@sentry/core@6.11.0":
version "6.11.0"
resolved "https://registry.yarnpkg.com/@sentry/core/-/core-6.11.0.tgz#40e94043afcf6407a109be26655c77832c64e740"
integrity sha512-09TB+f3pqEq8LFahFWHO6I/4DxHo+NcS52OkbWMDqEi6oNZRD7PhPn3i14LfjsYVv3u3AESU8oxSEGbFrr2UjQ==
dependencies:
"@sentry/hub" "6.11.0"
"@sentry/minimal" "6.11.0"
"@sentry/types" "6.11.0"
"@sentry/utils" "6.11.0"
tslib "^1.9.3"

"@sentry/hub@6.11.0":
version "6.11.0"
resolved "https://registry.yarnpkg.com/@sentry/hub/-/hub-6.11.0.tgz#ddf9ddb0577d1c8290dc02c0242d274fe84d6c16"
integrity sha512-pT9hf+ZJfVFpoZopoC+yJmFNclr4NPqPcl2cgguqCHb69DklD1NxgBNWK8D6X05qjnNFDF991U6t1mxP9HrGuw==
dependencies:
"@sentry/types" "6.11.0"
"@sentry/utils" "6.11.0"
tslib "^1.9.3"

"@sentry/minimal@6.11.0":
version "6.11.0"
resolved "https://registry.yarnpkg.com/@sentry/minimal/-/minimal-6.11.0.tgz#806d5512658370e40827b3e3663061db708fff33"
integrity sha512-XkZ7qrdlGp4IM/gjGxf1Q575yIbl5RvPbg+WFeekpo16Ufvzx37Mr8c2xsZaWosISVyE6eyFpooORjUlzy8EDw==
dependencies:
"@sentry/hub" "6.11.0"
"@sentry/types" "6.11.0"
tslib "^1.9.3"

"@sentry/node@^6.11.0":
version "6.11.0"
resolved "https://registry.yarnpkg.com/@sentry/node/-/node-6.11.0.tgz#62614c18af779373a12311f2fb57a8dde278425a"
integrity sha512-vbk+V/n7ZIFD8rHPYy03t/gIG5V7LGdjU4qJxVDgNZzticfWPnd2sLgle/r+l60XF6SKW/epG4rnxnBcgPdWaw==
dependencies:
"@sentry/core" "6.11.0"
"@sentry/hub" "6.11.0"
"@sentry/tracing" "6.11.0"
"@sentry/types" "6.11.0"
"@sentry/utils" "6.11.0"
cookie "^0.4.1"
https-proxy-agent "^5.0.0"
lru_map "^0.3.3"
tslib "^1.9.3"

"@sentry/tracing@6.11.0":
version "6.11.0"
resolved "https://registry.yarnpkg.com/@sentry/tracing/-/tracing-6.11.0.tgz#9bd9287addea1ebc12c75b226f71c7713c0fac4f"
integrity sha512-9VA1/SY++WeoMQI4K6n/sYgIdRtCu9NLWqmGqu/5kbOtESYFgAt1DqSyqGCr00ZjQiC2s7tkDkTNZb38K6KytQ==
dependencies:
"@sentry/hub" "6.11.0"
"@sentry/minimal" "6.11.0"
"@sentry/types" "6.11.0"
"@sentry/utils" "6.11.0"
tslib "^1.9.3"

"@sentry/types@6.11.0":
version "6.11.0"
resolved "https://registry.yarnpkg.com/@sentry/types/-/types-6.11.0.tgz#5122685478d32ddacd3a891cbcf550012df85f7c"
integrity sha512-gm5H9eZhL6bsIy/h3T+/Fzzz2vINhHhqd92CjHle3w7uXdTdFV98i2pDpErBGNTSNzbntqOMifYEB5ENtZAvcg==

"@sentry/utils@6.11.0":
version "6.11.0"
resolved "https://registry.yarnpkg.com/@sentry/utils/-/utils-6.11.0.tgz#d1dee4faf4d9c42c54bba88d5a66fb96b902a14c"
integrity sha512-IOvyFHcnbRQxa++jO+ZUzRvFHEJ1cZjrBIQaNVc0IYF0twUOB5PTP6joTcix38ldaLeapaPZ9LGfudbvYvxkdg==
dependencies:
"@sentry/types" "6.11.0"
tslib "^1.9.3"

"@sideway/address@^4.1.0":
version "4.1.2"
resolved "https://registry.yarnpkg.com/@sideway/address/-/address-4.1.2.tgz#811b84333a335739d3969cfc434736268170cad1"
Expand Down Expand Up @@ -3347,7 +3415,7 @@ cookie@0.4.0:
resolved "https://registry.yarnpkg.com/cookie/-/cookie-0.4.0.tgz#beb437e7022b3b6d49019d088665303ebe9c14ba"
integrity sha512-+Hp8fLp57wnUSt0tY0tHEXh4voZRDnoIrZPqlo3DPiI4y9lwg/jqx+1Om94/W6ZaPDOUbnjOt/99w66zk+l1Xg==

cookie@~0.4.1:
cookie@^0.4.1, cookie@~0.4.1:
version "0.4.1"
resolved "https://registry.yarnpkg.com/cookie/-/cookie-0.4.1.tgz#afd713fe26ebd21ba95ceb61f9a8116e50a537d1"
integrity sha512-ZwrFkGJxUR3EIoXtO+yVE69Eb7KlixbaeAWfBQB9vVsNn/o+Yw69gBWSSDK825hQNdN+wF8zELf3dFNl/kxkUA==
Expand Down Expand Up @@ -7092,6 +7160,11 @@ lru-queue@^0.1.0:
dependencies:
es5-ext "~0.10.2"

lru_map@^0.3.3:
version "0.3.3"
resolved "https://registry.yarnpkg.com/lru_map/-/lru_map-0.3.3.tgz#b5c8351b9464cbd750335a79650a0ec0e56118dd"
integrity sha1-tcg1G5Rky9dQM1p5ZQoOwOVhGN0=

make-dir@^3.0.0:
version "3.1.0"
resolved "https://registry.yarnpkg.com/make-dir/-/make-dir-3.1.0.tgz#415e967046b3a7f1d185277d84aa58203726a13f"
Expand Down Expand Up @@ -10496,7 +10569,7 @@ tsconfig@^7.0.0:
strip-bom "^3.0.0"
strip-json-comments "^2.0.0"

tslib@^1.8.1, tslib@^1.9.2:
tslib@^1.8.1, tslib@^1.9.2, tslib@^1.9.3:
version "1.14.1"
resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.14.1.tgz#cf2d38bdc34a134bcaf1091c41f6619e2f672d00"
integrity sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==
Expand Down

0 comments on commit a1cc6a0

Please sign in to comment.