Skip to content

Commit

Permalink
Improve metrics bind error message
Browse files Browse the repository at this point in the history
Previously:
```
app_main: Err: Address already in use (os error 98)
```
Now:
```
app_main: Err: binding to socket [::]:8000

Caused by:
    Address already in use (os error 98)
```
  • Loading branch information
joel0 authored and inikulin committed Apr 7, 2024
1 parent 1525589 commit 300231d
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions foundations/src/telemetry/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
use super::metrics;
use super::settings::TelemetrySettings;
use crate::{BootstrapResult, Result};
use anyhow::anyhow;
use anyhow::{anyhow, Context as _};
use futures_util::future::BoxFuture;
use futures_util::ready;
use futures_util::FutureExt;
Expand Down Expand Up @@ -114,7 +114,9 @@ pub(super) fn init(
#[cfg(feature = "settings")]
let addr = SocketAddr::from(addr);

let socket = TcpListener::from(bind_socket(addr)?);
let socket = TcpListener::from(
bind_socket(addr).with_context(|| format!("binding to socket {addr:?}"))?,
);
let builder = Server::from_tcp(socket)?;
let service = RouterService::new(router).map_err(|err| anyhow!(err))?;

Expand Down

0 comments on commit 300231d

Please sign in to comment.