haskell-servant / servant

Servat is a Haskell DSL for describing, serving, querying, mocking, documenting web applications and more!
https://docs.servant.dev/
1.82k stars 412 forks source link

Add cookbook to expose Prometheus counters. #1730

Open lucasdicioccio opened 6 months ago

lucasdicioccio commented 6 months ago

@tchoutri :kissing:

Not sure when I'll have time to address comments, so feel free to directly edit the PR.

The code itself is inspired from what I do in prodapi.

lucasdicioccio commented 6 months ago

@tchoutri any comment?

tchoutri commented 6 months ago

Sorry for the time, I got sidetracked by servant-quickcheck, which needed some love.

Any reason why you didn't use https://hackage.haskell.org/package/wai-middleware-prometheus for the WAI integration? I'm asking since it's part of the same family of packages as wai-middleware-prometheus.

lucasdicioccio commented 6 months ago

Any reason why you didn't use https://hackage.haskell.org/package/wai-middleware-prometheus for the WAI integration? I'm asking since it's part of the same family of packages as wai-middleware-prometheus.

Two things.

I haven't discussed (a), which is more of a taste/personal-experience judgment but we could add a mention as well (and maybe link to another cookbook to embed a middleware/serve a Raw Application). For (b) it's a bit motivated in the writing, adding a filtering query-param in prodapi is low on my priority list but it's quite often that I wish I had a way to reduce the prometheus payload at the server-side.

tchoutri commented 6 months ago

@lucasdicioccio cool, thanks for the explanation. :)