diff --git a/packages/server/app.ts b/packages/server/app.ts index c6d69f1301..cd9fb7d80d 100644 --- a/packages/server/app.ts +++ b/packages/server/app.ts @@ -11,7 +11,7 @@ import compression from 'compression' import cookieParser from 'cookie-parser' import { createTerminus } from '@godaddy/terminus' -import Logging from '@/logging' +import Metrics from '@/logging' import { startupLogger, shutdownLogger, @@ -403,9 +403,6 @@ export async function init() { // Should perhaps be done manually? await migrateDbToLatest({ region: 'main', db: knex }) - // Logging relies on 'regions' table in the database, so much be initialized after migrations - await Logging(app) - app.use(cookieParser()) app.use(DetermineRequestIdMiddleware) app.use(determineClientIpAddressMiddleware) @@ -453,6 +450,11 @@ export async function init() { // Initialize healthchecks const healthchecks = await healthchecksInitFactory()(app, true) + // Metrics relies on 'regions' table in the database, so much be initialized after migrations in the main database ("migrateDbToLatest({ region: 'main'," etc..) + // It also relies on the regional knex clients, which will initialize and run migrations in the respective regions. + // It must be initialized after the multiregion module is initialized in ModulesSetup.init + await Metrics(app) + // Init HTTP server & subscription server const server = http.createServer(app) const subscriptionServer = buildApolloSubscriptionServer(server)