From 670298a2ee8012e97a7e806d0bad356f6369e67f Mon Sep 17 00:00:00 2001 From: Nadeesha Cabral Date: Sat, 13 Jan 2024 09:52:55 +1100 Subject: [PATCH] chore: Adding Sentry profiling (#64) - Adds sentry profiling based on the presence of a DSN - Minor package updates --- control-plane/package.json | 2 + control-plane/src/utilities/profiling.ts | 11 ++ package-lock.json | 176 +++++++++++++++++++---- 3 files changed, 162 insertions(+), 27 deletions(-) create mode 100644 control-plane/src/utilities/profiling.ts diff --git a/control-plane/package.json b/control-plane/package.json index 4f9c1f1b..c0651b00 100644 --- a/control-plane/package.json +++ b/control-plane/package.json @@ -18,6 +18,8 @@ "@babel/preset-typescript": "^7.22.11", "@fastify/cors": "^8.5.0", "@influxdata/influxdb-client": "^1.33.2", + "@sentry/node": "^7.93.0", + "@sentry/profiling-node": "^1.3.5", "@ts-rest/core": "^3.27.0", "@ts-rest/fastify": "^3.27.0", "@types/jest": "^29.5.4", diff --git a/control-plane/src/utilities/profiling.ts b/control-plane/src/utilities/profiling.ts new file mode 100644 index 00000000..d867a9af --- /dev/null +++ b/control-plane/src/utilities/profiling.ts @@ -0,0 +1,11 @@ +import * as Sentry from "@sentry/node"; +import { ProfilingIntegration } from "@sentry/profiling-node"; + +if (process.env.SENTRY_DSN) { + Sentry.init({ + dsn: process.env.SENTRY_DSN, + integrations: [new ProfilingIntegration()], + tracesSampleRate: 1.0, + profilesSampleRate: 1.0, + }); +} diff --git a/package-lock.json b/package-lock.json index 8d2aadfa..d3b37e23 100644 --- a/package-lock.json +++ b/package-lock.json @@ -62,6 +62,8 @@ "@babel/preset-typescript": "^7.22.11", "@fastify/cors": "^8.5.0", "@influxdata/influxdb-client": "^1.33.2", + "@sentry/node": "^7.93.0", + "@sentry/profiling-node": "^1.3.5", "@ts-rest/core": "^3.27.0", "@ts-rest/fastify": "^3.27.0", "@types/jest": "^29.5.4", @@ -1932,11 +1934,11 @@ "integrity": "sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==" }, "node_modules/@clerk/backend": { - "version": "0.37.0", - "resolved": "https://registry.npmjs.org/@clerk/backend/-/backend-0.37.0.tgz", - "integrity": "sha512-ngBokqd5WaupUi5+xUaZNGCdrVMJFo+Sjiin7gxoXPVq/qdgA3phiEooEZmVAc9Io0MfAqheuiQ1XcCZj4kvdg==", + "version": "0.37.2", + "resolved": "https://registry.npmjs.org/@clerk/backend/-/backend-0.37.2.tgz", + "integrity": "sha512-Ymnf8LfcZTP/P15uMrY7myUtoOKgKiUR1G2c8429cIPdMTDC/fX+P+HUF1TlcKjwERuT+pGySufSjmPrDwqeMw==", "dependencies": { - "@clerk/shared": "1.3.0", + "@clerk/shared": "1.3.1", "@clerk/types": "3.60.0", "@peculiar/webcrypto": "1.4.1", "@types/node": "16.18.6", @@ -1993,11 +1995,11 @@ } }, "node_modules/@clerk/clerk-react": { - "version": "4.30.2", - "resolved": "https://registry.npmjs.org/@clerk/clerk-react/-/clerk-react-4.30.2.tgz", - "integrity": "sha512-Cr11vJj/0e75JV1WfR1UFtqJfjFOWRffl8AqcKk+QDOY7AgPd1V4Nvc7umIfhyoGYrJH+5tpga3QW2MlsekdsA==", + "version": "4.30.3", + "resolved": "https://registry.npmjs.org/@clerk/clerk-react/-/clerk-react-4.30.3.tgz", + "integrity": "sha512-bX4fUxGXUrMl8A50TpeUM8PHFKbMHmt7UfJ/NnUQMBN54h9N/NF2eSE2omY1+lDxBJmh/V9EiJZV8S6MwDflzw==", "dependencies": { - "@clerk/shared": "1.3.0", + "@clerk/shared": "1.3.1", "@clerk/types": "3.60.0", "tslib": "2.4.1" }, @@ -2014,12 +2016,12 @@ "integrity": "sha512-tGyy4dAjRIEwI7BzsB0lynWgOpfqjUdq91XXAlIWD2OwKBH7oCl/GZG/HT4BOHrTlPMOASlMQ7veyTqpmRcrNA==" }, "node_modules/@clerk/clerk-sdk-node": { - "version": "4.13.4", - "resolved": "https://registry.npmjs.org/@clerk/clerk-sdk-node/-/clerk-sdk-node-4.13.4.tgz", - "integrity": "sha512-pcg99eCjutPdVOhv4yXS2THV1NJhmA1gih127zW01RV8EkxeVF7K9aALqR7Hyi2ptnIsh3VF/UiYa1pvJ2R3Uw==", + "version": "4.13.6", + "resolved": "https://registry.npmjs.org/@clerk/clerk-sdk-node/-/clerk-sdk-node-4.13.6.tgz", + "integrity": "sha512-p/bGFvageJ6gTxuyG/VMdl0UiT0HzfT7ymrrcpZjN/lDheCoL5lin5JBBgdV4189tw9xb6wAl2XjsiOvYqo64w==", "dependencies": { - "@clerk/backend": "0.37.0", - "@clerk/shared": "1.3.0", + "@clerk/backend": "0.37.2", + "@clerk/shared": "1.3.1", "@clerk/types": "3.60.0", "@types/cookies": "0.7.7", "@types/express": "4.17.14", @@ -2049,14 +2051,14 @@ "integrity": "sha512-tGyy4dAjRIEwI7BzsB0lynWgOpfqjUdq91XXAlIWD2OwKBH7oCl/GZG/HT4BOHrTlPMOASlMQ7veyTqpmRcrNA==" }, "node_modules/@clerk/nextjs": { - "version": "4.29.1", - "resolved": "https://registry.npmjs.org/@clerk/nextjs/-/nextjs-4.29.1.tgz", - "integrity": "sha512-hJiHtGOWzQszL0FQ4FkDRLebR+2K3pc70Z7NJnAhS3tZqxZA6Dz03LUC88Ul6OUBi8ysekk5QqhDUbyxPSsrtA==", - "dependencies": { - "@clerk/backend": "0.37.0", - "@clerk/clerk-react": "4.30.2", - "@clerk/clerk-sdk-node": "4.13.4", - "@clerk/shared": "1.3.0", + "version": "4.29.3", + "resolved": "https://registry.npmjs.org/@clerk/nextjs/-/nextjs-4.29.3.tgz", + "integrity": "sha512-qPBHjOAEAwKPnBx7eat6oB5SUlqWWTALeize+pY4TRYURliUk/iZtNFFr/smF87bYCNwslZ+vDRQznEQsSpSkA==", + "dependencies": { + "@clerk/backend": "0.37.2", + "@clerk/clerk-react": "4.30.3", + "@clerk/clerk-sdk-node": "4.13.6", + "@clerk/shared": "1.3.1", "@clerk/types": "3.60.0", "path-to-regexp": "6.2.1", "tslib": "2.4.1" @@ -2076,9 +2078,9 @@ "integrity": "sha512-tGyy4dAjRIEwI7BzsB0lynWgOpfqjUdq91XXAlIWD2OwKBH7oCl/GZG/HT4BOHrTlPMOASlMQ7veyTqpmRcrNA==" }, "node_modules/@clerk/shared": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/@clerk/shared/-/shared-1.3.0.tgz", - "integrity": "sha512-blqXI4P2FIB2kjXhYe8d5jNIbKSmpSetcT/81xcBr2RVy234cV3oVX41Ypx10M36ev5v5cUqA4FfCSQ782EIUw==", + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/@clerk/shared/-/shared-1.3.1.tgz", + "integrity": "sha512-nzv4+uA90I/eQp55zfK9a1Po9VgCYlzlNhuZnKqyRsPyJ38l4gpIf3B3qSHHdN0+MTx9cWGFrik1CnpftdOBXQ==", "dependencies": { "glob-to-regexp": "0.4.1", "js-cookie": "3.0.1", @@ -4242,6 +4244,107 @@ "integrity": "sha512-UY+FGM/2jjMkzQLn8pxcHGMaVLh9aEitG3zY2CiY7XHdLiz3bZOwa6oDxNqEMv7zZkV+cj5DOdz0cQ1BP5Hjgw==", "dev": true }, + "node_modules/@sentry-internal/tracing": { + "version": "7.93.0", + "resolved": "https://registry.npmjs.org/@sentry-internal/tracing/-/tracing-7.93.0.tgz", + "integrity": "sha512-DjuhmQNywPp+8fxC9dvhGrqgsUb6wI/HQp25lS2Re7VxL1swCasvpkg8EOYP4iBniVQ86QK0uITkOIRc5tdY1w==", + "dependencies": { + "@sentry/core": "7.93.0", + "@sentry/types": "7.93.0", + "@sentry/utils": "7.93.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/@sentry/core": { + "version": "7.93.0", + "resolved": "https://registry.npmjs.org/@sentry/core/-/core-7.93.0.tgz", + "integrity": "sha512-vZQSUiDn73n+yu2fEcH+Wpm4GbRmtxmnXnYCPgM6IjnXqkVm3awWAkzrheADblx3kmxrRiOlTXYHw9NTWs56fg==", + "dependencies": { + "@sentry/types": "7.93.0", + "@sentry/utils": "7.93.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/@sentry/node": { + "version": "7.93.0", + "resolved": "https://registry.npmjs.org/@sentry/node/-/node-7.93.0.tgz", + "integrity": "sha512-nUXPCZQm5Y9Ipv7iWXLNp5dbuyi1VvbJ3RtlwD7utgsNkRYB4ixtKE9w2QU8DZZAjaEF6w2X94OkYH6C932FWw==", + "dependencies": { + "@sentry-internal/tracing": "7.93.0", + "@sentry/core": "7.93.0", + "@sentry/types": "7.93.0", + "@sentry/utils": "7.93.0", + "https-proxy-agent": "^5.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/@sentry/node/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/@sentry/node/node_modules/https-proxy-agent": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-5.0.1.tgz", + "integrity": "sha512-dFcAjpTQFgoLMzC2VwU+C/CbS7uRL0lWmxDITmqm7C+7F0Odmj6s9l6alZc6AELXhrnggM2CeWSXHGOdX2YtwA==", + "dependencies": { + "agent-base": "6", + "debug": "4" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/@sentry/profiling-node": { + "version": "1.3.5", + "resolved": "https://registry.npmjs.org/@sentry/profiling-node/-/profiling-node-1.3.5.tgz", + "integrity": "sha512-n2bfEbtLW3WuIMQGyxKJKzBNZOb1JYfMeJQ2WQn/42F++69m+u7T0S3EDGRN0Y//fbt5+r0any+4r3kChRXZkQ==", + "hasInstallScript": true, + "dependencies": { + "detect-libc": "^2.0.2", + "node-abi": "^3.52.0" + }, + "bin": { + "sentry-prune-profiler-binaries": "scripts/prune-profiler-binaries.mjs" + }, + "engines": { + "node": ">=8.0.0" + }, + "peerDependencies": { + "@sentry/node": "^7.44.1" + } + }, + "node_modules/@sentry/types": { + "version": "7.93.0", + "resolved": "https://registry.npmjs.org/@sentry/types/-/types-7.93.0.tgz", + "integrity": "sha512-UnzUccNakhFRA/esWBWP+0v7cjNg+RilFBQC03Mv9OEMaZaS29zSbcOGtRzuFOXXLBdbr44BWADqpz3VW0XaNw==", + "engines": { + "node": ">=8" + } + }, + "node_modules/@sentry/utils": { + "version": "7.93.0", + "resolved": "https://registry.npmjs.org/@sentry/utils/-/utils-7.93.0.tgz", + "integrity": "sha512-Iovj7tUnbgSkh/WrAaMrd5UuYjW7AzyzZlFDIUrwidsyIdUficjCG2OIxYzh76H6nYIx9SxewW0R54Q6XoB4uA==", + "dependencies": { + "@sentry/types": "7.93.0" + }, + "engines": { + "node": ">=8" + } + }, "node_modules/@sigstore/bundle": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/@sigstore/bundle/-/bundle-1.1.0.tgz", @@ -7523,6 +7626,14 @@ "node": ">=4" } }, + "node_modules/detect-libc": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-2.0.2.tgz", + "integrity": "sha512-UX6sGumvvqSaXgdKGUsgZWqcUyIXZ/vZTrlRT/iobiKhGL0zL4d3osHj3uqllWJK+i+sixDS/3COVEOFbupFyw==", + "engines": { + "node": ">=8" + } + }, "node_modules/detect-newline": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/detect-newline/-/detect-newline-3.1.0.tgz", @@ -9246,9 +9357,9 @@ "dev": true }, "node_modules/follow-redirects": { - "version": "1.15.3", - "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.3.tgz", - "integrity": "sha512-1VzOtuEM8pC9SFU1E+8KfTjZyMztRsgEfwQl44z8A25uy13jSzTj6dyK2Df52iV0vgHCfBwLhDWevLn95w5v6Q==", + "version": "1.15.5", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.5.tgz", + "integrity": "sha512-vSFWUON1B+yAw1VN4xMfxgn5fTUiaOzAJCKBwIIgT/+7CuGy9+r+5gITvP62j3RmaD5Ph65UaERdOSRGUzZtgw==", "funding": [ { "type": "individual", @@ -13334,6 +13445,17 @@ "tslib": "^2.0.3" } }, + "node_modules/node-abi": { + "version": "3.54.0", + "resolved": "https://registry.npmjs.org/node-abi/-/node-abi-3.54.0.tgz", + "integrity": "sha512-p7eGEiQil0YUV3ItH4/tBb781L5impVmmx2E9FRKF7d18XXzp4PGT2tdYMFY6wQqgxD0IwNZOiSJ0/K0fSi/OA==", + "dependencies": { + "semver": "^7.3.5" + }, + "engines": { + "node": ">=10" + } + }, "node_modules/node-fetch": { "version": "2.6.7", "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.7.tgz",