diff --git a/linkerd/app/outbound/src/http/logical/policy/route/backend/metrics/tests.rs b/linkerd/app/outbound/src/http/logical/policy/route/backend/metrics/tests.rs index dd0e68434b..0644415af1 100644 --- a/linkerd/app/outbound/src/http/logical/policy/route/backend/metrics/tests.rs +++ b/linkerd/app/outbound/src/http/logical/policy/route/backend/metrics/tests.rs @@ -155,13 +155,21 @@ async fn body_data_layer_records_frames() -> Result<(), Error> { tracing::info!("acquiring response body metrics"); let labels = labels::RouteBackend(parent_ref.clone(), route_ref.clone(), backend_ref.clone()); let BodyDataMetrics { - frames_total, - frames_bytes, + // TODO(kate): currently, histograms do not expose their observation count or sum. so, + // we're left unable to exercise these metrics until prometheus/client_rust#242 lands. + // - https://github.com/prometheus/client_rust/pull/241 + // - https://github.com/prometheus/client_rust/pull/242 + #[cfg(feature = "prometheus-client-rust-242")] + frame_size, + .. } = metrics.get_response_body_metrics(&labels); // Before we've sent a response, the counter should be zero. - assert_eq!(frames_total.get(), 0); - assert_eq!(frames_bytes.get(), 0); + #[cfg(feature = "prometheus-client-rust-242")] + { + assert_eq!(frame_size.count(), 0); + assert_eq!(frame_size.sum(), 0); + } // Create a response whose body is backed by a channel that we can send chunks to, send it. tracing::info!("sending response"); @@ -177,8 +185,11 @@ async fn body_data_layer_records_frames() -> Result<(), Error> { }; // Before we've sent any bytes, the counter should be zero. - assert_eq!(frames_total.get(), 0); - assert_eq!(frames_bytes.get(), 0); + #[cfg(feature = "prometheus-client-rust-242")] + { + assert_eq!(frame_size.count(), 0); + assert_eq!(frame_size.sum(), 0); + } // On the client end, poll our call future and await the response. tracing::info!("polling service future"); @@ -205,8 +216,10 @@ async fn body_data_layer_records_frames() -> Result<(), Error> { resp_tx.send_data("hello".into()).await?; let chunk = read_chunk(&mut body).await?; debug_assert_eq!("hello".as_bytes(), chunk, "should get same value back out"); - assert_eq!(frames_total.get(), 1); - assert_eq!(frames_bytes.get(), 5); + #[cfg(feature = "prometheus-client-rust-242")] + assert_eq!(frame_size.count(), 1); + #[cfg(feature = "prometheus-client-rust-242")] + assert_eq!(frame_size.sum(), 5); } { @@ -219,8 +232,10 @@ async fn body_data_layer_records_frames() -> Result<(), Error> { chunk, "should get same value back out" ); - assert_eq!(frames_total.get(), 2); - assert_eq!(frames_bytes.get(), 5 + 8); + #[cfg(feature = "prometheus-client-rust-242")] + assert_eq!(frame_size.count(), 2); + #[cfg(feature = "prometheus-client-rust-242")] + assert_eq!(frame_size.sum(), 5 + 8); } { @@ -233,8 +248,10 @@ async fn body_data_layer_records_frames() -> Result<(), Error> { Poll::Ready(None) => {} _ => panic!("got unexpected poll result"), }; - assert_eq!(frames_total.get(), 2); - assert_eq!(frames_bytes.get(), 5 + 8); + #[cfg(feature = "prometheus-client-rust-242")] + assert_eq!(frame_size.count(), 2); + #[cfg(feature = "prometheus-client-rust-242")] + assert_eq!(frame_size.sum(), 5 + 8); } Ok(())