Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions crates/apollo_dashboard/resources/dev_grafana.json
Original file line number Diff line number Diff line change
Expand Up @@ -3478,6 +3478,32 @@
],
"extra_params": {}
},
{
"title": "get_strk_to_usd_rate (client-side)",
"description": "client-side infra metrics for request type get_strk_to_usd_rate",
"type": "timeseries",
"exprs": [
"histogram_quantile(0.50,label_replace(sum by (le) (rate(l1_gas_price_local_response_times_secs_bucket{cluster=~\"$cluster\", namespace=~\"$namespace\", pod=~\"$pod\", request_variant=\"get_strk_to_usd_rate\"}[5m])), \"label_name\", \"0.50 l1_gas_price_local_response_times_secs\", \"le\", \".*\"))",
"histogram_quantile(0.95,label_replace(sum by (le) (rate(l1_gas_price_local_response_times_secs_bucket{cluster=~\"$cluster\", namespace=~\"$namespace\", pod=~\"$pod\", request_variant=\"get_strk_to_usd_rate\"}[5m])), \"label_name\", \"0.95 l1_gas_price_local_response_times_secs\", \"le\", \".*\"))",
"histogram_quantile(0.50,label_replace(sum by (le) (rate(l1_gas_price_remote_response_times_secs_bucket{cluster=~\"$cluster\", namespace=~\"$namespace\", pod=~\"$pod\", request_variant=\"get_strk_to_usd_rate\"}[5m])), \"label_name\", \"0.50 l1_gas_price_remote_response_times_secs\", \"le\", \".*\"))",
"histogram_quantile(0.95,label_replace(sum by (le) (rate(l1_gas_price_remote_response_times_secs_bucket{cluster=~\"$cluster\", namespace=~\"$namespace\", pod=~\"$pod\", request_variant=\"get_strk_to_usd_rate\"}[5m])), \"label_name\", \"0.95 l1_gas_price_remote_response_times_secs\", \"le\", \".*\"))",
"histogram_quantile(0.50,label_replace(sum by (le) (rate(l1_gas_price_remote_client_communication_failure_times_secs_bucket{cluster=~\"$cluster\", namespace=~\"$namespace\", pod=~\"$pod\", request_variant=\"get_strk_to_usd_rate\"}[5m])), \"label_name\", \"0.50 l1_gas_price_remote_client_communication_failure_times_secs\", \"le\", \".*\"))",
"histogram_quantile(0.95,label_replace(sum by (le) (rate(l1_gas_price_remote_client_communication_failure_times_secs_bucket{cluster=~\"$cluster\", namespace=~\"$namespace\", pod=~\"$pod\", request_variant=\"get_strk_to_usd_rate\"}[5m])), \"label_name\", \"0.95 l1_gas_price_remote_client_communication_failure_times_secs\", \"le\", \".*\"))"
],
"extra_params": {}
},
{
"title": "get_strk_to_usd_rate (server-side)",
"description": "server-side infra metrics for request type get_strk_to_usd_rate",
"type": "timeseries",
"exprs": [
"histogram_quantile(0.50,label_replace(sum by (le) (rate(l1_gas_price_processing_times_secs_bucket{cluster=~\"$cluster\", namespace=~\"$namespace\", pod=~\"$pod\", request_variant=\"get_strk_to_usd_rate\"}[5m])), \"label_name\", \"0.50 l1_gas_price_processing_times_secs\", \"le\", \".*\"))",
"histogram_quantile(0.95,label_replace(sum by (le) (rate(l1_gas_price_processing_times_secs_bucket{cluster=~\"$cluster\", namespace=~\"$namespace\", pod=~\"$pod\", request_variant=\"get_strk_to_usd_rate\"}[5m])), \"label_name\", \"0.95 l1_gas_price_processing_times_secs\", \"le\", \".*\"))",
"histogram_quantile(0.50,label_replace(sum by (le) (rate(l1_gas_price_queueing_times_secs_bucket{cluster=~\"$cluster\", namespace=~\"$namespace\", pod=~\"$pod\", request_variant=\"get_strk_to_usd_rate\"}[5m])), \"label_name\", \"0.50 l1_gas_price_queueing_times_secs\", \"le\", \".*\"))",
"histogram_quantile(0.95,label_replace(sum by (le) (rate(l1_gas_price_queueing_times_secs_bucket{cluster=~\"$cluster\", namespace=~\"$namespace\", pod=~\"$pod\", request_variant=\"get_strk_to_usd_rate\"}[5m])), \"label_name\", \"0.95 l1_gas_price_queueing_times_secs\", \"le\", \".*\"))"
],
"extra_params": {}
},
{
"title": "initialize (client-side)",
"description": "client-side infra metrics for request type initialize",
Expand Down
3 changes: 3 additions & 0 deletions crates/apollo_l1_gas_price/src/communication.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ impl ComponentRequestHandler<L1GasPriceRequest, L1GasPriceResponse> for L1GasPri
L1GasPriceRequest::GetEthToFriRate(timestamp) => {
L1GasPriceResponse::GetEthToFriRate(self.eth_to_fri_rate(timestamp).await)
}
L1GasPriceRequest::GetStrkToUsdRate(timestamp) => {
L1GasPriceResponse::GetStrkToUsdRate(self.strk_to_usd_rate(timestamp).await)
}
}
}
}
19 changes: 19 additions & 0 deletions crates/apollo_l1_gas_price_types/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ pub enum L1GasPriceRequest {
GetGasPrice(BlockTimestamp),
AddGasPrice(GasPriceData),
GetEthToFriRate(u64),
GetStrkToUsdRate(u64),
}
impl_debug_for_infra_requests_and_responses!(L1GasPriceRequest);
impl_labeled_request!(L1GasPriceRequest, L1GasPriceRequestLabelValue);
Expand All @@ -82,6 +83,7 @@ pub enum L1GasPriceResponse {
GetGasPrice(L1GasPriceProviderResult<PriceInfo>),
AddGasPrice(L1GasPriceProviderResult<()>),
GetEthToFriRate(L1GasPriceProviderResult<u128>),
GetStrkToUsdRate(L1GasPriceProviderResult<u128>),
}
impl_debug_for_infra_requests_and_responses!(L1GasPriceResponse);

Expand All @@ -99,7 +101,11 @@ pub trait L1GasPriceProviderClient: Send + Sync {
timestamp: BlockTimestamp,
) -> L1GasPriceProviderClientResult<PriceInfo>;

/// ETH/FRI rate as 18-decimal fixed-point integer (e.g. 5000 STRK per ETH → `5000 * 10^18`).
async fn get_rate(&self, timestamp: u64) -> L1GasPriceProviderClientResult<u128>;

/// STRK/USD rate as 18-decimal fixed-point integer (e.g. 24.5 STRK per USD → `24.5 * 10^18`).
async fn get_strk_to_usd_rate(&self, timestamp: u64) -> L1GasPriceProviderClientResult<u128>;
}

#[cfg_attr(any(feature = "testing", test), automock)]
Expand Down Expand Up @@ -171,6 +177,19 @@ where
Direct
)
}
#[instrument(skip(self))]
async fn get_strk_to_usd_rate(&self, timestamp: u64) -> L1GasPriceProviderClientResult<u128> {
let request = L1GasPriceRequest::GetStrkToUsdRate(timestamp);
handle_all_response_variants!(
self,
request,
L1GasPriceResponse,
GetStrkToUsdRate,
L1GasPriceClientError,
L1GasPriceProviderError,
Direct
)
}
}

generate_permutation_labels! {
Expand Down
Loading