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 82c5651d08..5883bc73e1 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 @@ -153,13 +153,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"); @@ -175,8 +183,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"); @@ -203,8 +214,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); } { @@ -217,8 +230,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); } { @@ -231,8 +246,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(())