Skip to content

Commit 0d5d95d

Browse files
authored
Merge pull request #3146 from spinframework/outbound-networking-error-type
outbound-networking: Add error.type to tracing::error!
2 parents 4aa07a8 + 6c239e5 commit 0d5d95d

File tree

1 file changed

+16
-6
lines changed
  • crates/factor-outbound-networking/src

1 file changed

+16
-6
lines changed

crates/factor-outbound-networking/src/lib.rs

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,18 @@ impl Factor for OutboundNetworkingFactor {
9292
.expression_resolver()
9393
.clone();
9494
let allowed_hosts_future = async move {
95-
let prepared = resolver.prepare().await?;
96-
AllowedHostsConfig::parse(&hosts, &prepared)
95+
let prepared = resolver.prepare().await.inspect_err(|err| {
96+
tracing::error!(
97+
%err, "error.type" = "variable_resolution_failed",
98+
"Error resolving variables when checking request against allowed outbound hosts",
99+
);
100+
})?;
101+
AllowedHostsConfig::parse(&hosts, &prepared).inspect_err(|err| {
102+
tracing::error!(
103+
%err, "error.type" = "invalid_allowed_hosts",
104+
"Error parsing allowed outbound hosts",
105+
);
106+
})
97107
}
98108
.map(|res| res.map(Arc::new).map_err(Arc::new))
99109
.boxed()
@@ -227,10 +237,10 @@ impl OutboundAllowedHosts {
227237
}
228238

229239
async fn resolve(&self) -> anyhow::Result<Arc<AllowedHostsConfig>> {
230-
self.allowed_hosts_future.clone().await.map_err(|err| {
231-
tracing::error!(%err, "Error resolving variables when checking request against allowed outbound hosts");
232-
anyhow::Error::msg(err)
233-
})
240+
self.allowed_hosts_future
241+
.clone()
242+
.await
243+
.map_err(anyhow::Error::msg)
234244
}
235245

236246
fn report_disallowed_host(&self, scheme: &str, authority: &str) {

0 commit comments

Comments
 (0)