diff --git a/packages/data-fetcher/src/block/block.service.ts b/packages/data-fetcher/src/block/block.service.ts index aed940597d..5c1bf7eae7 100644 --- a/packages/data-fetcher/src/block/block.service.ts +++ b/packages/data-fetcher/src/block/block.service.ts @@ -46,7 +46,7 @@ export class BlockService { public async getData(blockNumber: number): Promise { const stopDurationMeasuring = this.processingDurationMetric.startTimer(); - this.logger.debug({ message: "Getting block from the blockchain", blockNumber }); + this.logger.debug({ message: "Getting block data from the blockchain", blockNumber }); const stopGetBlockInfoDurationMetric = this.getBlockInfoDurationMetric.startTimer(); const [block, blockDetails] = await Promise.all([ this.blockchainService.getBlock(blockNumber), @@ -90,6 +90,7 @@ export class BlockService { stopDurationMeasuring({ status: blockProcessingStatus, action: "get" }); } + this.logger.debug({ message: "Successfully generated block data", blockNumber }); return { block, blockDetails, diff --git a/packages/data-fetcher/src/health/health.controller.spec.ts b/packages/data-fetcher/src/health/health.controller.spec.ts index 7f92bcd0a9..065fcd36cb 100644 --- a/packages/data-fetcher/src/health/health.controller.spec.ts +++ b/packages/data-fetcher/src/health/health.controller.spec.ts @@ -81,4 +81,11 @@ describe("HealthController", () => { }); }); }); + + describe("onApplicationShutdown", () => { + it("defined and returns void", async () => { + const result = healthController.onApplicationShutdown(); + expect(result).toBeUndefined(); + }); + }); }); diff --git a/packages/data-fetcher/src/health/health.controller.ts b/packages/data-fetcher/src/health/health.controller.ts index 0d4c13b75d..0568b6c115 100644 --- a/packages/data-fetcher/src/health/health.controller.ts +++ b/packages/data-fetcher/src/health/health.controller.ts @@ -1,9 +1,9 @@ -import { Logger, Controller, Get } from "@nestjs/common"; +import { Logger, Controller, Get, OnApplicationShutdown } from "@nestjs/common"; import { HealthCheckService, HealthCheck, HealthCheckResult } from "@nestjs/terminus"; import { JsonRpcHealthIndicator } from "./jsonRpcProvider.health"; @Controller(["health", "ready"]) -export class HealthController { +export class HealthController implements OnApplicationShutdown { private readonly logger: Logger; constructor( @@ -17,10 +17,18 @@ export class HealthController { @HealthCheck() public async check(): Promise { try { - return await this.healthCheckService.check([() => this.jsonRpcHealthIndicator.isHealthy("jsonRpcProvider")]); + const healthCheckResult = await this.healthCheckService.check([ + () => this.jsonRpcHealthIndicator.isHealthy("jsonRpcProvider"), + ]); + this.logger.debug({ message: "Health check result", ...healthCheckResult }); + return healthCheckResult; } catch (error) { this.logger.error({ message: error.message, response: error.getResponse() }, error.stack); throw error; } } + + onApplicationShutdown(signal?: string): void { + this.logger.debug({ message: "Received a signal", signal }); + } }