-
Notifications
You must be signed in to change notification settings - Fork 268
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
wip(prom): Simplify metrics traits #3242
base: main
Are you sure you want to change the base?
Commits on Sep 27, 2024
-
Configuration menu - View commit details
-
Copy full SHA for cf8a249 - Browse repository at this point
Copy the full SHA cf8a249View commit details -
refactor(prom): Remove
MkStreamLabel
's associated types (#3234)`MkStreamLabel` is, in short, a generic `(&Request) -> Option<StreamLabel>` function. we use it to inspect a request, and potentially provide the caller with an object that can provide relevant labels. 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. instead, we can return a generic `StreamLabel` of some sort, and leave the responsibility of the (admittedly baroque) associated type access to our type aliases like `RecordResponseDuration` and `RecordRequestDuration`. this change has a pleasant knock-on effect of leaving a number of the labels submodule's type aliases unused. this commit accordingly removes aliases like `HttpRouteRsp`, `GrpcRouteRsp`, `HttpRouteBackendRsp`, and `GrpcRouteBackendRsp`. this is a small initial step towards simplifying code that must interact with the `MkStreamLabel` interface. Signed-off-by: katelyn martin <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for c024811 - Browse repository at this point
Copy the full SHA c024811View commit details -
refactor(prom): Make
MkStreamLabel
andStreamLabel
object-safeour north star is making our metrics middleware easier to work with. we want `StreamLabel` to be boxable. this will let us avoid needing to thread baroque generics throughout our layer / service code, and instead rely on dynamic dispatch instead of static `L: StreamLabel` bounds. in order to move in that direction, we must take a small step back first. these traits must be object-safe in order to do that. for a trait to be object safe, per the Rust Reference, we may not use any function-level generics. accordingly, this moves the `<B>` bounds up to the top-level traits. this makes some of our type aliases icky, and introduces new generic parameters to various types/interfaces. we will be able to walk those back in subsequent commits, now that these traits can be placed in e.g. `Box<dyn StreamLabel>` values. NB: as this is an "Zwischenzug"¹ commit, we don't update the app crates. this commit will fail to compile if the entire workspace is built. Signed-off-by: katelyn martin <[email protected]> 1 - https://en.wikipedia.org/wiki/Zwischenzug
Configuration menu - View commit details
-
Copy full SHA for 0b6dbb0 - Browse repository at this point
Copy the full SHA 0b6dbb0View commit details -
refactor(prom): Provide
Parts
to label traitsthis commit updates the signature of `mk_stream_labeler()` and `init_response()` to instead examine the `http::request::Parts` and `http::response::Parts`, respectively. this is another step to simplify our label traits. no implementation of `MkStreamLabel` examines the body of the request. moreover, none even uses the `req` parameter at all! the intent of this signature seems reasonable however, we may want to look at certain requests and opt to ignore them. one could imagine an `l5d-*` header to refrain from installing telemetry on the response body, for example. however, as the last commit showed, we are subject to plenty of pain related to body generics. let's remove the need for them.
Configuration menu - View commit details
-
Copy full SHA for 3d701af - Browse repository at this point
Copy the full SHA 3d701afView commit details -
refactor(prom): Remove
MkStreamLabel
andStreamLabel
type parametersnow that we have switched over to inspect the `Parts` head material of the requests and responses, we can remove these type parameters, whilst remaining object-safe. nice!
Configuration menu - View commit details
-
Copy full SHA for c3d9938 - Browse repository at this point
Copy the full SHA c3d9938View commit details -
Configuration menu - View commit details
-
Copy full SHA for 7965d01 - Browse repository at this point
Copy the full SHA 7965d01View commit details