-
Notifications
You must be signed in to change notification settings - Fork 272
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: track world state metrics (#8109)
Extract relevant stats from world state: - sync duration (by synch type) - fork duration - db size (estimate) - individual tree sizes (ie. how many leaves are filled)
- Loading branch information
1 parent
9e11baf
commit 636e4ef
Showing
18 changed files
with
134 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import { type Timer } from '@aztec/foundation/timer'; | ||
import { | ||
Attributes, | ||
type Gauge, | ||
type Histogram, | ||
Metrics, | ||
type TelemetryClient, | ||
ValueType, | ||
} from '@aztec/telemetry-client'; | ||
|
||
export class WorldStateMetrics { | ||
private treeSize: Gauge; | ||
private dbSize: Gauge; | ||
private forkDuration: Histogram; | ||
private syncDuration: Histogram; | ||
|
||
constructor(client: TelemetryClient, name = 'MerkleTreesDb') { | ||
const meter = client.getMeter(name); | ||
this.treeSize = meter.createGauge(Metrics.WORLD_STATE_MERKLE_TREE_SIZE, { | ||
description: 'The size of Merkle trees', | ||
valueType: ValueType.INT, | ||
}); | ||
|
||
this.dbSize = meter.createGauge(Metrics.WORLD_STATE_DB_SIZE, { | ||
description: 'The size of the World State DB', | ||
valueType: ValueType.INT, | ||
unit: 'By', | ||
}); | ||
|
||
this.forkDuration = meter.createHistogram(Metrics.WORLD_STATE_FORK_DURATION, { | ||
description: 'The duration of a fork operation', | ||
unit: 'ms', | ||
valueType: ValueType.INT, | ||
}); | ||
|
||
this.syncDuration = meter.createHistogram(Metrics.WORLD_STATE_SYNC_DURATION, { | ||
description: 'The duration of a sync operation', | ||
unit: 'ms', | ||
valueType: ValueType.INT, | ||
}); | ||
} | ||
|
||
recordTreeSize(treeName: string, treeSize: bigint) { | ||
this.treeSize.record(Number(treeSize), { | ||
[Attributes.MERKLE_TREE_NAME]: treeName, | ||
}); | ||
} | ||
|
||
recordDbSize(dbSizeInBytes: number) { | ||
this.dbSize.record(dbSizeInBytes); | ||
} | ||
|
||
recordForkDuration(timerOrMs: Timer | number) { | ||
const ms = Math.ceil(typeof timerOrMs === 'number' ? timerOrMs : timerOrMs.ms()); | ||
this.forkDuration.record(ms); | ||
} | ||
|
||
recordSyncDuration(syncType: 'commit' | 'rollback_and_update', timerOrMs: Timer | number) { | ||
const ms = Math.ceil(typeof timerOrMs === 'number' ? timerOrMs : timerOrMs.ms()); | ||
this.syncDuration.record(ms, { | ||
[Attributes.STATUS]: syncType, | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,6 +21,9 @@ | |
{ | ||
"path": "../merkle-tree" | ||
}, | ||
{ | ||
"path": "../telemetry-client" | ||
}, | ||
{ | ||
"path": "../types" | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters