-
Notifications
You must be signed in to change notification settings - Fork 5
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
Use the latest & greatest SwiftPrometheus, and utilize Middleware #5
base: master
Are you sure you want to change the base?
Use the latest & greatest SwiftPrometheus, and utilize Middleware #5
Conversation
…tead of Responder+Router.
This looks like a sensible change to a Middleware-based approach. Are there plans for it to be reviewed/merged? |
Thanks for the nudge! I think with |
I only ask because I'm about to use it in a new project - thanks for your work 😀 |
@tonyarnold wanted to check in, were you having any trouble with this diff? |
@Yasumoto no, I haven't! The setup for this branch is far simpler (and less intrusive) than the current release, so I'm 👍 on that. I'd love to see this merged and tagged. Segue: Can you recommend a service (or services) for actually collating and reviewing the metrics this spits out? |
@tonyarnold If This walkthrough looks right once you have both setup and are ready to hook them together. |
Thank you, your advice is appreciated! |
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.
Left some comments (Mostly questions).
Overall LGTM. Reason I initially didn't go with middleware is because I didn't know how they worked, and the Kitura implementation I used as inspiration used Routers/Responders instead of middleware.
let duration = start.timeIntervalSinceNow * -1 | ||
Metrics.Timer(label: self.requestsTimerLabel, dimensions: dimensions).record(duration) | ||
return response | ||
} // should we also handle the failed future too? |
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.
Depending on if we're in front or behind the Error Middleware, we might want to. I'm not sure how this would work in combination with 4xx or 5xx errors. I'll do some research :)
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 think this threads the needle right— if it's been converted to a "response" then we'll properly track the status code, otherwise, we have a separate Error counter which doesn't have the status code at all.
Thanks for the look! @MrLotU I considered your great point about things like It's not ideal since we lose things like As always, open to ideas! |
Hey folks, I have been using this PR's branch locally for a bit in a Vapor 3.x project - I've updated today, and now I see:
It looks like the change to the upstream URL of SwiftPrometheus may have caused this? It changed from: https://github.com/MrLotU/SwiftPrometheus.git with a version of To: https://github.com/Yasumoto/SwiftPrometheus.git with no version, but a branch of |
@tonyarnold So sorry for the trouble! What’s your In theory that branch should be the same tag along with swift-server/swift-prometheus#17 rebased on top, but I must’ve accidentally included the wrong side. Very curious how I kept everything working locally after a |
@tonyarnold Yasumoto/SwiftPrometheus@fe69dfa should fix this up |
No need to apologise - I know what “alpha” means 😉 I appreciate the hard work and time you’ve put into improving this library. |
Status update: this PR is currently on hold and waiting for vapor/routing-kit#80 and vapor/vapor#2089 |
This is a pretty big diff and change in approach, so definitely open to feedback! 🎉
I'm a fan of plugging in
Middleware
(and didn't see discussion on reasons to avoid this pattern, but if there are happy to help document them!) and that enabled us to clean up a good chunk of code.Note that we do lose host-level metrics as part of this, but we'll absolutely need to get rid of
RuntimeTools/SwiftMetrics
because of the conflict with theLogging
module.