Skip to content

Commit

Permalink
common: fix sequentialTimerX log line to warn if configured time took…
Browse files Browse the repository at this point in the history
… longer than configured
  • Loading branch information
dwerner committed Dec 26, 2024
1 parent ae00a9e commit 4362b8f
Showing 1 changed file with 6 additions and 14 deletions.
20 changes: 6 additions & 14 deletions packages/indexer-common/src/sequential-timer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,18 +52,14 @@ export function sequentialTimerReduce<T, U>(
function work() {
const workStarted = Date.now()
const promiseOrT = reducer(acc, workStarted)
const workEnded = Date.now()
const loopTime = workStarted - lastWorkStarted
const workTime = workEnded - workStarted
logger.debug(
`sequentialTimerReduce loop took ${loopTime}ms, work took ${workTime}ms caller(${caller})`,
)
logger.debug(`sequentialTimerReduce loop took ${loopTime}ms caller(${caller})`)

if (workTime > milliseconds) {
if (loopTime > milliseconds) {
logger.warn(
'sequentialTimerReduce work took longer than the sequential timer was configured for',
{
workTime,
loopTime,
milliseconds,
},
)
Expand Down Expand Up @@ -124,18 +120,14 @@ export function sequentialTimerMap<U>(
function work() {
const workStarted = Date.now()
const promiseOrU = mapper(Date.now())
const workEnded = Date.now()
const loopTime = workStarted - lastWorkStarted
const workTime = workEnded - workStarted
logger.debug(
`sequentialTimerMap loop took ${loopTime}ms, work took ${workTime}ms caller(${caller})`,
)
logger.debug(`sequentialTimerMap loop took ${loopTime}ms caller(${caller})`)

if (workTime > milliseconds) {
if (loopTime > milliseconds) {
logger.warn(
'sequentialTimerMap work took longer than the sequential timer was configured for',
{
workTime,
loopTime,
milliseconds,
},
)
Expand Down

0 comments on commit 4362b8f

Please sign in to comment.