Skip to content

Conversation

@jmg-duarte
Copy link
Contributor

@jmg-duarte jmg-duarte commented Jan 12, 2026

Description

Migrate the alerter crate from warp to axum (part of Q1 roadmap)

Changes

  • Add handle_metrics_axum() function 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
  • Replace warp with axum in alerter dependencies
  • Extracted ShutdownController to shared, so it is possible to reuse in alerter

How to test

  1. Launch cargo r -p alerter --bin alerter -- --zero-ex-api-key ""
  2. Query the /metrics endpoint curl -X GET http://localhost:9588/metrics

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>
@jmg-duarte jmg-duarte marked this pull request as ready for review January 15, 2026 18:05
@jmg-duarte jmg-duarte requested a review from a team as a code owner January 15, 2026 18:05
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a 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.

Comment on lines +109 to +115
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))
}
Copy link
Contributor

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.

Copy link
Contributor Author

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

@jmg-duarte jmg-duarte requested a review from squadgazzz January 16, 2026 13:21
@jmg-duarte jmg-duarte added this pull request to the merge queue Jan 16, 2026
Merged via the queue into main with commit 135c104 Jan 16, 2026
19 checks passed
@jmg-duarte jmg-duarte deleted the jmgd/axum/alerter branch January 16, 2026 14:38
@github-actions github-actions bot locked and limited conversation to collaborators Jan 16, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants