composite-ekg-0.5.3.0: EKG Metrics for Vinyl/Frames records

Safe HaskellNone
LanguageHaskell2010

Composite.Ekg

Synopsis

Documentation

class EkgMetric a where Source #

Type class for constructing a configured EKG metric store for record type of named fields

For example, given:

type FActiveUsers    = "activeUsers"           :-> Gauge
type FResponseTimes  = "endpointResponseTimes" :-> Distribution
type FOrdersPlaced   = "ordersPlaced"          :-> Counter
type EkgMetrics = '[FActiveUsers, FResponseTimes, FRevenue]

And then used in:

configureMetrics :: IO (Rec EkgMetrics)
configureMetrics = do
  store <- newStore
  metrics <- ekgMetric "myapp" store
  _ <- forkServerWith store "localhost" 8080
  pure metrics

Compare to a more traditional:

metrics <- EkgMetrics
 <$> createGauge "myapp.active_users store
 <*> createDistribution "myapp.endpoint_response_times" store
 <*> createCounter "myapp.orders_placed" store

The former is more concise and harder to make naming errors particularly in larger store sets

Minimal complete definition

ekgMetric

Methods

ekgMetric :: Text -> Store -> IO a Source #