Skip to content

Commit

Permalink
[104] code review changes
Browse files Browse the repository at this point in the history
  • Loading branch information
ktatarnikov committed Jan 13, 2025
1 parent 77d0274 commit ebcb055
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 16 deletions.
26 changes: 12 additions & 14 deletions rhio/src/blobs/actor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,31 +131,29 @@ impl BlobsActor {
DownloadBlobEvent::Abort(err) => {
error!(parent: &span, %err, "failed downloading blob");

metrics::counter!(
BLOBS_DOWNLOAD_TOTAL,
LABEL_MSG_TYPE => LABEL_BLOB_MSG_TYPE_ERROR,
LABEL_LOCAL_BUCKET => blob.local_bucket_name.to_owned(),
LABEL_REMOTE_BUCKET => blob.remote_bucket_name.to_owned()
)
.increment(1);
BlobsActor::increment_blob_downloads(LABEL_BLOB_MSG_TYPE_ERROR, &blob);
}
DownloadBlobEvent::Done => {
debug!(parent: &span, "finished downloading blob");

metrics::counter!(
BLOBS_DOWNLOAD_TOTAL,
LABEL_MSG_TYPE => LABEL_BLOB_MSG_TYPE_DONE,
LABEL_LOCAL_BUCKET => blob.local_bucket_name.to_owned(),
LABEL_REMOTE_BUCKET => blob.remote_bucket_name.to_owned()
)
.increment(1);
BlobsActor::increment_blob_downloads(LABEL_BLOB_MSG_TYPE_DONE, &blob);
}
}
}

Ok(())
}

fn increment_blob_downloads(msg_type: &str, blob: &SignedBlobInfo) {
metrics::counter!(
BLOBS_DOWNLOAD_TOTAL,
LABEL_MSG_TYPE => msg_type.to_owned(),
LABEL_LOCAL_BUCKET => blob.local_bucket_name.to_owned(),
LABEL_REMOTE_BUCKET => blob.remote_bucket_name.to_owned()
)
.increment(1);
}

async fn shutdown(&mut self) -> Result<()> {
Ok(())
}
Expand Down
8 changes: 6 additions & 2 deletions rhio/src/health.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,20 @@ pub async fn run_http_server(bind_port: u16) -> Result<()> {
IpAddr::V4(Ipv4Addr::UNSPECIFIED),
bind_port,
))
.await?;
.await
.context("TCP Listener binding")?;
debug!(
"HTTP health and metrics endpoint listening on {}",
listener.local_addr()?
);

let app = Router::new().route(HTTP_HEALTH_ROUTE, get(health)).route(
HTTP_METRICS_ROUTE,
get(move || ready(recorder_handle.render())),
);
axum::serve(listener, app).await?;
axum::serve(listener, app)
.await
.context("HTTP metrics and health serving")?;
Ok(())
}

Expand Down

0 comments on commit ebcb055

Please sign in to comment.