Skip to content
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

feat(app): Add hostname label to http metrics #3258

Merged
merged 1 commit into from
Oct 15, 2024

Commits on Oct 14, 2024

  1. feat(app): Add hostname label to route metrics

    this commit introduces an additional label to HTTP and gRPC route
    metrics, containing the DNS host of requests. requests destined for an
    ip address of some kind are not recorded with a hostname metric, as a
    way to help minimize the impact of time series cardinality.
    
    the core of this change is in this field addition:
    
    ```diff
    // /linkerd/app/outbound/src/http/logical/policy/route/metrics/labels.rs
    -pub struct Route(pub ParentRef, pub RouteRef);
    +pub struct Route {
    +    parent: ParentRef,
    +    route: RouteRef,
    +    hostname: Option<dns::Name>,
    +}
    ```
    
    see this part of the change to our `MkStreamLabel` implementation, used
    in our metrics tracking request durtion, and counting response status
    codes:
    
    ```diff
    -    fn mk_stream_labeler<B>(&self, _: &::http::Request<B>) -> Option<Self::StreamLabel> {
    +    fn mk_stream_labeler<B>(&self, req: &::http::Request<B>) -> Option<Self::StreamLabel> {
             let parent = self.params.parent_ref.clone();
             let route = self.params.route_ref.clone();
    -        Some(metrics::LabelHttpRsp::from(metrics::labels::Route::from((
    -            parent, route,
    -        ))))
    +        Some(metrics::LabelHttpRsp::from(metrics::labels::Route::new(
    +            parent,
    +            route,
    +            req.uri(),
    +        )))
         }
    ```
    
    we now inspect the request, and use the URI to label metrics related to
    this traffic by hostname.
    
    a `http_request_hostnames()` test case is added to exercise this.
    
    some todo comments are left, noting where we would ideally like to
    simplify or generalize the machinery related to `RetryLabelExtract`, the
    type that bridges the labels needed based on our `NewService<T>` target,
    and the request type later accepted by the instantiated `Service<T>`.
    
    Signed-off-by: katelyn martin <[email protected]>
    cratelyn committed Oct 14, 2024
    Configuration menu
    Copy the full SHA
    dffabfe View commit details
    Browse the repository at this point in the history