mirror of
https://github.com/apricote/Listory.git
synced 2026-01-13 21:21:02 +00:00
fix(health): send healthcheck result to sentry to improve debugging
This commit is contained in:
parent
d1a5eb57d7
commit
dbf4374aeb
1 changed files with 10 additions and 3 deletions
|
|
@ -1,12 +1,13 @@
|
||||||
import { Controller, Get } from "@nestjs/common";
|
import { Controller, Get } from "@nestjs/common";
|
||||||
import { ConfigService } from "@nestjs/config";
|
import { ConfigService } from "@nestjs/config";
|
||||||
import {
|
import {
|
||||||
HttpHealthIndicator,
|
|
||||||
HealthCheck,
|
HealthCheck,
|
||||||
HealthCheckResult,
|
HealthCheckResult,
|
||||||
HealthCheckService,
|
HealthCheckService,
|
||||||
|
HttpHealthIndicator,
|
||||||
TypeOrmHealthIndicator,
|
TypeOrmHealthIndicator,
|
||||||
} from "@nestjs/terminus";
|
} from "@nestjs/terminus";
|
||||||
|
import { configureScope, Scope } from "@sentry/node";
|
||||||
|
|
||||||
@Controller("api/v1/health")
|
@Controller("api/v1/health")
|
||||||
export class HealthCheckController {
|
export class HealthCheckController {
|
||||||
|
|
@ -19,8 +20,8 @@ export class HealthCheckController {
|
||||||
|
|
||||||
@Get()
|
@Get()
|
||||||
@HealthCheck()
|
@HealthCheck()
|
||||||
check(): Promise<HealthCheckResult> {
|
async check(): Promise<HealthCheckResult> {
|
||||||
return this.health.check([
|
const health = await this.health.check([
|
||||||
() =>
|
() =>
|
||||||
this.http.pingCheck(
|
this.http.pingCheck(
|
||||||
"spotify-web",
|
"spotify-web",
|
||||||
|
|
@ -33,5 +34,11 @@ export class HealthCheckController {
|
||||||
),
|
),
|
||||||
() => this.typeorm.pingCheck("db"),
|
() => this.typeorm.pingCheck("db"),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
configureScope((scope: Scope) => {
|
||||||
|
scope.setExtra("health", health);
|
||||||
|
});
|
||||||
|
|
||||||
|
return health;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue