diff --git a/package-lock.json b/package-lock.json index 445a22c..24ddb4e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,8 +10,6 @@ "dependencies": { "@grpc/grpc-js": "^1.3.2", "@grpc/proto-loader": "^0.6.2", - "@sentry/node": "^6.7.2", - "@sentry/tracing": "^6.7.2", "ajv": "^8.6.0", "consola": "^2.15.3", "currency-codes": "^2.1.0", @@ -29,7 +27,6 @@ "locale-code": "^2.0.2", "mali": "^0.44.0", "pg": "^8.6.0", - "pg-query-stream": "^4.1.0", "semver": "^7.3.5", "under-pressure": "^5.7.0", "uuid": "^8.3.2" @@ -811,101 +808,6 @@ "resolved": "https://registry.npmjs.org/@protobufjs/utf8/-/utf8-1.1.0.tgz", "integrity": "sha1-p3c2C1s5oaLlEG+OhY8v0tBgxXA=" }, - "node_modules/@sentry/core": { - "version": "6.7.2", - "resolved": "https://registry.npmjs.org/@sentry/core/-/core-6.7.2.tgz", - "integrity": "sha512-NTZqwN5nR94yrXmSfekoPs1mIFuKvf8esdIW/DadwSKWAdLJwQTJY9xK/8PQv+SEzd7wiitPAx+mCw2By1xiNQ==", - "dependencies": { - "@sentry/hub": "6.7.2", - "@sentry/minimal": "6.7.2", - "@sentry/types": "6.7.2", - "@sentry/utils": "6.7.2", - "tslib": "^1.9.3" - }, - "engines": { - "node": ">=6" - } - }, - "node_modules/@sentry/hub": { - "version": "6.7.2", - "resolved": "https://registry.npmjs.org/@sentry/hub/-/hub-6.7.2.tgz", - "integrity": "sha512-05qVW6ymChJsXag4+fYCQokW3AcABIgcqrVYZUBf6GMU/Gbz5SJqpV7y1+njwWvnPZydMncP9LaDVpMKbE7UYQ==", - "dependencies": { - "@sentry/types": "6.7.2", - "@sentry/utils": "6.7.2", - "tslib": "^1.9.3" - }, - "engines": { - "node": ">=6" - } - }, - "node_modules/@sentry/minimal": { - "version": "6.7.2", - "resolved": "https://registry.npmjs.org/@sentry/minimal/-/minimal-6.7.2.tgz", - "integrity": "sha512-jkpwFv2GFHoVl5vnK+9/Q+Ea8eVdbJ3hn3/Dqq9MOLFnVK7ED6MhdHKLT79puGSFj+85OuhM5m2Q44mIhyS5mw==", - "dependencies": { - "@sentry/hub": "6.7.2", - "@sentry/types": "6.7.2", - "tslib": "^1.9.3" - }, - "engines": { - "node": ">=6" - } - }, - "node_modules/@sentry/node": { - "version": "6.7.2", - "resolved": "https://registry.npmjs.org/@sentry/node/-/node-6.7.2.tgz", - "integrity": "sha512-vfNTmxBbHthAKPDBo0gVk/aNHdgUfXLzmaK7FgWO7cISiI2soCfvKEIP61XqIFZru06teqcRuDsYlR4wSeyWpg==", - "dependencies": { - "@sentry/core": "6.7.2", - "@sentry/hub": "6.7.2", - "@sentry/tracing": "6.7.2", - "@sentry/types": "6.7.2", - "@sentry/utils": "6.7.2", - "cookie": "^0.4.1", - "https-proxy-agent": "^5.0.0", - "lru_map": "^0.3.3", - "tslib": "^1.9.3" - }, - "engines": { - "node": ">=6" - } - }, - "node_modules/@sentry/tracing": { - "version": "6.7.2", - "resolved": "https://registry.npmjs.org/@sentry/tracing/-/tracing-6.7.2.tgz", - "integrity": "sha512-juKlI7FICKONWJFJxDxerj0A+8mNRhmtrdR+OXFqOkqSAy/QXlSFZcA/j//O19k2CfwK1BrvoMcQ/4gnffUOVg==", - "dependencies": { - "@sentry/hub": "6.7.2", - "@sentry/minimal": "6.7.2", - "@sentry/types": "6.7.2", - "@sentry/utils": "6.7.2", - "tslib": "^1.9.3" - }, - "engines": { - "node": ">=6" - } - }, - "node_modules/@sentry/types": { - "version": "6.7.2", - "resolved": "https://registry.npmjs.org/@sentry/types/-/types-6.7.2.tgz", - "integrity": "sha512-h21Go/PfstUN+ZV6SbwRSZVg9GXRJWdLfHoO5PSVb3TVEMckuxk8tAE57/u+UZDwX8wu+Xyon2TgsKpiWKxqUg==", - "engines": { - "node": ">=6" - } - }, - "node_modules/@sentry/utils": { - "version": "6.7.2", - "resolved": "https://registry.npmjs.org/@sentry/utils/-/utils-6.7.2.tgz", - "integrity": "sha512-9COL7aaBbe61Hp5BlArtXZ1o/cxli1NGONLPrVT4fMyeQFmLonhUiy77NdsW19XnvhvaA+2IoV5dg3dnFiF/og==", - "dependencies": { - "@sentry/types": "6.7.2", - "tslib": "^1.9.3" - }, - "engines": { - "node": ">=6" - } - }, "node_modules/@sindresorhus/is": { "version": "0.14.0", "resolved": "https://registry.npmjs.org/@sindresorhus/is/-/is-0.14.0.tgz", @@ -987,17 +889,6 @@ "acorn": "^6.0.0 || ^7.0.0 || ^8.0.0" } }, - "node_modules/agent-base": { - "version": "6.0.2", - "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-6.0.2.tgz", - "integrity": "sha512-RZNwNclF7+MS/8bDg70amg32dyeZGZxiDuQmZxKLAlQjr3jGyLx+4Kkk58UO7D2QdgFIQCovuSuZESne6RG6XQ==", - "dependencies": { - "debug": "4" - }, - "engines": { - "node": ">= 6.0.0" - } - }, "node_modules/aggregate-error": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/aggregate-error/-/aggregate-error-3.1.0.tgz", @@ -3757,18 +3648,6 @@ "node": ">= 0.6" } }, - "node_modules/https-proxy-agent": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-5.0.0.tgz", - "integrity": "sha512-EkYm5BcKUGiduxzSt3Eppko+PiNWNEpa4ySk9vTC6wDsQJW9rHSa+UhGNJoRYp7bz6Ht1eaRIa6QaJqO5rCFbA==", - "dependencies": { - "agent-base": "6", - "debug": "4" - }, - "engines": { - "node": ">= 6" - } - }, "node_modules/iconv-lite": { "version": "0.4.24", "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", @@ -4707,11 +4586,6 @@ "node": ">=0.10.0" } }, - "node_modules/lru_map": { - "version": "0.3.3", - "resolved": "https://registry.npmjs.org/lru_map/-/lru_map-0.3.3.tgz", - "integrity": "sha1-tcg1G5Rky9dQM1p5ZQoOwOVhGN0=" - }, "node_modules/lru-cache": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", @@ -5640,14 +5514,6 @@ "resolved": "https://registry.npmjs.org/pg-connection-string/-/pg-connection-string-2.4.0.tgz", "integrity": "sha512-3iBXuv7XKvxeMrIgym7njT+HlZkwZqqGX4Bu9cci8xHZNT+Um1gWKqCsAzcC0d95rcKMU5WBg6YRUcHyV0HZKQ==" }, - "node_modules/pg-cursor": { - "version": "2.6.0", - "resolved": "https://registry.npmjs.org/pg-cursor/-/pg-cursor-2.6.0.tgz", - "integrity": "sha512-BFLg40CTgBJ+LX9EwqjztUYaKxpxLffMmDTmlQNMCustX/JxMTYimxRkdhZvPYZGp++/2LjuqkKtO5DVVq0FNg==", - "peerDependencies": { - "pg": "^8" - } - }, "node_modules/pg-int8": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/pg-int8/-/pg-int8-1.0.1.tgz", @@ -5669,14 +5535,6 @@ "resolved": "https://registry.npmjs.org/pg-protocol/-/pg-protocol-1.5.0.tgz", "integrity": "sha512-muRttij7H8TqRNu/DxrAJQITO4Ac7RmX3Klyr/9mJEOBeIpgnF8f9jAfRz5d3XwQZl5qBjF9gLsUtMPJE0vezQ==" }, - "node_modules/pg-query-stream": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/pg-query-stream/-/pg-query-stream-4.1.0.tgz", - "integrity": "sha512-QbupRwS1JHqRVmNLQax4dIENgi+HoT7ToEn+rCcWqsZ/fbjTVdV+RmeZJRSMIcDhza3CImb/yAsTN0g2UGy6vg==", - "dependencies": { - "pg-cursor": "^2.6.0" - } - }, "node_modules/pg-types": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/pg-types/-/pg-types-2.2.0.tgz", @@ -7154,11 +7012,6 @@ "strip-bom": "^3.0.0" } }, - "node_modules/tslib": { - "version": "1.14.1", - "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz", - "integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==" - }, "node_modules/type-check": { "version": "0.4.0", "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.4.0.tgz", @@ -8170,80 +8023,6 @@ "resolved": "https://registry.npmjs.org/@protobufjs/utf8/-/utf8-1.1.0.tgz", "integrity": "sha1-p3c2C1s5oaLlEG+OhY8v0tBgxXA=" }, - "@sentry/core": { - "version": "6.7.2", - "resolved": "https://registry.npmjs.org/@sentry/core/-/core-6.7.2.tgz", - "integrity": "sha512-NTZqwN5nR94yrXmSfekoPs1mIFuKvf8esdIW/DadwSKWAdLJwQTJY9xK/8PQv+SEzd7wiitPAx+mCw2By1xiNQ==", - "requires": { - "@sentry/hub": "6.7.2", - "@sentry/minimal": "6.7.2", - "@sentry/types": "6.7.2", - "@sentry/utils": "6.7.2", - "tslib": "^1.9.3" - } - }, - "@sentry/hub": { - "version": "6.7.2", - "resolved": "https://registry.npmjs.org/@sentry/hub/-/hub-6.7.2.tgz", - "integrity": "sha512-05qVW6ymChJsXag4+fYCQokW3AcABIgcqrVYZUBf6GMU/Gbz5SJqpV7y1+njwWvnPZydMncP9LaDVpMKbE7UYQ==", - "requires": { - "@sentry/types": "6.7.2", - "@sentry/utils": "6.7.2", - "tslib": "^1.9.3" - } - }, - "@sentry/minimal": { - "version": "6.7.2", - "resolved": "https://registry.npmjs.org/@sentry/minimal/-/minimal-6.7.2.tgz", - "integrity": "sha512-jkpwFv2GFHoVl5vnK+9/Q+Ea8eVdbJ3hn3/Dqq9MOLFnVK7ED6MhdHKLT79puGSFj+85OuhM5m2Q44mIhyS5mw==", - "requires": { - "@sentry/hub": "6.7.2", - "@sentry/types": "6.7.2", - "tslib": "^1.9.3" - } - }, - "@sentry/node": { - "version": "6.7.2", - "resolved": "https://registry.npmjs.org/@sentry/node/-/node-6.7.2.tgz", - "integrity": "sha512-vfNTmxBbHthAKPDBo0gVk/aNHdgUfXLzmaK7FgWO7cISiI2soCfvKEIP61XqIFZru06teqcRuDsYlR4wSeyWpg==", - "requires": { - "@sentry/core": "6.7.2", - "@sentry/hub": "6.7.2", - "@sentry/tracing": "6.7.2", - "@sentry/types": "6.7.2", - "@sentry/utils": "6.7.2", - "cookie": "^0.4.1", - "https-proxy-agent": "^5.0.0", - "lru_map": "^0.3.3", - "tslib": "^1.9.3" - } - }, - "@sentry/tracing": { - "version": "6.7.2", - "resolved": "https://registry.npmjs.org/@sentry/tracing/-/tracing-6.7.2.tgz", - "integrity": "sha512-juKlI7FICKONWJFJxDxerj0A+8mNRhmtrdR+OXFqOkqSAy/QXlSFZcA/j//O19k2CfwK1BrvoMcQ/4gnffUOVg==", - "requires": { - "@sentry/hub": "6.7.2", - "@sentry/minimal": "6.7.2", - "@sentry/types": "6.7.2", - "@sentry/utils": "6.7.2", - "tslib": "^1.9.3" - } - }, - "@sentry/types": { - "version": "6.7.2", - "resolved": "https://registry.npmjs.org/@sentry/types/-/types-6.7.2.tgz", - "integrity": "sha512-h21Go/PfstUN+ZV6SbwRSZVg9GXRJWdLfHoO5PSVb3TVEMckuxk8tAE57/u+UZDwX8wu+Xyon2TgsKpiWKxqUg==" - }, - "@sentry/utils": { - "version": "6.7.2", - "resolved": "https://registry.npmjs.org/@sentry/utils/-/utils-6.7.2.tgz", - "integrity": "sha512-9COL7aaBbe61Hp5BlArtXZ1o/cxli1NGONLPrVT4fMyeQFmLonhUiy77NdsW19XnvhvaA+2IoV5dg3dnFiF/og==", - "requires": { - "@sentry/types": "6.7.2", - "tslib": "^1.9.3" - } - }, "@sindresorhus/is": { "version": "0.14.0", "resolved": "https://registry.npmjs.org/@sindresorhus/is/-/is-0.14.0.tgz", @@ -8310,14 +8089,6 @@ "integrity": "sha512-K0Ptm/47OKfQRpNQ2J/oIN/3QYiK6FwW+eJbILhsdxh2WTLdl+30o8aGdTbm5JbffpFFAg/g+zi1E+jvJha5ng==", "dev": true }, - "agent-base": { - "version": "6.0.2", - "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-6.0.2.tgz", - "integrity": "sha512-RZNwNclF7+MS/8bDg70amg32dyeZGZxiDuQmZxKLAlQjr3jGyLx+4Kkk58UO7D2QdgFIQCovuSuZESne6RG6XQ==", - "requires": { - "debug": "4" - } - }, "aggregate-error": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/aggregate-error/-/aggregate-error-3.1.0.tgz", @@ -10485,15 +10256,6 @@ "toidentifier": "1.0.0" } }, - "https-proxy-agent": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-5.0.0.tgz", - "integrity": "sha512-EkYm5BcKUGiduxzSt3Eppko+PiNWNEpa4ySk9vTC6wDsQJW9rHSa+UhGNJoRYp7bz6Ht1eaRIa6QaJqO5rCFbA==", - "requires": { - "agent-base": "6", - "debug": "4" - } - }, "iconv-lite": { "version": "0.4.24", "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", @@ -11175,11 +10937,6 @@ "integrity": "sha512-G2Lj61tXDnVFFOi8VZds+SoQjtQC3dgokKdDG2mTm1tx4m50NUHBOZSBwQQHyy0V12A0JTG4icfZQH+xPyh8VA==", "dev": true }, - "lru_map": { - "version": "0.3.3", - "resolved": "https://registry.npmjs.org/lru_map/-/lru_map-0.3.3.tgz", - "integrity": "sha1-tcg1G5Rky9dQM1p5ZQoOwOVhGN0=" - }, "lru-cache": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", @@ -11868,11 +11625,6 @@ "resolved": "https://registry.npmjs.org/pg-connection-string/-/pg-connection-string-2.4.0.tgz", "integrity": "sha512-3iBXuv7XKvxeMrIgym7njT+HlZkwZqqGX4Bu9cci8xHZNT+Um1gWKqCsAzcC0d95rcKMU5WBg6YRUcHyV0HZKQ==" }, - "pg-cursor": { - "version": "2.6.0", - "resolved": "https://registry.npmjs.org/pg-cursor/-/pg-cursor-2.6.0.tgz", - "integrity": "sha512-BFLg40CTgBJ+LX9EwqjztUYaKxpxLffMmDTmlQNMCustX/JxMTYimxRkdhZvPYZGp++/2LjuqkKtO5DVVq0FNg==" - }, "pg-int8": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/pg-int8/-/pg-int8-1.0.1.tgz", @@ -11888,14 +11640,6 @@ "resolved": "https://registry.npmjs.org/pg-protocol/-/pg-protocol-1.5.0.tgz", "integrity": "sha512-muRttij7H8TqRNu/DxrAJQITO4Ac7RmX3Klyr/9mJEOBeIpgnF8f9jAfRz5d3XwQZl5qBjF9gLsUtMPJE0vezQ==" }, - "pg-query-stream": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/pg-query-stream/-/pg-query-stream-4.1.0.tgz", - "integrity": "sha512-QbupRwS1JHqRVmNLQax4dIENgi+HoT7ToEn+rCcWqsZ/fbjTVdV+RmeZJRSMIcDhza3CImb/yAsTN0g2UGy6vg==", - "requires": { - "pg-cursor": "^2.6.0" - } - }, "pg-types": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/pg-types/-/pg-types-2.2.0.tgz", @@ -13024,11 +12768,6 @@ "strip-bom": "^3.0.0" } }, - "tslib": { - "version": "1.14.1", - "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz", - "integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==" - }, "type-check": { "version": "0.4.0", "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.4.0.tgz", diff --git a/package.json b/package.json index c8fbefa..d7639b2 100644 --- a/package.json +++ b/package.json @@ -25,8 +25,6 @@ "dependencies": { "@grpc/grpc-js": "^1.3.2", "@grpc/proto-loader": "^0.6.2", - "@sentry/node": "^6.7.2", - "@sentry/tracing": "^6.7.2", "ajv": "^8.6.0", "consola": "^2.15.3", "currency-codes": "^2.1.0", @@ -44,7 +42,6 @@ "locale-code": "^2.0.2", "mali": "^0.44.0", "pg": "^8.6.0", - "pg-query-stream": "^4.1.0", "semver": "^7.3.5", "under-pressure": "^5.7.0", "uuid": "^8.3.2" diff --git a/src/grpc.js b/src/grpc.js index 49a8ce4..78f130e 100644 --- a/src/grpc.js +++ b/src/grpc.js @@ -1,4 +1,3 @@ -import Sentry from '@sentry/node' import Mali from 'mali' import path from 'path' import { PerformanceObserver, performance } from 'perf_hooks' @@ -38,39 +37,24 @@ app.use(async (context, next) => { return next() } - const tracer = Sentry.startTransaction({ - name: context.fullName, - op: 'GET', - trimEnd: true, - }) - - Sentry.setUser({ - ...context.request.metadata, - account_id: context.request.req.account_id, - }) - performance.mark(context.fullName) + function measure() { + performance.mark(context.fullName + '-ended') + performance.measure( + context.fullName, + context.fullName, + context.fullName + '-ended', + ) + } + return next() .then(() => { - tracer.finish() - performance.mark(context.fullName + '-ended') - performance.measure( - context.fullName, - context.fullName, - context.fullName + '-ended', - ) + measure() }) .catch((error) => { - Sentry.captureException(error) logger.fatal(error) - tracer.finish() - performance.mark(context.fullName + '-ended') - performance.measure( - context.fullName, - context.fullName, - context.fullName + '-ended', - ) + measure() throw error }) }) diff --git a/src/index.js b/src/index.js index 0c0eb3a..d31feff 100644 --- a/src/index.js +++ b/src/index.js @@ -1,5 +1,3 @@ -import Sentry from '@sentry/node' -import Tracing from '@sentry/tracing' import Logger from './logger.js' import { build } from './server.js' import config from './config.js' @@ -7,26 +5,8 @@ import pg from './pg/index.js' import grpc from './grpc.js' const logger = Logger.create().withScope('application').withTag('start') - -Sentry.init({ - dsn: config.sentry, - integrations: [ - new Sentry.Integrations.OnUncaughtException({ - onFatalError(firstError) { - Sentry.captureException(firstError) - logger.withTag('OnUncaughtException').error(firstError) - process.exit(1) - }, - }), - new Sentry.Integrations.OnUnhandledRejection({ - mode: 'strict', - }), - new Sentry.Integrations.Http({ tracing: true }), - new Tracing.Integrations.Postgres(), - ], -}) - const server = await build() + await pg.raw('select 1+1 as result') await server.listen(config.port, '0.0.0.0') logger.success(`Application booted on port=${config.port}`) diff --git a/src/server.js b/src/server.js index 5dedd58..8d4c10a 100644 --- a/src/server.js +++ b/src/server.js @@ -1,5 +1,4 @@ import grpcjs from '@grpc/grpc-js' -import Sentry from '@sentry/node' import ajvCurrency from './validators/ajv-currency-code.js' import ajvSemver from './validators/ajv-semver.js' import ajvLocale from './validators/ajv-locale-code.js' @@ -44,7 +43,6 @@ export async function build() { throw server.httpErrors.serviceUnavailable(error.message) default: logger.fatal(error) - Sentry.captureException(error) throw server.httpErrors.internalServerError('Something went wrong') } } else if (error.statusCode) { @@ -56,7 +54,6 @@ export async function build() { } else { // Handle uncaught errors due to runtime issues logger.error(error) - Sentry.captureException(error) throw server.httpErrors.internalServerError('Something went wrong') } }) @@ -162,38 +159,6 @@ export async function build() { })(req, res, next) }) - server.addHook('onError', (request, _, error, done) => { - Sentry.withScope((scope) => { - scope.setSpan(request.trace) - scope.setUser({ - id: request.user.identity.id, - email: request.user.identity.recovery_addresses[0].value, - }) - Sentry.captureException(error) - }) - done() - }) - - server.addHook('onRequest', (request, _, done) => { - if (request.routerPath?.startsWith('/v1/')) { - request.trace = Sentry.startTransaction({ - op: request.method, - name: request.routerPath, - trimEnd: true, - }) - } - - done() - }) - - server.addHook('onResponse', (request, _, done) => { - setImmediate(() => { - request.trace?.setHttpStatus(request.statusCode) - request.trace?.finish() - }) - done() - }) - server.register(routes, { prefix: '/v1' }) server.get('/', { schema: { hide: true } }, async () => ({ status: 'up',