Skip to content

Commit

Permalink
Don't expose L1 provider URL in metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
jbearer committed Jan 9, 2025
1 parent 78b16ce commit 8903530
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions types/src/v0/impls/l1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,9 @@ impl L1ClientMetrics {
}

impl L1Provider {
fn new(url: Url, failures: &dyn CounterFamily) -> Self {
fn new(index: usize, url: Url, failures: &dyn CounterFamily) -> Self {
Self {
failures: failures.create(vec![url.to_string()]),
failures: failures.create(vec![index.to_string()]),
inner: Http::new(url),
}
}
Expand All @@ -153,7 +153,8 @@ impl MultiRpcClient {
clients: Arc::new(
clients
.into_iter()
.map(|url| L1Provider::new(url, &*failures))
.enumerate()
.map(|(i, url)| L1Provider::new(i, url, &*failures))
.collect(),
),
status: Default::default(),
Expand Down Expand Up @@ -222,12 +223,13 @@ impl JsonRpcClient for MultiRpcClient {

status.client
};
let client = &self.clients[current % self.clients.len()];
let provider = current % self.clients.len();
let client = &self.clients[provider];
match client.request(method, &params).await {
Ok(res) => Ok(res),
Err(err) => {
let t = Instant::now();
tracing::warn!(?t, method, ?params, "L1 client error: {err:#}");
tracing::warn!(?t, method, ?params, provider, "L1 client error: {err:#}");
client.failures.add(1);

// Keep track of failures, failing over to the next client if necessary.
Expand Down Expand Up @@ -340,11 +342,12 @@ impl L1Client {
Some(urls) => {
// Use a new WebSockets host each time we retry in case there is a
// problem with one of the hosts specifically.
let url = &urls[i % urls.len()];
let provider = i % urls.len();
let url = &urls[provider];
ws = match Provider::<Ws>::connect(url.clone()).await {
Ok(ws) => ws,
Err(err) => {
tracing::warn!(%url, "failed to connect WebSockets provider: {err:#}");
tracing::warn!(provider, "failed to connect WebSockets provider: {err:#}");
sleep(retry_delay).await;
continue;
}
Expand Down

0 comments on commit 8903530

Please sign in to comment.