linkerd2-proxy icon indicating copy to clipboard operation
linkerd2-proxy copied to clipboard

refactor(http/prom): Simplify `record_response` middleware

Open cratelyn opened this issue 1 year ago • 1 comments

this branch makes a variety of small, non-breaking changes to the linkerd-http-prom crate, and the outbound proxy code related to route- and backend-level metrics.

this branch does not make particularly significant breaking changes to the StreamLabel or MkStreamLabel traits. this branch is focused on minimizing the type complexity of these traits, and consequently in dependent code.

these changes are provided in distinct, atomic commits. readers are encourages to review this branch commit-by-commit. the primary changes that are worth highlighting, mentioned in comments below are:

  • StreamLabel is now object-safe, making use of dyn StreamLabel possible. we now use request::Parts and response::Parts parameters in our trait methods. this means that we no longer need to be generic across request/response bodies, but retain the ability to inspect e.g. status codes.

  • the StreamLabel interface includes associated types for the labels used for metrics related to request/response duration, and counting status codes. we do not however, actually need to separately define these associated types in the MkStreamLabel contract. these types are removed.

  • ResponseMetrics and RequestMetrics are generic over L: StreamLabel. these were previously generic over DurationLabels and StatusLabels, even though the same parent L was used in practice.

  • documentation to various interfaces is added.

cratelyn avatar Sep 27 '24 23:09 cratelyn

nb: this isn't expected to compile right now, i'm refraining from updating app code until the linkerd-http-prom interfaces are more situated.

cratelyn avatar Sep 27 '24 23:09 cratelyn