From c3336888570fbcc8b7c54f773b9653e1016b6a4d Mon Sep 17 00:00:00 2001 From: AASHISH MALIK <=> Date: Fri, 6 Dec 2024 19:05:49 +0530 Subject: [PATCH] fix: added gauge metric --- src/util/prometheus.js | 12 ++++++++++++ src/v0/destinations/braze/util.js | 22 ++++++++++------------ 2 files changed, 22 insertions(+), 12 deletions(-) diff --git a/src/util/prometheus.js b/src/util/prometheus.js index c8dd55068be..1585f0b3a62 100644 --- a/src/util/prometheus.js +++ b/src/util/prometheus.js @@ -520,6 +520,18 @@ class Prometheus { type: 'counter', labelNames: ['destination_id'], }, + { + name: 'braze_batch_subscription_size', + help: 'braze_batch_subscription_size', + type: 'gauge', + labelNames: ['destination_id'], + }, + { + name: 'braze_batch_subscription_combined_size', + help: 'braze_batch_subscription_combined_size', + type: 'gauge', + labelNames: ['destination_id'], + }, { name: 'hs_batch_size', help: 'hs_batch_size', diff --git a/src/v0/destinations/braze/util.js b/src/v0/destinations/braze/util.js index b99ac69b1d2..3778c34c43c 100644 --- a/src/v0/destinations/braze/util.js +++ b/src/v0/destinations/braze/util.js @@ -418,13 +418,19 @@ function prepareGroupAndAliasBatch(arrayChunks, responseArray, destination, type response.endpoint = getSubscriptionGroupEndPoint(getEndpointFromConfig(destination)); const subscription_groups = chunk; // maketool transformed event - if (destination.ID == '2oRdG2shHukATE89DiUovc8wZ3P') { - logger.info(`braze subscription chunk ${JSON.stringify(subscription_groups)}`); - } + logger.info(`braze subscription chunk ${JSON.stringify(subscription_groups)}`); + + stats.gauge('braze_batch_subscription_size', subscription_groups.length, { + destination_id: destination.ID, + }); // Deduplicate the subscription groups before constructing the response body const deduplicatedSubscriptionGroups = combineSubscriptionGroups(subscription_groups); + stats.gauge('braze_batch_subscription_combined_size', deduplicatedSubscriptionGroups.length, { + destination_id: destination.ID, + }); + response.body.JSON = removeUndefinedAndNullValues({ subscription_groups: deduplicatedSubscriptionGroups, }); @@ -534,10 +540,7 @@ const processBatch = (transformedEvents) => { prepareGroupAndAliasBatch(mergeUsersArrayChunks, responseArray, destination, 'merge'); if (successMetadata.length > 0) { - // maketool transformed event - if (destination.ID == '2oRdG2shHukATE89DiUovc8wZ3P') { - logger.info(`Response 1 batchRequest ${JSON.stringify(responseArray)}`); - } + console.log(`Response 1 batchRequest ${JSON.stringify(responseArray)}`); finalResponse.push({ batchedRequest: responseArray, metadata: successMetadata, @@ -554,11 +557,6 @@ const processBatch = (transformedEvents) => { finalResponse.push(...filteredResponses); } - // maketool transformed event - if (destination.ID == '2oRdG2shHukATE89DiUovc8wZ3P') { - logger.info(`final Response : ${JSON.stringify(finalResponse)}`); - } - return finalResponse; };