Skip to content

Commit

Permalink
chore: updated log message
Browse files Browse the repository at this point in the history
Signed-off-by: Logan Nguyen <[email protected]>
  • Loading branch information
quiet-node committed Oct 3, 2024
1 parent 27113cd commit 349eb2d
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions packages/relay/src/lib/services/hbarLimitService/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -207,15 +207,13 @@ export class HbarLimitService implements IHbarLimitService {
// In such cases, it should still be true if spendingPlan.spentToday === dailyLimit.
const exceedsLimit = spendingPlan.spentToday >= dailyLimit || spendingPlan.spentToday + estimatedTxFee > dailyLimit;

if (exceedsLimit) {
this.logger.warn(
`${requestDetails.formattedRequestId} User has exceeded HBAR rate limit threshold: user=${user}, spentToday=${spendingPlan.spentToday}, estimatedTxFee=${estimatedTxFee}, dailyLimit=${dailyLimit}, txConstructorName=${txConstructorName}, mode=${mode}, methodName=${methodName}`,
);
} else {
this.logger.trace(
`${requestDetails.formattedRequestId} User has NOT exceeded HBAR rate limit threshold: user=${user}, spentToday=${spendingPlan.spentToday}, estimatedTxFee=${estimatedTxFee}, dailyLimit=${dailyLimit}, txConstructorName=${txConstructorName}, mode=${mode}, methodName=${methodName}`,
);
}
this.logger.trace(
`${requestDetails.formattedRequestId} User ${
exceedsLimit ? 'has' : 'has NOT'
} exceeded HBAR rate limit threshold: user=${user}, spentToday=${
spendingPlan.spentToday
}, estimatedTxFee=${estimatedTxFee}, dailyLimit=${dailyLimit}, txConstructorName=${txConstructorName}, mode=${mode}, methodName=${methodName}`,
);

return exceedsLimit;
}
Expand Down Expand Up @@ -290,7 +288,7 @@ export class HbarLimitService implements IHbarLimitService {
if (this.remainingBudget <= 0 || this.remainingBudget - estimatedTxFee < 0) {
this.hbarLimitCounter.labels(mode, methodName).inc(1);
this.logger.warn(
`${requestDetails.formattedRequestId} Daily HBAR rate limit incoming call: remainingBudget=${
`${requestDetails.formattedRequestId} Total HBAR rate limit reached: remainingBudget=${
this.remainingBudget
}, totalBudget=${
this.totalBudget
Expand All @@ -299,7 +297,7 @@ export class HbarLimitService implements IHbarLimitService {
return true;
} else {
this.logger.trace(
`${requestDetails.formattedRequestId} Daily HBAR rate limit not reached: remainingBudget=${
`${requestDetails.formattedRequestId} Total HBAR rate limit NOT reached: remainingBudget=${
this.remainingBudget
}, totalBudget=${
this.totalBudget
Expand Down

0 comments on commit 349eb2d

Please sign in to comment.