-
Notifications
You must be signed in to change notification settings - Fork 1k
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
misc/metrics: Replace tide with some other webserver #2432
Comments
I'm glad to help in any way I can. I just don't to go swatting at flys with an albacore tuna if that can be avoided. Am I missing a second issue that was not fixed? It seemed the cited issues were referencing the same thing. |
Hi @esotericbyte, I would very much appreciate additional help here. My motivation:
Given that the list of advisories is relatively small, I suggested to do (3.1) (removing all advisories). Ultimately I don't care how we achieve (1). @esotericbyte how would you approach this problem? |
i wrote a js filter that condensed the advisory from cargo audit --json and realized that all of the warning issues in the main build of rust-libp2p are the same as those for tide alone and that this is also a problem for the example for open metrics client. I will start to work on a version using Warp. It uses some syntax that seems very concise but it does have the same vulnerability with chrono. Actix another alternative and cargo audit itself also uses chrono. |
When using Warp, I recommend using |
Have you taken a look at axum web framework? By the hyper and warp author on axum:
|
I looked at hyper ! It seems that going without a framework and just using the http server , going full boiler obviously is a good way to go and avoids 3 problems.
The disadvantage is longer code. Thinking about responses to comments helped lead me toward this direction. I'd be interested in your opinions. The metrics code example currently uses tide framework to serve the metrics along the side of another server or in this case peer. This is not the start of a web service or to integrate with a framework to collect the metrics. Those are separate issues. This adds a listener to an additional port to provide metrics to e.g. Prometheus. I intend to replace tide. The current plan is to define functions to serve the metrics using hyper.
The goal is simple understandable code to serve the metrics. It's not going to get any more complex. With a short example will compile times have more impact on developer experience than simple code?
|
This is one of the hard questions. My opinion is that warp code can be quite easy to read for someone who is only interested in the HTTP semantics, but it is definitely not simple — to me “simple” means “the abstraction works perfectly, without leakage, and I can understand the implementation details if need be”. A hammer & chisel is simple, a CNC milling machine can do many more things (which may be easy) but is definitely not simple.
As per the above, I cannot tell. I’m using warp in a context where requests happen infrequently, so it wouldn’t even matter if the resulting routing code allocated filters on the heap for every request (which BTW is what the high-level akka-http DSL does, in a completely different ecosystem). Since serving a prometheus endpoint is a rather small surface area, I’d find it simpler to go low-level than to use ca. 1% of a high-level framework (I have no experience with axum yet, so can’t tell whether that counts as “low-level”). |
Axum is around the same abstraction level as tide and warp. It is very new (first release on Jul 30, 2021) and very actively developed. The benefit over tide is that is uses tokio instead of async-std as async runtime. At the same time it uses less "magic" compared to warp and is more actively developed. If you don't need the middleware (e.g. to add metrics to your endpoints) a higher level web frameworks offers and accept some more boilerplate then hyper should be perfectly fine as nearly all web frameworks are a thin layer on top of hyper anyway. In the end it depends on your requirements. I mentioned axum as the previous choice was tide. |
Looks like chrono itself is not patched at all, which is quite unfortunate: chronotope/chrono#499. |
Nearly done with a hyper based metrics server that complies but i need to test it. It's on my fork but is not ready for a PR. After nearly done I can not help but question if the extra complexity of an asynchronous threaded http server is overkill for this purpose. Among possible downsides hyper and tokio had to be compiled with feature full for some trait implementations. |
🙏 No need to be asynchronous. The simpler the better. |
I finished the hyper sever at the above branch and removed Tide from metrics/Cargo.toml |
cargo audit
reports two vulnerabilities in the dependency graph oftide
:Given that we use
tide
for an example only, I would guess any other webserver would do.Blocks #2430.
The text was updated successfully, but these errors were encountered: