servant-ekg: Helpers for using ekg with servant

[ bsd3, library, servant, system, web ] [ Propose Tags ]

Helpers for using ekg with servant, e.g.. counters per endpoint.


[Skip to Readme]

Modules

[Index] [Quick Jump]

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

Versions [RSS] 0.2.0.0, 0.3, 0.3.1
Change log CHANGELOG.md
Dependencies base (>=4.9 && <4.13), ekg-core (>=0.1.1.4 && <0.2), hashable (>=1.2.7.0 && <1.3), http-types (>=0.12.2 && <0.13), servant (>=0.14 && <0.17), text (>=1.2.3.0 && <1.3), time (>=1.6.0.1 && <1.9), unordered-containers (>=0.2.9.0 && <0.3), wai (>=3.2.0 && <3.3) [details]
License BSD-3-Clause
Author Anchor Engineering <engineering@lists.anchor.net.au>, Servant Contributors
Maintainer Servant Contributors <haskell-servant-maintainers@googlegroups.com>
Category Servant, Web, System
Source repo head: git clone https://github.com/haskell-servant/servant-ekg.git
Uploaded by phadej at 2019-02-28T08:38:31Z
Distributions
Downloads 1926 total (25 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2019-02-28 [all 1 reports]

Readme for servant-ekg-0.3

[back to package description]

servant-ekg

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.