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

refactor(prom): Remove MkStreamLabel's associated types #3234

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions linkerd/app/outbound/src/http/logical/policy/route.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,6 @@ impl<T> filters::Apply for Http<T> {
}

impl<T> metrics::MkStreamLabel for Http<T> {
type StatusLabels = metrics::labels::HttpRouteRsp;
type DurationLabels = metrics::labels::Route;
type StreamLabel = metrics::LabelHttpRouteRsp;

fn mk_stream_labeler<B>(&self, _: &::http::Request<B>) -> Option<Self::StreamLabel> {
Expand Down Expand Up @@ -227,8 +225,6 @@ impl<T> filters::Apply for Grpc<T> {
}

impl<T> metrics::MkStreamLabel for Grpc<T> {
type StatusLabels = metrics::labels::GrpcRouteRsp;
type DurationLabels = metrics::labels::Route;
type StreamLabel = metrics::LabelGrpcRouteRsp;

fn mk_stream_labeler<B>(&self, _: &::http::Request<B>) -> Option<Self::StreamLabel> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,6 @@ impl<T> filters::Apply for Http<T> {
}

impl<T> metrics::MkStreamLabel for Http<T> {
type StatusLabels = metrics::labels::HttpRouteBackendRsp;
type DurationLabels = metrics::labels::RouteBackend;
type StreamLabel = metrics::LabelHttpRouteBackendRsp;

fn mk_stream_labeler<B>(&self, _: &::http::Request<B>) -> Option<Self::StreamLabel> {
Expand All @@ -176,8 +174,6 @@ impl<T> filters::Apply for Grpc<T> {
}

impl<T> metrics::MkStreamLabel for Grpc<T> {
type StatusLabels = metrics::labels::GrpcRouteBackendRsp;
type DurationLabels = metrics::labels::RouteBackend;
type StreamLabel = metrics::LabelGrpcRouteBackendRsp;

fn mk_stream_labeler<B>(&self, _: &::http::Request<B>) -> Option<Self::StreamLabel> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,6 @@ pub struct RouteBackend(pub ParentRef, pub RouteRef, pub BackendRef);
#[derive(Clone, Debug, Hash, PartialEq, Eq)]
pub struct Rsp<P, L>(pub P, pub L);

pub type RouteRsp<L> = Rsp<Route, L>;
pub type HttpRouteRsp = RouteRsp<HttpRsp>;
pub type GrpcRouteRsp = RouteRsp<GrpcRsp>;

pub type RouteBackendRsp<L> = Rsp<RouteBackend, L>;
pub type HttpRouteBackendRsp = RouteBackendRsp<HttpRsp>;
pub type GrpcRouteBackendRsp = RouteBackendRsp<GrpcRsp>;

#[derive(Clone, Debug, Hash, PartialEq, Eq)]
pub struct HttpRsp {
pub status: Option<http::StatusCode>,
Expand Down
22 changes: 1 addition & 21 deletions linkerd/http/prom/src/record_response.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,27 +32,7 @@ pub use self::{
/// This is specifically to support higher-cardinality status counters and
/// lower-cardinality stream duration histograms.
pub trait MkStreamLabel {
type DurationLabels: EncodeLabelSet
+ Clone
+ Eq
+ std::fmt::Debug
+ std::hash::Hash
+ Send
+ Sync
+ 'static;
type StatusLabels: EncodeLabelSet
+ Clone
+ Eq
+ std::fmt::Debug
+ std::hash::Hash
+ Send
+ Sync
+ 'static;

type StreamLabel: StreamLabel<
DurationLabels = Self::DurationLabels,
StatusLabels = Self::StatusLabels,
>;
type StreamLabel: StreamLabel;

/// Returns None when the request should not be recorded.
fn mk_stream_labeler<B>(&self, req: &http::Request<B>) -> Option<Self::StreamLabel>;
Expand Down
12 changes: 9 additions & 3 deletions linkerd/http/prom/src/record_response/request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use std::{
};
use tokio::{sync::oneshot, time};

use super::{DurationFamily, MkDurationHistogram, MkStreamLabel};
use super::{DurationFamily, MkDurationHistogram, MkStreamLabel, StreamLabel};

/// Metrics type that tracks completed requests.
#[derive(Debug)]
Expand All @@ -25,13 +25,19 @@ pub struct RequestMetrics<DurL, StatL> {
pub type NewRequestDuration<L, X, N> = super::NewRecordResponse<
L,
X,
RequestMetrics<<L as MkStreamLabel>::DurationLabels, <L as MkStreamLabel>::StatusLabels>,
RequestMetrics<
<<L as MkStreamLabel>::StreamLabel as StreamLabel>::DurationLabels,
<<L as MkStreamLabel>::StreamLabel as StreamLabel>::StatusLabels,
>,
N,
>;

pub type RecordRequestDuration<L, S> = super::RecordResponse<
L,
RequestMetrics<<L as MkStreamLabel>::DurationLabels, <L as MkStreamLabel>::StatusLabels>,
RequestMetrics<
<<L as MkStreamLabel>::StreamLabel as StreamLabel>::DurationLabels,
<<L as MkStreamLabel>::StreamLabel as StreamLabel>::StatusLabels,
>,
S,
>;

Expand Down
12 changes: 9 additions & 3 deletions linkerd/http/prom/src/record_response/response.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use std::{
};
use tokio::{sync::oneshot, time};

use super::{DurationFamily, MkDurationHistogram, MkStreamLabel};
use super::{DurationFamily, MkDurationHistogram, MkStreamLabel, StreamLabel};

#[derive(Debug)]
pub struct ResponseMetrics<DurL, StatL> {
Expand All @@ -25,13 +25,19 @@ pub struct ResponseMetrics<DurL, StatL> {
pub type NewResponseDuration<L, X, N> = super::NewRecordResponse<
L,
X,
ResponseMetrics<<L as MkStreamLabel>::DurationLabels, <L as MkStreamLabel>::StatusLabels>,
ResponseMetrics<
<<L as MkStreamLabel>::StreamLabel as StreamLabel>::DurationLabels,
<<L as MkStreamLabel>::StreamLabel as StreamLabel>::StatusLabels,
>,
N,
>;

pub type RecordResponseDuration<L, S> = super::RecordResponse<
L,
ResponseMetrics<<L as MkStreamLabel>::DurationLabels, <L as MkStreamLabel>::StatusLabels>,
ResponseMetrics<
<<L as MkStreamLabel>::StreamLabel as StreamLabel>::DurationLabels,
<<L as MkStreamLabel>::StreamLabel as StreamLabel>::StatusLabels,
>,
S,
>;

Expand Down
Loading