@@ -42,7 +42,7 @@ deployment :: Text
42
42
deployment = tShow Deployment. deployment
43
43
44
44
metricUpdateInterval :: Time. NominalDiffTime
45
- metricUpdateInterval = 10 * 60 -- 10 mins
45
+ metricUpdateInterval = 5 * 60 -- 5 mins
46
46
47
47
-- | Low resolution metrics that are updated rarely.
48
48
data SlowChangingMetrics = SlowChangingMetrics
@@ -63,7 +63,8 @@ data SlowChangingMetrics = SlowChangingMetrics
63
63
-- Number of total public or private definitions on /main branch of all Share projects
64
64
numTotalPublicOrPrivateDefinitions :: Int64 ,
65
65
usersWithContributions :: Int64 ,
66
- usersWithTickets :: Int64
66
+ usersWithTickets :: Int64 ,
67
+ causalDiffQueueEntriesCount :: Int64
67
68
}
68
69
69
70
-- | Serves the app's prometheus metrics at `/metrics`
@@ -77,7 +78,7 @@ serveMetricsMiddleware env = do
77
78
refreshGauges getMetrics
78
79
Prom. prometheus prometheusSettings app req handleResponse
79
80
where
80
- runPG = PG. runSessionWithPool (Env. pgConnectionPool env) . PG. readTransaction
81
+ runPG = PG. runSessionWithPool (Env. pgConnectionPool env) . PG. transaction PG. ReadCommitted PG. Read
81
82
prometheusSettings =
82
83
Prom. def
83
84
{ Prom. prometheusEndPoint = [" metrics" ],
@@ -311,6 +312,7 @@ queryMetrics now = do
311
312
numTotalPublicDefinitions <- Q. numTotalPublicDefinitions
312
313
usersWithContributions <- Q. usersInteractedWithContributions
313
314
usersWithTickets <- Q. usersInteractedWithTickets
315
+ causalDiffQueueEntriesCount <- Q. numCausalDiffQueueEntries
314
316
pure SlowChangingMetrics {.. }
315
317
316
318
-- | Since some time-based metrics will change due to the passage of time rather than any
@@ -339,6 +341,8 @@ refreshGauges getMetrics = do
339
341
Prom. withLabel numUsersWithContributions (deployment, service) \ gauge -> Prom. setGauge gauge (fromIntegral usersWithContributions)
340
342
Prom. withLabel numUsersWithTickets (deployment, service) \ gauge -> Prom. setGauge gauge (fromIntegral usersWithTickets)
341
343
344
+ Prom. withLabel numCausalDiffQueueEntries (deployment, service) \ gauge -> Prom. setGauge gauge (fromIntegral causalDiffQueueEntriesCount)
345
+
342
346
{-# NOINLINE numUniqueAccountsWithAPushInLastWeek #-}
343
347
numUniqueAccountsWithAPushInLastWeek :: Prom. Vector Prom. Label2 Prom. Gauge
344
348
numUniqueAccountsWithAPushInLastWeek =
@@ -423,6 +427,18 @@ webhookSendingDurationSeconds =
423
427
" webhook_sending_duration_seconds"
424
428
" The time it took to send a notification webhook"
425
429
430
+ {-# NOINLINE numCausalDiffQueueEntries #-}
431
+ numCausalDiffQueueEntries :: Prom. Vector Prom. Label2 Prom. Gauge
432
+ numCausalDiffQueueEntries =
433
+ Prom. unsafeRegister $
434
+ Prom. vector (" deployment" , " service" ) $
435
+ Prom. gauge info
436
+ where
437
+ info =
438
+ Prom. Info
439
+ " causal_diff_queue_entries_count"
440
+ " The number of causal diffs in the queue."
441
+
426
442
timeActionIntoHistogram :: (Prom. Label l , MonadUnliftIO m ) => (Prom. Vector l Prom. Histogram ) -> l -> m c -> m c
427
443
timeActionIntoHistogram histogram l m = do
428
444
startTime <- liftIO $ Clock. getTime Monotonic
0 commit comments