Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions servers/cu/src/bootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,12 @@ export const createApis = async (ctx) => {
onCreateWorker: onCreateWorker('primary')
})
const primaryWorkQueue = new PQueue({ concurrency: maxPrimaryWorkerThreads })
primaryWorkQueue.on('add', () => {
pendingEvaluationCounter.inc(1, { type: 'primary' })
})
primaryWorkQueue.on('next', () => {
pendingEvaluationCounter.dec(1, { type: 'primary' })
})

const maxDryRunWorkerTheads = Math.max(
1,
Expand All @@ -152,6 +158,12 @@ export const createApis = async (ctx) => {
maxQueueSize: ctx.WASM_EVALUATION_WORKERS_DRY_RUN_MAX_QUEUE
})
const dryRunWorkQueue = new PQueue({ concurrency: maxDryRunWorkerTheads })
dryRunWorkQueue.on('add', () => {
pendingEvaluationCounter.inc(1, { type: 'dry-run' })
})
dryRunWorkQueue.on('next', () => {
pendingEvaluationCounter.dec(1, { type: 'dry-run' })
})

const arweave = ArweaveClient.createWalletClient()
const address = ArweaveClient.addressWith({ WALLET: ctx.WALLET, arweave })
Expand Down Expand Up @@ -294,6 +306,12 @@ export const createApis = async (ctx) => {
labelNames: ['stream_type', 'message_type', 'process_error']
})

const pendingEvaluationCounter = MetricsClient.counterWith({})({
name: 'ao_process_pending_evaluations',
description: 'The total number of pending evaluations on a CU',
labelNames: ['type']
})

/**
* TODO: Gas can grow to a huge number. We need to make sure this doesn't crash when that happens
*/
Expand Down Expand Up @@ -330,6 +348,7 @@ export const createApis = async (ctx) => {
logger
}),
evaluationCounter,
pendingEvaluationCounter,
// gasCounter,
saveProcess: AoProcessClient.saveProcessWith({ db, logger }),
findEvaluation: AoEvaluationClient.findEvaluationWith({ db, logger }),
Expand Down