mirror of
https://github.com/ChainSafe/lodestar.git
synced 2026-01-10 08:08:16 -05:00
fix: correct leveldb metrics (#8355)
Bring https://github.com/ChainSafe/lodestar/pull/8335 to unstable Co-authored-by: twoeths <10568965+twoeths@users.noreply.github.com> Co-authored-by: Tuyen Nguyen <twoeths@users.noreply.github.com>
This commit is contained in:
@@ -189,9 +189,9 @@ export class LevelDbController implements DatabaseController<Uint8Array, Uint8Ar
|
||||
|
||||
/** Capture metrics for db.iterator, db.keys, db.values .all() calls */
|
||||
private async metricsAll<T>(promise: Promise<T[]>, bucket: string): Promise<T[]> {
|
||||
this.metrics?.dbWriteReq.inc({bucket}, 1);
|
||||
this.metrics?.dbReadReq.inc({bucket}, 1);
|
||||
const items = await promise;
|
||||
this.metrics?.dbWriteItems.inc({bucket}, items.length);
|
||||
this.metrics?.dbReadItems.inc({bucket}, items.length);
|
||||
return items;
|
||||
}
|
||||
|
||||
@@ -201,7 +201,7 @@ export class LevelDbController implements DatabaseController<Uint8Array, Uint8Ar
|
||||
getValue: (item: T) => K,
|
||||
bucket: string
|
||||
): AsyncIterable<K> {
|
||||
this.metrics?.dbWriteReq.inc({bucket}, 1);
|
||||
this.metrics?.dbReadReq.inc({bucket}, 1);
|
||||
|
||||
let itemsRead = 0;
|
||||
|
||||
@@ -212,7 +212,7 @@ export class LevelDbController implements DatabaseController<Uint8Array, Uint8Ar
|
||||
yield getValue(item);
|
||||
}
|
||||
|
||||
this.metrics?.dbWriteItems.inc({bucket}, itemsRead);
|
||||
this.metrics?.dbReadItems.inc({bucket}, itemsRead);
|
||||
}
|
||||
|
||||
/** Start interval to capture metric for db size */
|
||||
|
||||
Reference in New Issue
Block a user