зеркало из https://github.com/mozilla/fxa.git
Merge pull request #15843 from mozilla/FXA-7658-investigate-implement-sentry-cron-monitoring
feat(crons): adds sentry monitoring for a cron job
This commit is contained in:
Коммит
d544c27380
|
@ -4,6 +4,7 @@
|
|||
|
||||
import program from 'commander';
|
||||
import { StatsD } from 'hot-shots';
|
||||
import * as Sentry from '@sentry/node';
|
||||
import {
|
||||
setupAuthDatabase,
|
||||
setupDatabase,
|
||||
|
@ -41,6 +42,8 @@ function getKnex(table: string) {
|
|||
}
|
||||
}
|
||||
|
||||
Sentry.init({});
|
||||
|
||||
const logFactory = mozlog(config.log);
|
||||
let log: ILogger = logFactory('default');
|
||||
|
||||
|
@ -478,8 +481,20 @@ export async function run() {
|
|||
if (require.main === module) {
|
||||
process.on('exit', (code) => log.info('exit', { code }));
|
||||
|
||||
const checkInId = Sentry.captureCheckIn({
|
||||
monitorSlug: 'audit-tokens',
|
||||
status: 'in_progress',
|
||||
});
|
||||
|
||||
run()
|
||||
.then((result) => log.info('result', { result }))
|
||||
.then((result) => {
|
||||
log.info('result', { result });
|
||||
Sentry.captureCheckIn({
|
||||
checkInId,
|
||||
monitorSlug: 'audit-tokens',
|
||||
status: 'ok',
|
||||
});
|
||||
})
|
||||
.then(() => {
|
||||
// Make sure statsd closes cleanly so we don't lose any metrics
|
||||
return new Promise((resolve) => {
|
||||
|
@ -495,6 +510,11 @@ if (require.main === module) {
|
|||
})
|
||||
.catch((error) => {
|
||||
log.error('audit-tokens', { error });
|
||||
Sentry.captureCheckIn({
|
||||
checkInId,
|
||||
monitorSlug: 'audit-tokens',
|
||||
status: 'error',
|
||||
});
|
||||
})
|
||||
.finally(process.exit);
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче