Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(server): app initialization starts metrics after multiregion #3697

Merged
merged 1 commit into from
Dec 16, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions packages/server/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down