Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#6]: Update readme #8

Merged
merged 1 commit into from
Dec 15, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,17 @@

# Servant Performance Counters

This package lets you track performance counters for each of your Servant endpoints using Prometheus.
This package lets you track performance counters for each of your Servant endpoints using [Prometheus](https://prometheus.io/).

# Usage

Servant-Prometheus knows how to handle all official Servant combinators out of the box.
`servant-prometheus` knows how to handle all official Servant combinators out of the box.

## Instrumenting your API
To use Servant-Prometheus, you'll need to wrap your WAI application with the Servant-Prometheus middleware.

```
To use `servant-prometheus`, you'll need to wrap your WAI application with the provided middleware.

```haskell
import Network.Wai.Handler.Warp
import Prometheus.Servant

Expand All @@ -27,7 +28,14 @@ main = do
run 8080 app
```

## Custom metrics

Note, that in example above `defaultMetrics` used, which actually provided as an example and good starting point.
If you want to use your custom metrics (eg you want another labels), you'll need to define an implementation for `Metrics mLatencyLabel mActiveLabel` data.
That's not hard, just copy-paste and tweak accordingly to your needs.

## 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-prometheus`.