From f67e54d66ec700cb0f303d5eb464993110eaf99a Mon Sep 17 00:00:00 2001 From: Wan <495709+wa0x6e@users.noreply.github.com> Date: Fri, 15 Sep 2023 22:11:24 +0900 Subject: [PATCH] chore: upgrade to snapshot-metrics 1.1.0 (#180) * chore: upgrade to snapshot-metrics 1.4.0 * Update src/metrics.ts Co-authored-by: Dmytro Tolok --------- Co-authored-by: Dmytro Tolok --- package.json | 4 ++-- src/metrics.ts | 23 +++-------------------- yarn.lock | 16 ++++++++-------- 3 files changed, 13 insertions(+), 30 deletions(-) diff --git a/package.json b/package.json index ea516f4..cd24d94 100644 --- a/package.json +++ b/package.json @@ -22,8 +22,8 @@ "@aws-sdk/client-s3": "^3.75.0", "@fleekhq/fleek-storage-js": "^1.0.21", "@pinata/sdk": "^1.1.25", - "@snapshot-labs/snapshot-metrics": "^1.0.0", - "@snapshot-labs/snapshot-sentry": "^1.3.0", + "@snapshot-labs/snapshot-metrics": "^1.1.0", + "@snapshot-labs/snapshot-sentry": "^1.4.0", "compression": "^1.7.4", "cors": "^2.8.5", "dotenv": "^16.0.1", diff --git a/src/metrics.ts b/src/metrics.ts index 55c5315..71f8f6b 100644 --- a/src/metrics.ts +++ b/src/metrics.ts @@ -1,23 +1,16 @@ import init, { client } from '@snapshot-labs/snapshot-metrics'; +import { capture } from '@snapshot-labs/snapshot-sentry'; import type { Express } from 'express'; import gateways from './gateways.json'; import { providersMap, IMAGE_PROVIDERS, JSON_PROVIDERS } from './providers/utils'; -let server; - export default function initMetrics(app: Express) { init(app, { normalizedPath: [['^/ipfs/.*', '/ipfs/#url']], - whitelistedPath: [/^\/$/, /^\/upload$/, /^\/ipfs\/.*$/] + whitelistedPath: [/^\/$/, /^\/upload$/, /^\/ipfs\/.*$/], + errorHandler: capture }); - app.use((req, res, next) => { - if (!server) { - // @ts-ignore - server = req.socket.server; - } - next(); - }); app.use(providersInstrumentation); } @@ -106,13 +99,3 @@ const providersInstrumentation = (req, res, next) => { }; next(); }; - -new client.Gauge({ - name: 'express_open_connections_size', - help: 'Number of open connections on the express server.', - async collect() { - if (server) { - this.set(server._connections); - } - } -}); diff --git a/yarn.lock b/yarn.lock index f9bcc35..23ad128 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1825,18 +1825,18 @@ resolved "https://registry.yarnpkg.com/@snapshot-labs/prettier-config/-/prettier-config-0.1.0-beta.7.tgz#c8e07e7e9baabee245020a72ac05835b65139823" integrity sha512-k/FUf4VWhwLFUmKuWs2mNvmPe691hqhvCJuujD4TfbIivWysmL1TqthwfdQUrQEAQUqVQ2ZKEiGkbufp5J27eQ== -"@snapshot-labs/snapshot-metrics@^1.0.0": - version "1.0.0" - resolved "https://registry.yarnpkg.com/@snapshot-labs/snapshot-metrics/-/snapshot-metrics-1.0.0.tgz#1f88a6aacc81f639f7059c153b53c550934cd3b3" - integrity sha512-6T8a2NX6Qo6zVAoNIWV8eSJCukCynI/HCLp37VZTzX8jwU/ahGsiDTQC3I/MDus+LDB+8pI5nju33NwM8Q7n2g== +"@snapshot-labs/snapshot-metrics@^1.1.0": + version "1.1.0" + resolved "https://registry.yarnpkg.com/@snapshot-labs/snapshot-metrics/-/snapshot-metrics-1.1.0.tgz#0b700ed50a28400cae7bfa47de9f5a1cc018719a" + integrity sha512-KajdSDd7cjQ9pRRYLDMqSd6yTcQ7Ln2/1zrRY5w23vGTSAH/NF0/7XojPYiW+IIdVAa5fV5nrcjFXT1X62XSYA== dependencies: express-prom-bundle "^6.6.0" prom-client "^14.2.0" -"@snapshot-labs/snapshot-sentry@^1.3.0": - version "1.3.0" - resolved "https://registry.yarnpkg.com/@snapshot-labs/snapshot-sentry/-/snapshot-sentry-1.3.0.tgz#9822d62b9a8918c70a09167da7b36ff43b9edba0" - integrity sha512-Qy+uLwsLhlRjx8MSbVU46tYVbiA5fIp6i1bgyab5pHwqsBaP93sjQIBetfGzeWxmmUXI8cS4lUOCc/x0HXEEGg== +"@snapshot-labs/snapshot-sentry@^1.4.0": + version "1.4.0" + resolved "https://registry.yarnpkg.com/@snapshot-labs/snapshot-sentry/-/snapshot-sentry-1.4.0.tgz#77933c2d8a32bb1b8daa05fec78ea73f8b78258d" + integrity sha512-261ZJGQ1rsSnAqsPrED1Hn2CoRFLtGla2WfnhqddcfYfYgEx2hsxUGs0jpSBCSfY/AsfK1+MgsoIXOFWXu74qQ== dependencies: "@sentry/node" "^7.60.1"