-
Notifications
You must be signed in to change notification settings - Fork 152
Migrate alerter crate from warp to axum #4045
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
Conversation
Replace warp with axum for the alerter service's metrics endpoint. Add axum metrics handler to observe crate, gated behind the existing axum-tracing feature to maintain backward compatibility. Changes: - Add handle_metrics_axum() to observe crate (feature-gated) - Update alerter to use axum::Server::bind() API - Enable axum-tracing feature in alerter's observe dependency - Fix observe Cargo.toml to use dep:axum syntax for feature - Replace warp dependency with axum in alerter 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
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.
Code Review
This pull request successfully migrates the alerter crate from warp to axum, modernizing the service and correctly implementing the axum server for metrics. However, a potential Denial of Service vulnerability was identified due to an unhandled error when starting the server. Improving error handling is recommended to prevent silent failures and ensure better observability.
| pub fn handle_metrics_axum() -> axum::Router { | ||
| async fn metrics_handler() -> String { | ||
| encode(get_registry()) | ||
| } | ||
|
|
||
| axum::Router::new().route("/metrics", axum::routing::get(metrics_handler)) | ||
| } |
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.
This function is not as composable as the warp one as it already creates the whole router and not just the /metrics handler. I think this would have to be adjusted if you want to use it for example in the orderbook crate which has more than the metrics endpoint.
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.
For metrics specifically, it doesn't matter much because the metrics endpoint is a whole separate service — see serve_metrics
I'll migrate the metrics endpoint after to make this uniform
Description
Migrate the alerter crate from warp to axum (part of Q1 roadmap)
Changes
handle_metrics_axum()function to observe crate (feature-gated)dep:axumsyntaxHow to test
cargo r -p alerter --bin alerter -- --zero-ex-api-key ""curl -X GET http://localhost:9588/metrics