Skip to content

Commit

Permalink
chore: upgrade metrics package (#671)
Browse files Browse the repository at this point in the history
  • Loading branch information
wa0x6e authored Sep 12, 2023
1 parent e241408 commit 8331162
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 29 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
"prettier": "@snapshot-labs/prettier-config",
"dependencies": {
"@snapshot-labs/keycard": "^0.4.0",
"@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",
"@snapshot-labs/snapshot.js": "^0.5.8",
"bluebird": "^3.7.2",
"connection-string": "^1.0.1",
Expand Down
22 changes: 3 additions & 19 deletions src/helpers/metrics.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import init, { client } from '@snapshot-labs/snapshot-metrics';
import { capture } from '@snapshot-labs/snapshot-sentry';
import { Express } from 'express';
import { spacesMetadata } from './spaces';
import { strategies } from './strategies';
Expand All @@ -11,7 +12,6 @@ const whitelistedPath = [
/^\/api\/spaces\/.+$/,
/^\/graphql/
];
let server;

const rateLimitedRequestsCount = new client.Counter({
name: 'http_requests_by_rate_limit_count',
Expand All @@ -35,17 +35,11 @@ export default function initMetrics(app: Express) {
['^/api/scores/.+', '/api/scores/#id'],
['^/api/spaces/([^/]+)(/poke)?$', '/api/spaces/#key$2']
],
whitelistedPath
whitelistedPath,
errorHandler: (e: any) => capture(e)
});

app.use(instrumentRateLimitedRequests);
app.use((req, res, next) => {
if (!server) {
// @ts-ignore
server = req.socket.server;
}
next();
});
}

new client.Gauge({
Expand Down Expand Up @@ -138,16 +132,6 @@ new client.Gauge({
}
});

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);
}
}
});

export const requestDeduplicatorSize = new client.Gauge({
name: 'request_deduplicator_size',
help: 'Total number of items in the deduplicator queue'
Expand Down
16 changes: 8 additions & 8 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1333,18 +1333,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"

Expand Down

0 comments on commit 8331162

Please sign in to comment.