diff --git a/src/app/main.rs b/src/app/main.rs index 9718647ec..bd04a29be 100644 --- a/src/app/main.rs +++ b/src/app/main.rs @@ -21,7 +21,7 @@ use metrics::{self, FmtMetrics}; use never::Never; use proxy::{ self, buffer, - http::{client, insert_target, metrics::timestamp_request_open, normalize_uri, router}, + http::{client, insert_target, normalize_uri, router}, limit, reconnect, timeout, }; use svc::{self, Layer as _Layer, Stack as _Stack}; @@ -334,7 +334,6 @@ where // including metadata about the request's origin. let server_stack = svc::stack::phantom_data::layer() .push(insert_target::layer()) - .push(timestamp_request_open::layer()) .bind(svc::shared::stack(router)); serve( @@ -404,7 +403,6 @@ where let source_stack = svc::stack::phantom_data::layer() .push(inbound::orig_proto_downgrade::layer()) .push(insert_target::layer()) - .push(timestamp_request_open::layer()) .bind(svc::shared::stack(router)); serve( @@ -504,13 +502,6 @@ where ::Buf: Send, G: GetOriginalDst + Send + 'static, { - // Install the request open timestamp module at the very top of the - // stack, in order to take the timestamp as close as possible to the - // beginning of the request's lifetime. - // - // TODO replace with a metrics module that is registered to the server - // transport. - let listen_addr = bound_port.local_addr(); let server = proxy::Server::new( proxy_name, diff --git a/src/proxy/http/metrics/mod.rs b/src/proxy/http/metrics/mod.rs index 13986a1fd..b39f7eabf 100644 --- a/src/proxy/http/metrics/mod.rs +++ b/src/proxy/http/metrics/mod.rs @@ -10,7 +10,6 @@ use metrics::{latency, Counter, FmtLabels, Histogram}; pub mod classify; mod report; mod service; -pub mod timestamp_request_open; pub use self::report::Report; pub use self::service::layer; diff --git a/src/proxy/http/metrics/timestamp_request_open.rs b/src/proxy/http/metrics/timestamp_request_open.rs deleted file mode 100644 index 9188cf1c7..000000000 --- a/src/proxy/http/metrics/timestamp_request_open.rs +++ /dev/null @@ -1,89 +0,0 @@ -use futures::Poll; -use http; -use std::time::Instant; - -use svc; - -/// A `RequestOpen` timestamp. -/// -/// This is added to a request's `Extensions` by the `TimestampRequestOpen` -/// middleware. It's a newtype in order to distinguish it from other -/// `Instant`s that may be added as request extensions. -#[derive(Copy, Clone, Debug)] -pub struct RequestOpen(pub Instant); - -/// Middleware that adds a `RequestOpen` timestamp to requests. -/// -/// This is a separate middleware from `sensor::Http`, because we want -/// to install it at the earliest point in the stack. This is in order -/// to ensure that request latency metrics cover the overhead added by -/// the proxy as accurately as possible. -#[derive(Copy, Clone, Debug)] -pub struct TimestampRequestOpen { - inner: S, -} - -/// Layers a `TimestampRequestOpen` middleware on an HTTP client. -#[derive(Clone, Debug)] -pub struct Layer(); - -/// Uses an `M`-typed `Stack` to build a `TimestampRequestOpen` service. -#[derive(Clone, Debug)] -pub struct Stack(M); - -// === impl TimestampRequsetOpen === - -impl svc::Service for TimestampRequestOpen -where - S: svc::Service>, -{ - type Request = http::Request; - type Response = S::Response; - type Error = S::Error; - type Future = S::Future; - - fn poll_ready(&mut self) -> Poll<(), Self::Error> { - self.inner.poll_ready() - } - - fn call(&mut self, mut req: Self::Request) -> Self::Future { - req.extensions_mut().insert(RequestOpen(Instant::now())); - self.inner.call(req) - } -} - -// === impl Layer === - -pub fn layer() -> Layer { - Layer() -} - -impl svc::Layer for Layer -where - M: svc::Stack, - M::Value: svc::Service>, -{ - type Value = as svc::Stack>::Value; - type Error = as svc::Stack>::Error; - type Stack = Stack; - - fn bind(&self, next: M) -> Self::Stack { - Stack(next) - } -} - -// === impl Stack === - -impl svc::Stack for Stack -where - M: svc::Stack, - M::Value: svc::Service>, -{ - type Value = TimestampRequestOpen; - type Error = M::Error; - - fn make(&self, target: &T) -> Result { - let inner = self.0.make(target)?; - Ok(TimestampRequestOpen { inner }) - } -}