mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-05-23 17:19:37 +02:00
Merge pull request #12044 from overleaf/em-fix-mongo-connection-pool-metrics
Fix Mongo connection pool metrics in web GitOrigin-RevId: 10de58c5e04a43f2014fbf9cde84d0bbb7daa9ad
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
const mongoose = require('mongoose')
|
||||
const Settings = require('@overleaf/settings')
|
||||
const Metrics = require('@overleaf/metrics')
|
||||
const logger = require('@overleaf/logger')
|
||||
const { addConnectionDrainer } = require('./GracefulShutdown')
|
||||
|
||||
@@ -20,6 +21,10 @@ const connectionPromise = mongoose.connect(
|
||||
Settings.mongo.options
|
||||
)
|
||||
|
||||
connectionPromise.then(mongooseInstance => {
|
||||
Metrics.mongodb.monitor(mongooseInstance.connection.client)
|
||||
})
|
||||
|
||||
addConnectionDrainer('mongoose', async () => {
|
||||
await connectionPromise
|
||||
await mongoose.disconnect()
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
const Metrics = require('@overleaf/metrics')
|
||||
const { ObjectId } = require('mongodb')
|
||||
const OError = require('@overleaf/o-error')
|
||||
const { getNativeDb } = require('./Mongoose')
|
||||
@@ -23,7 +22,6 @@ async function waitForDb() {
|
||||
const db = {}
|
||||
async function setupDb() {
|
||||
const internalDb = await getNativeDb()
|
||||
Metrics.mongodb.monitor(internalDb)
|
||||
|
||||
db.contacts = internalDb.collection('contacts')
|
||||
db.deletedFiles = internalDb.collection('deletedFiles')
|
||||
|
||||
Reference in New Issue
Block a user