Skip to content

Commit

Permalink
refactor(cu): renamed total evaluation gauge and finer labels for fin…
Browse files Browse the repository at this point in the history
…er time-series #917
  • Loading branch information
TillaTheHun0 committed Aug 6, 2024
1 parent b158429 commit e4c79f7
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 12 deletions.
7 changes: 1 addition & 6 deletions servers/cu/src/domain/api/dryRun.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,7 @@ export function dryRunWith (env) {
* Otherwise, we are evaluating up to the latest
*/
exact: !!messageTxId,
needsMemory: true,
/**
* Add an indicator that this eval stream is part of a dry run.
* This is used for metric purposes.
*/
dryRun: true
needsMemory: true
})
)
/**
Expand Down
4 changes: 2 additions & 2 deletions servers/cu/src/domain/api/readState.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export function readStateWith (env) {
const loadModule = loadModuleWith(env)
const evaluate = evaluateWith(env)

return ({ processId, messageId, to, ordinate, cron, exact, needsMemory, dryRun = false }) => {
return ({ processId, messageId, to, ordinate, cron, exact, needsMemory }) => {
messageId = messageId || [to, ordinate, cron].filter(isNotNil).join(':') || 'latest'

const stats = {
Expand Down Expand Up @@ -79,7 +79,7 @@ export function readStateWith (env) {
* there is only one instance of the work used to resolve each Async,
* every time, thus preventing duplication of work
*/
pending = of({ id: processId, messageId, to, ordinate, cron, stats, needsMemory, dryRun })
pending = of({ id: processId, messageId, to, ordinate, cron, stats, needsMemory })
.chain(loadProcessMeta)
.chain(loadProcess)
.chain(loadModule)
Expand Down
4 changes: 2 additions & 2 deletions servers/cu/src/domain/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -239,9 +239,9 @@ export const createApis = async (ctx) => {
}

const evaluationCounter = MetricsClient.counterWith({})({
name: 'total_evaluations',
name: 'ao_process_total_evaluations',
description: 'The total number of evaluations on a CU',
labelNames: ['processId', 'cron', 'dryRun', 'error']
labelNames: ['stream_type', 'message_type', 'process_error']
})

/**
Expand Down
16 changes: 14 additions & 2 deletions servers/cu/src/domain/lib/evaluate.js
Original file line number Diff line number Diff line change
Expand Up @@ -241,9 +241,21 @@ export function evaluateWith (env) {
}

/**
* Increments gauges for total evaluations
* Increments gauges for total evaluations for both:
*
* total evaluations (no labels)
* specific kinds of evaluations (type of eval stream, type of message, whether an error occurred or not)
*/
evaluationCounter.inc(1, { cron: Boolean(cron), dryRun: Boolean(ctx.dryRun) }, { processId: ctx.id, error: Boolean(output.Error) })
evaluationCounter.inc(1)
evaluationCounter.inc(
1,
{
stream_type: ctx.dryRun ? 'dry-run' : 'primary',
message_type: ctx.dryRun ? 'dry-run' : cron ? 'cron' : isAssignment ? 'assignment' : 'scheduled',
process_error: Boolean(output.Error)
},
{ processId: ctx.id }
)
/**
* TODO: Gas can grow to a huge number. We need to make sure this doesn't crash when that happens
*/
Expand Down

0 comments on commit e4c79f7

Please sign in to comment.