-
Notifications
You must be signed in to change notification settings - Fork 0
feat: add atlas-server observability metrics #47
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
df1ebb2
feat: add atlas-server observability metrics
pthmas 9675bff
fix: address observability review feedback
pthmas 5f3ada6
fix: satisfy backend clippy
pthmas b629530
feat: extend observability with lag, missing blocks, and processing d…
pthmas 948d0fc
fix: drive head-block metrics from batch watermark, not end_block
pthmas 6563d09
merge: resolve conflicts with main (erc20 supply history, chain logo …
pthmas File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| use axum::{extract::State, http::StatusCode, response::IntoResponse, Json}; | ||
| use serde::Serialize; | ||
| use std::sync::Arc; | ||
|
|
||
| use crate::api::AppState; | ||
|
|
||
| #[derive(Serialize)] | ||
| struct HealthResponse { | ||
| status: &'static str, | ||
| #[serde(skip_serializing_if = "Option::is_none")] | ||
| reason: Option<String>, | ||
| } | ||
|
|
||
| /// GET /health/live — liveness probe (process is alive) | ||
| pub async fn liveness() -> impl IntoResponse { | ||
| Json(HealthResponse { | ||
| status: "ok", | ||
| reason: None, | ||
| }) | ||
| } | ||
|
|
||
| /// GET /health/ready — readiness probe (DB reachable, indexer fresh) | ||
| pub async fn readiness(State(state): State<Arc<AppState>>) -> impl IntoResponse { | ||
| // Check DB connectivity | ||
| if let Err(e) = sqlx::query("SELECT 1").execute(&state.pool).await { | ||
| return ( | ||
| StatusCode::SERVICE_UNAVAILABLE, | ||
| Json(HealthResponse { | ||
| status: "not_ready", | ||
| reason: Some(format!("database unreachable: {e}")), | ||
| }), | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
| ); | ||
| } | ||
|
|
||
| // Check indexer freshness (head within 5 minutes) | ||
| if let Some(block) = state.head_tracker.latest().await { | ||
| let now = chrono::Utc::now(); | ||
| let age = now - block.indexed_at; | ||
| if age > chrono::Duration::minutes(5) { | ||
| return ( | ||
| StatusCode::SERVICE_UNAVAILABLE, | ||
| Json(HealthResponse { | ||
| status: "not_ready", | ||
| reason: Some(format!( | ||
| "indexer stale: last block indexed {}s ago", | ||
| age.num_seconds() | ||
| )), | ||
| }), | ||
| ); | ||
| } | ||
| } | ||
|
coderabbitai[bot] marked this conversation as resolved.
Outdated
|
||
|
|
||
| ( | ||
| StatusCode::OK, | ||
| Json(HealthResponse { | ||
| status: "ready", | ||
| reason: None, | ||
| }), | ||
| ) | ||
| } | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| use axum::extract::State; | ||
| use std::sync::Arc; | ||
|
|
||
| use crate::api::AppState; | ||
|
|
||
| /// GET /metrics — Prometheus text format | ||
| pub async fn metrics(State(state): State<Arc<AppState>>) -> String { | ||
| state.prometheus_handle.render() | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.