Skip to content

Commit

Permalink
proxy: remove some trace logs (#8334)
Browse files Browse the repository at this point in the history
  • Loading branch information
conradludgate authored and skyzh committed Jul 15, 2024
1 parent f28abb9 commit 4c7c002
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 41 deletions.
41 changes: 1 addition & 40 deletions proxy/src/http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,11 @@
pub mod health_server;

use std::{str::FromStr, sync::Arc, time::Duration};
use std::time::Duration;

use futures::FutureExt;
pub use reqwest::{Request, Response, StatusCode};
pub use reqwest_middleware::{ClientWithMiddleware, Error};
pub use reqwest_retry::{policies::ExponentialBackoff, RetryTransientMiddleware};
use tokio::time::Instant;
use tracing::trace;

use crate::{
metrics::{ConsoleRequest, Metrics},
Expand All @@ -24,8 +21,6 @@ use reqwest_middleware::RequestBuilder;
/// We deliberately don't want to replace this with a public static.
pub fn new_client() -> ClientWithMiddleware {
let client = reqwest::ClientBuilder::new()
.dns_resolver(Arc::new(GaiResolver::default()))
.connection_verbose(true)
.build()
.expect("Failed to create http client");

Expand All @@ -36,8 +31,6 @@ pub fn new_client() -> ClientWithMiddleware {

pub fn new_client_with_timeout(default_timout: Duration) -> ClientWithMiddleware {
let timeout_client = reqwest::ClientBuilder::new()
.dns_resolver(Arc::new(GaiResolver::default()))
.connection_verbose(true)
.timeout(default_timout)
.build()
.expect("Failed to create http client with timeout");
Expand Down Expand Up @@ -103,38 +96,6 @@ impl Endpoint {
}
}

use hyper_util::client::legacy::connect::dns::{
GaiResolver as HyperGaiResolver, Name as HyperName,
};
use reqwest::dns::{Addrs, Name, Resolve, Resolving};
/// https://docs.rs/reqwest/0.11.18/src/reqwest/dns/gai.rs.html
use tower_service::Service;
#[derive(Debug)]
pub struct GaiResolver(HyperGaiResolver);

impl Default for GaiResolver {
fn default() -> Self {
Self(HyperGaiResolver::new())
}
}

impl Resolve for GaiResolver {
fn resolve(&self, name: Name) -> Resolving {
let this = &mut self.0.clone();
let hyper_name = HyperName::from_str(name.as_str()).expect("name should be valid");
let start = Instant::now();
Box::pin(
Service::<HyperName>::call(this, hyper_name).map(move |result| {
let resolve_duration = start.elapsed();
trace!(duration = ?resolve_duration, addr = %name.as_str(), "resolve host complete");
result
.map(|addrs| -> Addrs { Box::new(addrs) })
.map_err(|err| -> Box<dyn std::error::Error + Send + Sync> { Box::new(err) })
}),
)
}
}

#[cfg(test)]
mod tests {
use super::*;
Expand Down
3 changes: 2 additions & 1 deletion proxy/src/logging.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ use tracing_subscriber::{
pub async fn init() -> anyhow::Result<LoggingGuard> {
let env_filter = EnvFilter::builder()
.with_default_directive(LevelFilter::INFO.into())
.from_env_lossy();
.from_env_lossy()
.add_directive("azure_core::policies::transport=off".parse().unwrap());

let fmt_layer = tracing_subscriber::fmt::layer()
.with_ansi(false)
Expand Down

0 comments on commit 4c7c002

Please sign in to comment.