-
Notifications
You must be signed in to change notification settings - Fork 16
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
Support json format for metrics #70
Conversation
Let's change the query param to As per the discussion in #shotover we should also support the HTTP |
I also wonder if it'd be better to use Warp or another high-level HTTP server implementation. From a very cursory read it looks like Warp makes it easier to handle headers and various things. Getting |
BTW, Warp was literally the first thing I found from a DDG search. I'm a total Rust noobie — I have no idea if there's a better candidate HTTP library. |
yeah, am struggling a bit with the headers. @benbromhead any thoughts on wrap ? |
So I haven't had a chance to look at the patch yet, but below are some general thoughts on a HTTP library / implementation (tl;dr, it's complex and we want to do http in other parts of shotover, so lets just do quick and dirty right now even if its just a query param... that way we can do http right for the whole thing when we get to it)...
So right now given that it's a pita to handle headers with what we have, let's choose |
In fact iirc we already do use hyper (https://github.com/hyperium/hyper), which uses tower.rs under the hood, but at least it doesn't leak beyond the current implementation... |
src/admin/httpserver.rs
Outdated
let output = observer.drain(); | ||
let output = match req.uri().query() { | ||
(Some("x-accept=application/json")) => { | ||
let builder = Arc::new(JsonBuilder::new().set_pretty_json(true)); |
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.
given this is machine readable, we probably don't need to do pretty json
controller.observe(&mut observer); | ||
let output = observer.drain(); | ||
let output = match req.uri().query() { | ||
(Some("x-accept=application/json")) => { |
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.
It's kinda annoying the hyper won't even parse the query param for us and we need to match the whole string... but per my previous comment... oh well
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, I tried few things, but looks like will need a better library to do stuff like that
Ah yeah the broken build was my fault, rerunning should work fine now. |
@benbromhead Can you elaborate on this? |
Metrics format accepted as a query parameter "accept". Default format is prometheus. Other accepted format is "application/json".