Skip to content

Commit

Permalink
feat: Count get requests made by near-lake-framework
Browse files Browse the repository at this point in the history
  • Loading branch information
morgsmccauley committed Apr 15, 2024
1 parent f42f843 commit e30878d
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
1 change: 1 addition & 0 deletions block-streamer/src/block_stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ impl BlockStream {
}
}

#[allow(clippy::too_many_arguments)]
#[tracing::instrument(
skip_all,
fields(
Expand Down
6 changes: 6 additions & 0 deletions block-streamer/src/lake_s3_client.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
#![cfg_attr(test, allow(dead_code))]

use async_trait::async_trait;
use near_lake_framework::s3_client::{GetObjectBytesError, ListCommonPrefixesError};

use crate::metrics;

#[cfg(not(test))]
pub use LakeS3ClientImpl as LakeS3Client;
#[cfg(test)]
Expand Down Expand Up @@ -30,6 +34,8 @@ impl near_lake_framework::s3_client::S3Client for LakeS3ClientImpl {
bucket: &str,
prefix: &str,
) -> Result<Vec<u8>, GetObjectBytesError> {
metrics::LAKE_S3_GET_REQUEST_COUNT.inc();

let object = self
.s3_client
.get_object()
Expand Down
8 changes: 7 additions & 1 deletion block-streamer/src/metrics.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
use actix_web::{get, App, HttpServer, Responder};
use lazy_static::lazy_static;
use prometheus::{
register_int_counter_vec, register_int_gauge_vec, Encoder, IntCounterVec, IntGaugeVec,
register_int_counter, register_int_counter_vec, register_int_gauge_vec, Encoder, IntCounter,
IntCounterVec, IntGaugeVec,
};
use tracing_subscriber::layer::Context;
use tracing_subscriber::Layer;

lazy_static! {
pub static ref LAKE_S3_GET_REQUEST_COUNT: IntCounter = register_int_counter!(
"queryapi_block_streamer_lake_s3_get_request_count",
"Number of requests made to S3 from near lake framework",
)
.unwrap();
pub static ref LAST_PROCESSED_BLOCK: IntGaugeVec = register_int_gauge_vec!(
"queryapi_block_streamer_last_processed_block",
"Height of last block seen",
Expand Down

0 comments on commit e30878d

Please sign in to comment.