feat(health): add Sentry status check to health endpoint
- Integrated Sentry status check functionality in the health controller. - Updated tests to validate Sentry active/disabled states. - Improved Sentry initialization with enhanced logging and error handling.
This commit is contained in:
@@ -19,22 +19,35 @@ async function bootstrap() {
|
||||
|
||||
const sentryDsn = configService.get<string>("SENTRY_DSN");
|
||||
if (sentryDsn) {
|
||||
Sentry.init({
|
||||
dsn: sentryDsn,
|
||||
integrations: [nodeProfilingIntegration()],
|
||||
tracesSampleRate: 1.0,
|
||||
profilesSampleRate: 1.0,
|
||||
sendDefaultPii: false, // RGPD
|
||||
beforeSend(event) {
|
||||
// Hachage de l'IP utilisateur pour Sentry si elle est présente
|
||||
if (event.user?.ip_address) {
|
||||
event.user.ip_address = createHash("sha256")
|
||||
.update(event.user.ip_address)
|
||||
.digest("hex");
|
||||
}
|
||||
return event;
|
||||
},
|
||||
});
|
||||
try {
|
||||
Sentry.init({
|
||||
dsn: sentryDsn,
|
||||
integrations: [Sentry.nestIntegration(), nodeProfilingIntegration()],
|
||||
tracesSampleRate: 1.0,
|
||||
profilesSampleRate: 1.0,
|
||||
sendDefaultPii: false, // RGPD
|
||||
beforeSend(event) {
|
||||
// Hachage de l'IP utilisateur pour Sentry si elle est présente
|
||||
if (event.user?.ip_address) {
|
||||
event.user.ip_address = createHash("sha256")
|
||||
.update(event.user.ip_address)
|
||||
.digest("hex");
|
||||
}
|
||||
return event;
|
||||
},
|
||||
});
|
||||
|
||||
const client = Sentry.getClient();
|
||||
if (client?.getOptions().dsn) {
|
||||
logger.log("Sentry is initialized and connection is active");
|
||||
} else {
|
||||
logger.warn("Sentry initialized but DSN is missing");
|
||||
}
|
||||
} catch (error) {
|
||||
logger.error(`Failed to initialize Sentry: ${error.message}`);
|
||||
}
|
||||
} else {
|
||||
logger.warn("Sentry is disabled (SENTRY_DSN not configured)");
|
||||
}
|
||||
|
||||
// Sécurité
|
||||
|
||||
Reference in New Issue
Block a user