Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
benzekrimaha committed Jun 17, 2024
1 parent add9193 commit da81b34
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
7 changes: 2 additions & 5 deletions src/CircuitBreaker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,12 @@ export class CircuitBreaker extends EventEmitter {
}

async _evaluate() {
this._evaluatingPromiseHook = Promise.allSettled(this._probes.map(p => p.check().catch(error => {
this.emit('connection-failed', error);
return 'failed';
})));
this._evaluatingPromiseHook = Promise.allSettled(this._probes.map(p => p.check()));
await this._evaluatingPromiseHook;
this._evaluatingPromiseHook = null;

const allOk = this._probes.every(probe => probe.value);

console.log('allOk:', allOk);

Check failure on line 70 in src/CircuitBreaker.ts

View workflow job for this annotation

GitHub Actions / test

Unexpected console statement
const initialState = this._aggregateState;

if (allOk) {
Expand Down
2 changes: 1 addition & 1 deletion src/probes/PrometheusClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export class PrometheusClient {
return series[0].value.value;
} catch (error: unknown) {
log.error('unable to query prometheus', { error });
return null;
return -1;
}
}
}
3 changes: 3 additions & 0 deletions src/probes/PrometheusQueryProbe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export class PrometheusQueryProbe implements Probe {

async check() {
const v = await this.prometheusClient.instantQuery();
log.info('observed value', { value: v });
if (v != null) {
if (Number.isNaN(v)) {
log.warn('warning: ignoring received NaN value (interval too long for retention?)');
Expand All @@ -46,6 +47,8 @@ export class PrometheusQueryProbe implements Probe {
}

get value() {
log.info('observed value', { value: this.observed });
log.info('threshold', { threshold: this.config.threshold });
return this.observed < this.config.threshold;
}
}

0 comments on commit da81b34

Please sign in to comment.