linkerd2-proxy/lib
Oliver Gould 81b83784f0
Prepare HTTP metrics for per-route classification (#112)
Previously, stacks were built with `Layer::and_then`. This pattern
severely impacts compile-times as stack complexity grows.

In order to ameliorate this, `app::main` has been changed to build
stacks from the "bottom" (endpoint client) to "top" (serverside
connection) by _push_-ing Layers onto a concrete stack, i.e. and not
composing layers for an abstract stack.

While doing this, we take the oppportunity to remove a ton of
now-unnecessary `PhantomData`. A new, dedicated `phantom_data` stack
module can be used to aid type inference as needed.

Other stack utilities like `map_target` and `map_err` have been
introduced to assist this transition.

Furthermore, all instances of `Layer::new` have been changed to a free
`fn layer` to improve readability.

This change sets up two upcoming changes: a stack-oriented `controller`
client and, subsequently, service-profile-based routing.

* Prepare HTTP metrics for per-route classification

In order to support Service Profiles, the proxy will add a new scope of
HTTP metrics prefixed with `route_`, i.e. so that the proxy exposes
`request_total` and `route_request_total` independently.

Furthermore, the proxy must be able to use different
response-classification logic for each route, and this classification
logic should apply to both metrics scopes.

This alters the `proxy::http::metrics` module so that:

1. HTTP metrics may be scoped with a prefix (as the stack is described).

2. The HTTP metrics layer now discovers the classifier by trying to
   extract it from each request's extensions or fall back to a `Default`
   implementation. Only a default implementation is used presently.

3. It was too easy to use the `Classify` trait API incorrectly.
   Non-default classify implementation could cause a runtime panic!
   The API has been changed so that the type system ensures correct
   usage.

4. The HTTP classifier must be configurable per-request. In order to do
   this, we expect a higher stack layer will add response classifiers to
   request extensions when appropriate (i.e., in a follow-up).

Finally, the `telemetry::Report` type requires updating every time a new
set of metrics is added. We don't need a struct to represent this.
`FmtMetrics::and_then` has been added as a combinator so that a fixed
type is not necessary.
2018-10-30 10:47:33 -07:00
..
fs-watch refactor: Structure the proxy in terms of `Stack` (#100) 2018-10-11 11:25:03 -07:00
futures-mpsc-lossy Create a `lib` dir for subcrates (#97) 2018-09-18 16:02:31 -07:00
metrics Prepare HTTP metrics for per-route classification (#112) 2018-10-30 10:47:33 -07:00
router refactor: Structure the proxy in terms of `Stack` (#100) 2018-10-11 11:25:03 -07:00
stack refactor: Build stacks from bottom-to-top (#111) 2018-10-29 14:02:42 -07:00
task refactor: Structure the proxy in terms of `Stack` (#100) 2018-10-11 11:25:03 -07:00
timeout refactor: Structure the proxy in terms of `Stack` (#100) 2018-10-11 11:25:03 -07:00