No description
Find a file
Arian van Putten a5ef9c5efd
Merge pull request #32 from Simspace/uverb+fragment-support
support UVerb + correctly bound Fragment instance for older servant versions
2023-08-26 08:06:53 +00:00
.github/workflows no CI coverage for GHC 8.0, 8.2, 8.4, 9.0 2022-01-31 22:43:07 -08:00
bench Enumerate API and populate counters at start time 2019-02-28 09:09:37 +02:00
lib/Servant support UVerb + Fragment 2022-04-07 16:06:12 -07:00
test Enumerate API and populate counters at start time 2019-02-28 09:09:37 +02:00
.gitignore Update to servant-0.15 2019-02-11 15:50:20 +02:00
.travis.yml Tried to get GHC 8.8 and 8.10 under test 2020-10-18 15:44:34 -04:00
cabal.haskell-ci Made work with servant-0.18 2020-10-18 14:44:08 -04:00
cabal.project Allow servant-0.16 2019-02-28 01:15:30 +02:00
cabal.project.local fix tests 2022-01-23 23:38:30 -08:00
CHANGELOG.md Add changelog 2019-02-28 10:03:25 +02:00
LICENSE Initial commit 2015-05-01 12:40:08 +10:00
output.log Update to servant-0.15 2019-02-11 15:50:20 +02:00
README.md basic GitHub Actions 2022-01-22 15:19:49 -08:00
servant-ekg.cabal Merge branch 'master' into uverb+fragment-support 2022-06-01 11:25:42 -07:00
Setup.hs Initial commit 2015-05-01 12:40:08 +10:00
stack.yaml Update to servant-0.15 2019-02-11 15:50:20 +02:00

servant-ekg

Build Status Build status

Servant Performance Counters

This package lets you track peformance counters for each of your Servant endpoints using EKG.

Usage

Servant-EKG knows how to handle all official Servant combinators out of the box.

Instrumenting your API

To use Servant-EKG, you'll need to wrap your WAI application with the Servant-EKG middleware.

import Network.Wai.Handler.Warp
import System.Metrics
import Servant.Ekg

wrapWithEkg :: Proxy api -> Server api -> IO Application
wrapWithEkg api server = do
  monitorEndpoints' <- monitorEndpoints api =<< newStore

  return $ monitorEndpoints' (serve api server)

main :: IO ()
main = do
  let api    = ...
      server = ...

  app <- wrapWithEkg api server

  run 8080 app

Runtime overhead

Instrumenting your API introduces a non-zero runtime overhead, on the order of 200 - 600 µsec depending upon your machine. It's a good idea to run the benchmarks on your intended production platform to get an idea of how large the overhead will be. You'll need to have wrk installed to run the benchmarks.

In general, the runtime overhead should be effectively negligible if your handlers are issuing network requests, such as to databases. If you have handlers that are small, CPU-only, and requested frequently, you will see a performance hit from Servant-EKG.