Remove the `timestamp_request_open` module (#128)

The `timestamp_request_open` module is no longer used.  It can safely be
removed.
This commit is contained in:
Oliver Gould 2018-11-13 15:35:55 -08:00 committed by GitHub
parent 1595b2457d
commit fbadd969ce
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 1 additions and 100 deletions

View File

@ -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
<B::Data as ::bytes::IntoBuf>::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,

View File

@ -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;

View File

@ -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<S> {
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>(M);
// === impl TimestampRequsetOpen ===
impl<S, B> svc::Service for TimestampRequestOpen<S>
where
S: svc::Service<Request = http::Request<B>>,
{
type Request = http::Request<B>;
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<T, B, M> svc::Layer<T, T, M> for Layer
where
M: svc::Stack<T>,
M::Value: svc::Service<Request = http::Request<B>>,
{
type Value = <Stack<M> as svc::Stack<T>>::Value;
type Error = <Stack<M> as svc::Stack<T>>::Error;
type Stack = Stack<M>;
fn bind(&self, next: M) -> Self::Stack {
Stack(next)
}
}
// === impl Stack ===
impl<T, B, M> svc::Stack<T> for Stack<M>
where
M: svc::Stack<T>,
M::Value: svc::Service<Request = http::Request<B>>,
{
type Value = TimestampRequestOpen<M::Value>;
type Error = M::Error;
fn make(&self, target: &T) -> Result<Self::Value, Self::Error> {
let inner = self.0.make(target)?;
Ok(TimestampRequestOpen { inner })
}
}