chore: add comments on the Observation module
This commit is contained in:
committed by
Steve Chavez
parent
2766b844a9
commit
80a4edbd2d
@@ -75,6 +75,7 @@ middleware logLevel getAuthRole = case logLevel of
|
|||||||
, Wai.destination = Wai.Handle stdout
|
, Wai.destination = Wai.Handle stdout
|
||||||
}
|
}
|
||||||
|
|
||||||
|
-- All observations are logged except some that depend on the log-level
|
||||||
observationLogger :: LoggerState -> LogLevel -> ObservationHandler
|
observationLogger :: LoggerState -> LogLevel -> ObservationHandler
|
||||||
observationLogger loggerState logLevel obs = case obs of
|
observationLogger loggerState logLevel obs = case obs of
|
||||||
o@(PoolAcqTimeoutObs _) -> do
|
o@(PoolAcqTimeoutObs _) -> do
|
||||||
|
|||||||
@@ -1,3 +1,7 @@
|
|||||||
|
{-|
|
||||||
|
Module : PostgREST.Logger
|
||||||
|
Description : Metrics based on the Observation module. See Observation.hs.
|
||||||
|
-}
|
||||||
module PostgREST.Metrics
|
module PostgREST.Metrics
|
||||||
( init
|
( init
|
||||||
, MetricsState (..)
|
, MetricsState (..)
|
||||||
@@ -28,6 +32,7 @@ init configDbPoolSize = do
|
|||||||
setGauge poolMaxSize (fromIntegral configDbPoolSize)
|
setGauge poolMaxSize (fromIntegral configDbPoolSize)
|
||||||
pure $ MetricsState poolTimeouts poolAvailable poolWaiting poolMaxSize schemaCacheLoads schemaCacheQueryTime
|
pure $ MetricsState poolTimeouts poolAvailable poolWaiting poolMaxSize schemaCacheLoads schemaCacheQueryTime
|
||||||
|
|
||||||
|
-- Only some observations are used as metrics
|
||||||
observationMetrics :: MetricsState -> ObservationHandler
|
observationMetrics :: MetricsState -> ObservationHandler
|
||||||
observationMetrics (MetricsState poolTimeouts poolAvailable poolWaiting _ schemaCacheLoads schemaCacheQueryTime) obs = case obs of
|
observationMetrics (MetricsState poolTimeouts poolAvailable poolWaiting _ schemaCacheLoads schemaCacheQueryTime) obs = case obs of
|
||||||
(PoolAcqTimeoutObs _) -> do
|
(PoolAcqTimeoutObs _) -> do
|
||||||
|
|||||||
@@ -1,7 +1,10 @@
|
|||||||
{-# LANGUAGE LambdaCase #-}
|
{-# LANGUAGE LambdaCase #-}
|
||||||
{-|
|
{-|
|
||||||
Module : PostgREST.Observation
|
Module : PostgREST.Observation
|
||||||
Description : Observations that can be used for Logging and Metrics
|
Description : This module holds an Observation type which is the core of Observability for PostgREST.
|
||||||
|
The Observation and ObservationHandler (the observer) are abstractions that allow centralizing logging and metrics concerns,
|
||||||
|
only observer calls with an Observation constructor are applied at different parts in the codebase.
|
||||||
|
The Logger and Metrics modules then decide which observations to expose. Not all observations need to be logged nor all correspond to a metric.
|
||||||
-}
|
-}
|
||||||
module PostgREST.Observation
|
module PostgREST.Observation
|
||||||
( Observation(..)
|
( Observation(..)
|
||||||
|
|||||||
Reference in New Issue
Block a user