Skip to content

Commit

Permalink
feat: added methodsCounter metric for batch_requests
Browse files Browse the repository at this point in the history
Signed-off-by: Logan Nguyen <logan.nguyen@swirldslabs.com>
  • Loading branch information
quiet-node committed May 13, 2024
1 parent b7ee182 commit 128d723
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions packages/ws-server/src/webSocketServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,13 @@ app.ws.use(async (ctx) => {
if (Array.isArray(request)) {
logger.trace(`${connectionIdPrefix} ${requestIdPrefix}: Receive batch request=${JSON.stringify(request)}`);

// Increment metrics for batch_requests
wsMetricRegistry.getCounter('methodsCounter').labels(WS_CONSTANTS.BATCH_REQUEST_METHOD_NAME).inc();
wsMetricRegistry
.getCounter('methodsCounterByIp')
.labels(ctx.request.ip, WS_CONSTANTS.BATCH_REQUEST_METHOD_NAME)
.inc();

// send error if batch request feature is not enabled
if (!getWsBatchRequestsEnabled()) {
const batchRequestDisabledError = predefined.WS_BATCH_REQUESTS_DISABLED;
Expand Down

0 comments on commit 128d723

Please sign in to comment.