@@ -153,13 +153,21 @@ async fn body_data_layer_records_frames() -> Result<(), Error> {
153
153
tracing:: info!( "acquiring response body metrics" ) ;
154
154
let labels = labels:: RouteBackend ( parent_ref. clone ( ) , route_ref. clone ( ) , backend_ref. clone ( ) ) ;
155
155
let BodyDataMetrics {
156
- frames_total,
157
- frames_bytes,
156
+ // TODO(kate): currently, histograms do not expose their observation count or sum. so,
157
+ // we're left unable to exercise these metrics until prometheus/client_rust#242 lands.
158
+ // - https://github.com/prometheus/client_rust/pull/241
159
+ // - https://github.com/prometheus/client_rust/pull/242
160
+ #[ cfg( feature = "prometheus-client-rust-242" ) ]
161
+ frame_size,
162
+ ..
158
163
} = metrics. get_response_body_metrics ( & labels) ;
159
164
160
165
// Before we've sent a response, the counter should be zero.
161
- assert_eq ! ( frames_total. get( ) , 0 ) ;
162
- assert_eq ! ( frames_bytes. get( ) , 0 ) ;
166
+ #[ cfg( feature = "prometheus-client-rust-242" ) ]
167
+ {
168
+ assert_eq ! ( frame_size. count( ) , 0 ) ;
169
+ assert_eq ! ( frame_size. sum( ) , 0 ) ;
170
+ }
163
171
164
172
// Create a response whose body is backed by a channel that we can send chunks to, send it.
165
173
tracing:: info!( "sending response" ) ;
@@ -175,8 +183,11 @@ async fn body_data_layer_records_frames() -> Result<(), Error> {
175
183
} ;
176
184
177
185
// Before we've sent any bytes, the counter should be zero.
178
- assert_eq ! ( frames_total. get( ) , 0 ) ;
179
- assert_eq ! ( frames_bytes. get( ) , 0 ) ;
186
+ #[ cfg( feature = "prometheus-client-rust-242" ) ]
187
+ {
188
+ assert_eq ! ( frame_size. count( ) , 0 ) ;
189
+ assert_eq ! ( frame_size. sum( ) , 0 ) ;
190
+ }
180
191
181
192
// On the client end, poll our call future and await the response.
182
193
tracing:: info!( "polling service future" ) ;
@@ -203,8 +214,10 @@ async fn body_data_layer_records_frames() -> Result<(), Error> {
203
214
resp_tx. send_data ( "hello" . into ( ) ) . await ?;
204
215
let chunk = read_chunk ( & mut body) . await ?;
205
216
debug_assert_eq ! ( "hello" . as_bytes( ) , chunk, "should get same value back out" ) ;
206
- assert_eq ! ( frames_total. get( ) , 1 ) ;
207
- assert_eq ! ( frames_bytes. get( ) , 5 ) ;
217
+ #[ cfg( feature = "prometheus-client-rust-242" ) ]
218
+ assert_eq ! ( frame_size. count( ) , 1 ) ;
219
+ #[ cfg( feature = "prometheus-client-rust-242" ) ]
220
+ assert_eq ! ( frame_size. sum( ) , 5 ) ;
208
221
}
209
222
210
223
{
@@ -217,8 +230,10 @@ async fn body_data_layer_records_frames() -> Result<(), Error> {
217
230
chunk,
218
231
"should get same value back out"
219
232
) ;
220
- assert_eq ! ( frames_total. get( ) , 2 ) ;
221
- assert_eq ! ( frames_bytes. get( ) , 5 + 8 ) ;
233
+ #[ cfg( feature = "prometheus-client-rust-242" ) ]
234
+ assert_eq ! ( frame_size. count( ) , 2 ) ;
235
+ #[ cfg( feature = "prometheus-client-rust-242" ) ]
236
+ assert_eq ! ( frame_size. sum( ) , 5 + 8 ) ;
222
237
}
223
238
224
239
{
@@ -231,8 +246,10 @@ async fn body_data_layer_records_frames() -> Result<(), Error> {
231
246
Poll :: Ready ( None ) => { }
232
247
_ => panic ! ( "got unexpected poll result" ) ,
233
248
} ;
234
- assert_eq ! ( frames_total. get( ) , 2 ) ;
235
- assert_eq ! ( frames_bytes. get( ) , 5 + 8 ) ;
249
+ #[ cfg( feature = "prometheus-client-rust-242" ) ]
250
+ assert_eq ! ( frame_size. count( ) , 2 ) ;
251
+ #[ cfg( feature = "prometheus-client-rust-242" ) ]
252
+ assert_eq ! ( frame_size. sum( ) , 5 + 8 ) ;
236
253
}
237
254
238
255
Ok ( ( ) )
0 commit comments