Merge pull request #2664 from spali/keep_prometheus_instance

remember prometheus instance and expose it
This commit is contained in:
Louis Lam
2023-02-23 20:43:05 +08:00
committed by GitHub
2 changed files with 7 additions and 10 deletions

View File

@@ -203,7 +203,7 @@ class Monitor extends BeanModel {
let previousBeat = null;
let retries = 0;
let prometheus = new Prometheus(this);
this.prometheus = new Prometheus(this);
const beat = async () => {
@@ -755,7 +755,7 @@ class Monitor extends BeanModel {
await R.store(bean);
log.debug("monitor", `[${this.name}] prometheus.update`);
prometheus.update(bean, tlsInfo);
this.prometheus.update(bean, tlsInfo);
previousBeat = bean;
@@ -840,15 +840,15 @@ class Monitor extends BeanModel {
clearTimeout(this.heartbeatInterval);
this.isStop = true;
this.prometheus().remove();
this.prometheus.remove();
}
/**
* Get a new prometheus instance
* @returns {Prometheus}
* Get prometheus instance
* @returns {Prometheus|undefined}
*/
prometheus() {
return new Prometheus(this);
getPrometheus() {
return this.prometheus;
}
/**