Skip to content

Commit

Permalink
style(monitoring): shift out monitoring to support
Browse files Browse the repository at this point in the history
  • Loading branch information
kishore03109 committed Jun 27, 2024
1 parent 548f0df commit 837714d
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 15 deletions.
1 change: 0 additions & 1 deletion .aws/deploy/backend-task-definition.prod.json
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@
"valueFrom": "PROD_INCOMING_QUEUE_URL"
},
{ "name": "JWT_SECRET", "valueFrom": "PROD_JWT_SECRET" },
{ "name": "KEYCDN_API_KEY", "valueFrom": "PROD_KEYCDN_API_KEY" },
{
"name": "MAX_NUM_OTP_ATTEMPTS",
"valueFrom": "PROD_MAX_NUM_OTP_ATTEMPTS"
Expand Down
1 change: 0 additions & 1 deletion .aws/deploy/backend-task-definition.staging.json
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@
"valueFrom": "STAGING_INCOMING_QUEUE_URL"
},
{ "name": "JWT_SECRET", "valueFrom": "STAGING_JWT_SECRET" },
{ "name": "KEYCDN_API_KEY", "valueFrom": "STAGING_KEYCDN_API_KEY" },
{
"name": "MAX_NUM_OTP_ATTEMPTS",
"valueFrom": "STAGING_MAX_NUM_OTP_ATTEMPTS"
Expand Down
5 changes: 5 additions & 0 deletions common/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import {
Reviewer,
ReviewRequestView,
} from "@database/models"
import MonitoringService from "@root/monitoring"
import AuditLogsService from "@root/services/admin/AuditLogsService"
import RepoManagementService from "@root/services/admin/RepoManagementService"
import GitFileCommitService from "@root/services/db/GitFileCommitService"
Expand Down Expand Up @@ -248,3 +249,7 @@ export const auditLogsService = new AuditLogsService({
sitesService,
usersService,
})

export const monitoringService = new MonitoringService({
launchesService,
})
1 change: 1 addition & 0 deletions src/config/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,7 @@ const config = convict({
doc: "Slackbot token",
env: "SLACK_TOKEN",
format: String,
default: "",
},
},
keyCdn: {
Expand Down
19 changes: 11 additions & 8 deletions src/monitoring/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ export default class MonitoringService {
// seems to be a bug in typing, this is a direct
// copy paste from the octokit documentation
// https://octokit.github.io/rest.js/v20#automatic-retries
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const OctokitRetry = Octokit.plugin(retry as any)
const octokitWithRetry: Octokit = new OctokitRetry({
auth: SYSTEM_GITHUB_TOKEN,
Expand Down Expand Up @@ -221,8 +222,16 @@ export default class MonitoringService {
.andThen(() => okAsync(reportCard))
})

return ResultAsync.combineWithAllErrors(domainResolvers)
.andThen(() => {
return ResultAsync.combineWithAllErrors(domainResolvers).map(
() => reportCard
)
}

driver() {
this.monitoringServiceLogger.info("Monitoring service started")
return this.getAllDomains()
.andThen(this.generateReportCard)
.andThen((reportCard) => {
this.monitoringServiceLogger.info({
message: "Report card generated",
meta: {
Expand All @@ -232,11 +241,5 @@ export default class MonitoringService {
})
return okAsync(reportCard)
})
.orElse(() => okAsync([]))
}

driver() {
this.monitoringServiceLogger.info("Monitoring service started")
return this.getAllDomains().andThen(this.generateReportCard)
}
}
4 changes: 0 additions & 4 deletions src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -365,10 +365,6 @@ const authV2Router = new AuthRouter({
sgidAuthRouter,
})

const monitoringService = new MonitoringService({
launchesService,
})

const app = express()

useSharedMiddleware(app)
Expand Down
10 changes: 9 additions & 1 deletion support/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,16 @@ import "module-alias/register"

import express from "express"

import { infraService, sequelize } from "@common/index"
import {
infraService,
launchesService,
monitoringService,
sequelize,
} from "@common/index"
import { useSharedMiddleware } from "@common/middleware"
import { config } from "@root/config/config"
import logger from "@root/logger/logger"
import MonitoringService from "@root/monitoring"

import { ROUTE_VERSION } from "./constants"
import { v2Router } from "./routes"
Expand All @@ -18,6 +24,8 @@ const app = express()
// poller site launch updates
infraService.pollMessages()

monitoringService.driver()

const ROUTE_PREFIX_ISOBOT = `/${ROUTE_VERSION}/isobot`
app.use(ROUTE_PREFIX_ISOBOT, isobotRouter)

Expand Down

0 comments on commit 837714d

Please sign in to comment.