Skip to content

Commit

Permalink
Merge branch '258-log-level-health' into 'dev'
Browse files Browse the repository at this point in the history
Add warn level to logger health parameter

Closes #258

See merge request ergo/rosen-bridge/watcher!304
  • Loading branch information
zargarzadehm committed Oct 13, 2024
2 parents 99c280c + 18aeef2 commit 65061cd
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 8 deletions.
5 changes: 5 additions & 0 deletions .changeset/angry-buttons-sniff.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@rosen-bridge/watcher': minor
---

Add warn level to logger health parameter and tune the thresholds
7 changes: 4 additions & 3 deletions config/default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,10 @@ healthCheck:
permit:
warnCommitmentCount: 4 # warning remaining permits for creating commitment
criticalCommitmentCount: 0 # critical remaining permits for creating commitment
errorLog:
maxAllowedCount: 2 # maximum allowed error log lines
duration: 100000 # error log duration time check in milliseconds
logs:
duration: 600 # log duration time check (in seconds)
maxAllowedErrorCount: 1 # maximum allowed error log lines
maxAllowedWarnCount: 10 # maximum allowed warn log lines
redeemSwapEnabled: true # if set true when no permit left, system automatically redeem new commitments and commit again for old observations
rewardCollection:
threshold: 100000 # RSN threshold for reward collection
Expand Down
10 changes: 7 additions & 3 deletions src/config/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -526,8 +526,9 @@ class HealthCheckConfig {
permitCriticalCommitmentCount: number;
permitDefaultCommitmentRWT: number;
updateInterval: number;
logDuration: number;
errorLogAllowedCount: number;
errorLogDuration: number;
warnLogAllowedCount: number;

constructor() {
this.ergWarnThreshold = BigInt(
Expand Down Expand Up @@ -579,10 +580,13 @@ class HealthCheckConfig {
'healthCheck.permit.criticalCommitmentCount'
);
this.updateInterval = getRequiredNumber('healthCheck.interval');
this.logDuration = getRequiredNumber('healthCheck.logs.duration') * 1000;
this.errorLogAllowedCount = getRequiredNumber(
'healthCheck.errorLog.maxAllowedCount'
'healthCheck.logs.maxAllowedErrorCount'
);
this.warnLogAllowedCount = getRequiredNumber(
'healthCheck.logs.maxAllowedWarnCount'
);
this.errorLogDuration = getRequiredNumber('healthCheck.errorLog.duration');
}
}

Expand Down
13 changes: 11 additions & 2 deletions src/utils/healthCheck.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,14 +91,23 @@ class HealthCheckSingleton {
}
this.healthCheck = new HealthCheck(notify, notificationConfig);
const errorLogHealthCheck = new LogLevelHealthCheck(
logger,
WinstonLogger.getInstance().getDefaultLogger(),
HealthStatusLevel.UNSTABLE,
getConfig().healthCheck.errorLogAllowedCount,
getConfig().healthCheck.errorLogDuration,
getConfig().healthCheck.logDuration,
'error'
);
this.healthCheck.register(errorLogHealthCheck);

const warnLogHealthCheck = new LogLevelHealthCheck(
WinstonLogger.getInstance().getDefaultLogger(),
HealthStatusLevel.UNSTABLE,
getConfig().healthCheck.warnLogAllowedCount,
getConfig().healthCheck.logDuration,
'warn'
);
this.healthCheck.register(warnLogHealthCheck);

if (getConfig().general.scannerType === NODE_TYPE) {
this.registerErgoNodeHealthCheckParams();
} else if (getConfig().general.scannerType === EXPLORER_TYPE) {
Expand Down

0 comments on commit 65061cd

Please sign in to comment.