Skip to content

feat(metrics): add metric for builder proxy being up #143

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

Closed
wants to merge 1 commit into from
Closed
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
11 changes: 10 additions & 1 deletion src/metrics.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::time::Duration;

use metrics::{Counter, Histogram, counter, histogram};
use metrics::{Counter, Gauge, Histogram, counter, gauge, histogram};
use metrics_derive::Metrics;

use crate::server::PayloadSource;
Expand All @@ -26,6 +26,10 @@ pub struct ServerMetrics {
#[allow(dead_code)]
pub builder_rpc_response_count: Counter,

#[metric(describe = "Whether the builder client is up")]
#[allow(dead_code)]
pub builder_up: Gauge,

// L2 proxy metrics
#[metric(describe = "Latency for l2 client forwarded rpc calls (excluding the engine api)", labels = ["method"])]
#[allow(dead_code)]
Expand Down Expand Up @@ -73,6 +77,11 @@ impl ServerMetrics {
histogram!("rpc.builder_forwarded_call", "method" => method).record(latency.as_secs_f64());
}

pub fn record_builder_up(&self, up: bool) {
let val = if up { 1 } else { 0 };
gauge!("rpc.builder_up").set(val);
}

pub fn increment_builder_rpc_response_count(
&self,
http_status_code: String,
Expand Down
3 changes: 3 additions & 0 deletions src/proxy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,9 @@ async fn record_metrics(
if let Some(metrics) = &metrics {
match source {
PayloadSource::Builder => {
metrics.record_builder_up(
http_status_code == StatusCode::INTERNAL_SERVER_ERROR.to_string(),
);
metrics.record_builder_forwarded_call(duration, method.to_string());
metrics.increment_builder_rpc_response_count(
http_status_code,
Expand Down