From dbf4374aeba767ba6221ad2787922c905a35e989 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julian=20T=C3=B6lle?= Date: Sat, 11 Jun 2022 14:02:48 +0200 Subject: [PATCH] fix(health): send healthcheck result to sentry to improve debugging --- src/health-check/health-check.controller.ts | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/health-check/health-check.controller.ts b/src/health-check/health-check.controller.ts index 28532e2..b1a4c4d 100644 --- a/src/health-check/health-check.controller.ts +++ b/src/health-check/health-check.controller.ts @@ -1,12 +1,13 @@ import { Controller, Get } from "@nestjs/common"; import { ConfigService } from "@nestjs/config"; import { - HttpHealthIndicator, HealthCheck, HealthCheckResult, HealthCheckService, + HttpHealthIndicator, TypeOrmHealthIndicator, } from "@nestjs/terminus"; +import { configureScope, Scope } from "@sentry/node"; @Controller("api/v1/health") export class HealthCheckController { @@ -19,8 +20,8 @@ export class HealthCheckController { @Get() @HealthCheck() - check(): Promise { - return this.health.check([ + async check(): Promise { + const health = await this.health.check([ () => this.http.pingCheck( "spotify-web", @@ -33,5 +34,11 @@ export class HealthCheckController { ), () => this.typeorm.pingCheck("db"), ]); + + configureScope((scope: Scope) => { + scope.setExtra("health", health); + }); + + return health; } }