Skip to content
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

proxy-http: Simplify TracingExecutor #2849

Merged
merged 1 commit into from
Mar 29, 2024
Merged
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
4 changes: 2 additions & 2 deletions linkerd/app/integration/src/client.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use super::*;
use linkerd_app_core::proxy::http::trace;
use linkerd_app_core::proxy::http::TracingExecutor;
use parking_lot::Mutex;
use std::io;
use tokio::net::TcpStream;
Expand Down Expand Up @@ -252,7 +252,7 @@ fn run(
let work = async move {
let client = hyper::Client::builder()
.http2_only(http2_only)
.executor(trace::Executor::new())
.executor(TracingExecutor)
.build::<Conn, hyper::Body>(conn);
tracing::trace!("client task started");
let mut rx = rx;
Expand Down
4 changes: 2 additions & 2 deletions linkerd/app/integration/src/controller.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use super::*;

pub use linkerd2_proxy_api::destination as pb;
use linkerd2_proxy_api::net;
use linkerd_app_core::proxy::http::trace;
use linkerd_app_core::proxy::http::TracingExecutor;
use parking_lot::Mutex;
use std::collections::VecDeque;
use std::net::IpAddr;
Expand Down Expand Up @@ -372,7 +372,7 @@ where
let _ = listening_tx.send(());
}

let mut http = hyper::server::conn::Http::new().with_executor(trace::Executor::new());
let mut http = hyper::server::conn::Http::new().with_executor(TracingExecutor);
http.http2_only(true);
loop {
let (sock, addr) = listener.accept().await?;
Expand Down
5 changes: 2 additions & 3 deletions linkerd/app/integration/src/server.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use super::app_core::svc::http::TracingExecutor;
use super::*;
use linkerd_app_core::proxy::http::trace;
use std::{
io,
sync::atomic::{AtomicUsize, Ordering},
Expand Down Expand Up @@ -194,8 +194,7 @@ impl Server {
async move {
tracing::info!("support server running");
let mut new_svc = NewSvc(Arc::new(self.routes));
let mut http =
hyper::server::conn::Http::new().with_executor(trace::Executor::new());
let mut http = hyper::server::conn::Http::new().with_executor(TracingExecutor);
match self.version {
Run::Http1 => http.http1_only(true),
Run::Http2 => http.http2_only(true),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,9 @@ use std::future::Future;
use tracing::instrument::Instrument;

#[derive(Clone, Debug, Default)]
pub struct Executor(());
pub struct TracingExecutor;

impl Executor {
pub fn new() -> Self {
Self(())
}
}

impl<F> hyper::rt::Executor<F> for Executor
impl<F> hyper::rt::Executor<F> for TracingExecutor
where
F: Future + Send + 'static,
F::Output: Send + 'static,
Expand Down
6 changes: 3 additions & 3 deletions linkerd/proxy/http/src/h2.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::trace;
use crate::executor::TracingExecutor;
use futures::prelude::*;
pub use h2::{Error as H2Error, Reason};
use hyper::{
Expand Down Expand Up @@ -95,10 +95,10 @@ where
let (io, _meta) = connect.err_into::<Error>().await?;
let mut builder = conn::Builder::new();
builder
.executor(TracingExecutor)
.http2_only(true)
.http2_initial_stream_window_size(initial_stream_window_size)
.http2_initial_connection_window_size(initial_connection_window_size)
.executor(trace::Executor::new());
.http2_initial_connection_window_size(initial_connection_window_size);

// Configure HTTP/2 PING frames
if let Some(timeout) = keepalive_timeout {
Expand Down
3 changes: 2 additions & 1 deletion linkerd/proxy/http/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ pub mod classify;
pub mod client;
pub mod client_handle;
pub mod detect;
mod executor;
mod glue;
pub mod h1;
pub mod h2;
Expand All @@ -21,7 +22,6 @@ mod retain;
mod server;
pub mod strip_header;
pub mod timeout;
pub mod trace;
pub mod upgrade;
pub mod version;

Expand All @@ -33,6 +33,7 @@ pub use self::{
},
client_handle::{ClientHandle, SetClientHandle},
detect::DetectHttp,
executor::TracingExecutor,
header_from_target::NewHeaderFromTarget,
normalize_uri::{MarkAbsoluteForm, NewNormalizeUri},
override_authority::{AuthorityOverride, NewOverrideAuthority},
Expand Down
10 changes: 4 additions & 6 deletions linkerd/proxy/http/src/server.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::{
client_handle::SetClientHandle, h2::Settings as H2Settings, trace, upgrade, BoxBody,
BoxRequest, ClientHandle, Version,
client_handle::SetClientHandle, h2::Settings as H2Settings, upgrade, BoxBody, BoxRequest,
ClientHandle, TracingExecutor, Version,
};
use linkerd_error::Error;
use linkerd_io::{self as io, PeerAddr};
Expand All @@ -13,8 +13,6 @@ use std::{
use tower::Service;
use tracing::{debug, Instrument};

type Server = hyper::server::conn::Http<trace::Executor>;

/// Configures HTTP server behavior.
#[derive(Clone, Debug)]
pub struct Params {
Expand All @@ -34,7 +32,7 @@ pub struct NewServeHttp<X, N> {
#[derive(Clone, Debug)]
pub struct ServeHttp<N> {
version: Version,
server: Server,
server: hyper::server::conn::Http<TracingExecutor>,
inner: N,
drain: drain::Watch,
}
Expand Down Expand Up @@ -62,7 +60,7 @@ where
fn new_service(&self, target: T) -> Self::Service {
let Params { version, h2, drain } = self.params.extract_param(&target);

let mut srv = hyper::server::conn::Http::new().with_executor(trace::Executor::new());
let mut srv = hyper::server::conn::Http::new().with_executor(TracingExecutor);
srv.http2_initial_stream_window_size(h2.initial_stream_window_size)
.http2_initial_connection_window_size(h2.initial_connection_window_size);
// Configure HTTP/2 PING frames
Expand Down
4 changes: 2 additions & 2 deletions linkerd/proxy/tap/src/accept.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use linkerd_conditional::Conditional;
use linkerd_error::Error;
use linkerd_io as io;
use linkerd_meshtls as meshtls;
use linkerd_proxy_http::trace;
use linkerd_proxy_http::TracingExecutor;
use linkerd_tls as tls;
use std::{
collections::HashSet,
Expand Down Expand Up @@ -46,7 +46,7 @@ impl AcceptPermittedClients {
let svc = TapServer::new(tap);
Box::pin(async move {
hyper::server::conn::Http::new()
.with_executor(trace::Executor::new())
.with_executor(TracingExecutor)
.http2_only(true)
.serve_connection(io, svc)
.await
Expand Down
Loading