Skip to content

Commit

Permalink
fix: added gauge metric
Browse files Browse the repository at this point in the history
  • Loading branch information
AASHISH MALIK committed Dec 6, 2024
1 parent 35db010 commit c333688
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 12 deletions.
12 changes: 12 additions & 0 deletions src/util/prometheus.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
22 changes: 10 additions & 12 deletions src/v0/destinations/braze/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
});
Expand Down Expand Up @@ -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,
Expand All @@ -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;
};

Expand Down

0 comments on commit c333688

Please sign in to comment.