From a45b500d9c3df01aefee1879969ebd6c60f06acc Mon Sep 17 00:00:00 2001 From: Geoffrey Hayes Date: Fri, 31 Jul 2020 15:23:02 -0700 Subject: [PATCH] Add Metrics These metrics were used by our current metrics and alerting system to determine whether or not the poster is running successfully. We add these back so we can use similar metrics. --- poster/src/index.ts | 39 ++++++++++++++++++++++++++++++++------- 1 file changed, 32 insertions(+), 7 deletions(-) diff --git a/poster/src/index.ts b/poster/src/index.ts index a14b4316..57196817 100644 --- a/poster/src/index.ts +++ b/poster/src/index.ts @@ -64,12 +64,37 @@ async function run() { web3.eth.transactionConfirmationBlocks = 10; } - try { - await main(sources, poster_key, view_address, view_function, gas_limit, gas_price, price_delta, assets, mocked_world, pairs, web3); - console.log('Poster run completed successfully'); - } catch (e) { - console.error(`Poster failed to run`, e); - } + await main(sources, poster_key, view_address, view_function, gas_limit, gas_price, price_delta, assets, mocked_world, pairs, web3); + + let success_log = { + message: "Price Feed Poster run completed successfully", + metric_name: 'PriceFeed-PosterHealth', + labels: { + price_feed_poster_healthy: 1 + } + }; + + process.stderr.write(JSON.stringify(success_log) + "\n", () => { + process.exit(0); + }); } -run(); +run().catch((e) => { + console.error(`Error encountered: ${e}`); + console.error(e); + console.log(e.stack) + console.log + + let error_log = { + message: "Price run failed", + metric_name: 'PriceFeed-PosterHealth', + labels: { + price_feed_poster_healthy: 0, + error: e.toString() + } + }; + + process.stderr.write(JSON.stringify(error_log) + "\n", () => { + process.exit(1); + }) +});