mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-05-31 12:51:35 +02:00
Merge pull request #22871 from overleaf/em-history-flush-metrics
History flush metrics GitOrigin-RevId: eb8b357427942e9816ad92ccd46c0dd8a65ab939
This commit is contained in:
15
services/project-history/app/js/Metrics.js
Normal file
15
services/project-history/app/js/Metrics.js
Normal file
@@ -0,0 +1,15 @@
|
||||
// @ts-check
|
||||
|
||||
import { prom } from '@overleaf/metrics'
|
||||
|
||||
export const historyFlushDurationSeconds = new prom.Histogram({
|
||||
name: 'history_flush_duration_seconds',
|
||||
help: 'Duration of a history flush in seconds',
|
||||
buckets: [0.05, 0.1, 0.2, 0.3, 0.5, 1, 2, 5, 10],
|
||||
})
|
||||
|
||||
export const historyFlushQueueSize = new prom.Histogram({
|
||||
name: 'history_flush_queue_size',
|
||||
help: 'Size of the queue during history flushes',
|
||||
buckets: prom.exponentialBuckets(1, 2, 10),
|
||||
})
|
||||
@@ -15,6 +15,7 @@ import * as WebApiManager from './WebApiManager.js'
|
||||
import * as SyncManager from './SyncManager.js'
|
||||
import * as Versions from './Versions.js'
|
||||
import * as Errors from './Errors.js'
|
||||
import * as Metrics from './Metrics.js'
|
||||
import { Profiler } from './Profiler.js'
|
||||
|
||||
const keys = Settings.redis.lock.key_schema
|
||||
@@ -61,6 +62,7 @@ export function getRawUpdates(projectId, batchSize, callback) {
|
||||
|
||||
// Process all updates for a project, only check project-level information once
|
||||
export function processUpdatesForProject(projectId, callback) {
|
||||
const startTimeMs = Date.now()
|
||||
LockManager.runWithLock(
|
||||
keys.projectHistoryLock({ project_id: projectId }),
|
||||
(extendLock, releaseLock) => {
|
||||
@@ -76,6 +78,11 @@ export function processUpdatesForProject(projectId, callback) {
|
||||
OError.tag(error)
|
||||
}
|
||||
ErrorRecorder.record(projectId, queueSize, error, callback)
|
||||
if (queueSize > 0) {
|
||||
const duration = (Date.now() - startTimeMs) / 1000
|
||||
Metrics.historyFlushDurationSeconds.observe(duration)
|
||||
Metrics.historyFlushQueueSize.observe(queueSize)
|
||||
}
|
||||
// clear the timestamp in the background if the queue is now empty
|
||||
RedisManager.clearDanglingFirstOpTimestamp(projectId, () => {})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user