-
-
Notifications
You must be signed in to change notification settings - Fork 413
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
Add cookbook to expose Prometheus counters. #1730
base: master
Are you sure you want to change the base?
Add cookbook to expose Prometheus counters. #1730
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i blame myself
@tchoutri any comment? |
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, quite a big review, I can understand if you'd rather let me handle it. :)
The second metrics we use to instrument our program is a background thread | ||
incrementing a counter every second. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rather "the second tool we use to instrument our program[…]"? The thread is not the metric, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
correct, it's lazy writing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe We further instrument our program with a second metrics. This second metrics consist of a simple counter. A background thread will increment the counter every second
.
wdyt?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yep!
"pre-rendered" format for the MimeRender instance. | ||
|
||
``` haskell | ||
newtype Metrics = Metrics {toLBS :: ByteString} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
newtype Metrics = Metrics {toLBS :: ByteString} | |
newtype Metrics = Metrics {getMetrics :: ByteString} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe FormattedMetrics
then so that getMetrics
becomes getFormattedMetrics
(if you want to have more explicit types)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah sure let's go!
newtype Metrics = Metrics {toLBS :: ByteString} | ||
|
||
instance MimeRender PlainText Metrics where | ||
mimeRender _ = toLBS |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mimeRender _ = toLBS | |
mimeRender _ = getMetrics |
Co-authored-by: Théophile Choutri <[email protected]>
Co-authored-by: Théophile Choutri <[email protected]>
Co-authored-by: Théophile Choutri <[email protected]>
Co-authored-by: Théophile Choutri <[email protected]>
Co-authored-by: Théophile Choutri <[email protected]>
Co-authored-by: Théophile Choutri <[email protected]>
Co-authored-by: Théophile Choutri <[email protected]>
Co-authored-by: Théophile Choutri <[email protected]>
Co-authored-by: Théophile Choutri <[email protected]>
Co-authored-by: Théophile Choutri <[email protected]>
Co-authored-by: Théophile Choutri <[email protected]>
Co-authored-by: Théophile Choutri <[email protected]>
Co-authored-by: Théophile Choutri <[email protected]>
Co-authored-by: Théophile Choutri <[email protected]>
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). |
@lucasdicioccio cool, thanks for the explanation. :) |
@tchoutri 😗
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.