From 54cec4ae6b07c5f0bac4f4d1e5a425c32b6b39d9 Mon Sep 17 00:00:00 2001 From: Samuel Holmes Date: Mon, 1 May 2023 17:51:15 -0700 Subject: [PATCH 1/3] Change heartbeat verbiage --- src/util/heartbeat.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/util/heartbeat.ts b/src/util/heartbeat.ts index 19f8ecc..82c0d17 100644 --- a/src/util/heartbeat.ts +++ b/src/util/heartbeat.ts @@ -34,7 +34,7 @@ export function makeHeartbeat( if (seconds < nextSeconds) return nextSeconds += logSeconds - let out = `${seconds.toFixed(2)}s, ${count} rows` + let out = `${seconds.toFixed(2)}s, ${count} beats` if (item != null) out += `, ${item}` out += '\n' stderr.write(out) From 4914d65a9d83f2ed76d87e837930cfdd979e566f Mon Sep 17 00:00:00 2001 From: Samuel Holmes Date: Mon, 1 May 2023 17:56:35 -0700 Subject: [PATCH 2/3] Earmark row in priceChangeDaemon heartbeat --- src/daemons/priceChangeDaemon.ts | 2 +- src/db/couchPushEvents.ts | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/daemons/priceChangeDaemon.ts b/src/daemons/priceChangeDaemon.ts index e7be578..e71e41b 100644 --- a/src/daemons/priceChangeDaemon.ts +++ b/src/daemons/priceChangeDaemon.ts @@ -28,7 +28,7 @@ runDaemon(async tools => { logger.warn({ msg: 'Failed event', id, err }) } - heartbeat() + heartbeat(`row '${eventRow.id}'`) } }) diff --git a/src/db/couchPushEvents.ts b/src/db/couchPushEvents.ts index 8141955..01d2e52 100644 --- a/src/db/couchPushEvents.ts +++ b/src/db/couchPushEvents.ts @@ -36,6 +36,7 @@ import { PushEvent, PushTrigger } from '../types/pushTypes' * To make changes, edit the `event` object, then call `save`. */ export interface PushEventRow { + id: string event: PushEvent save: () => Promise } @@ -267,6 +268,7 @@ function makePushEventRow( let base = { ...event } return { + id: clean.id, event, async save(): Promise { From cb95cc874b70fe736cd429d12b86e2b82113b9de Mon Sep 17 00:00:00 2001 From: Samuel Holmes Date: Mon, 1 May 2023 18:03:22 -0700 Subject: [PATCH 3/3] Include extra information in the heartbeat log Change `item` to `info` and maintain the full rest of the chunk string. --- src/daemons/runDaemon.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/daemons/runDaemon.ts b/src/daemons/runDaemon.ts index c5a0e54..9f6011b 100644 --- a/src/daemons/runDaemon.ts +++ b/src/daemons/runDaemon.ts @@ -91,9 +91,10 @@ async function iterate( const heartbeat = makeHeartbeat({ write: chunk => { - const [timeElapsed, item] = chunk.split(',') + const [timeElapsed, ...rest] = chunk.split(',') + const info = rest.join(',').trim() logger.info( - { timeElapsed: timeElapsed.trim(), item: item.trim() }, + { timeElapsed: timeElapsed.trim(), info }, 'heartbeat %s', chunk )