@@ -289,32 +289,47 @@ def test_http_payload_compression(server, client_cls, method, threshold):
289
289
compression_threshold = threshold ,
290
290
) as client :
291
291
with InternalTraceContext (internal_metrics ):
292
- status , data = client .send_request (payload = payload , params = {"method" : "test" })
292
+ status , data = client .send_request (payload = payload , params = {"method" : "method1" })
293
+
294
+ # Sending one additional request to valid metric aggregation for top level data usage supportability metrics
295
+ with client_cls (
296
+ "localhost" ,
297
+ server .port ,
298
+ disable_certificate_validation = True ,
299
+ compression_method = method ,
300
+ compression_threshold = threshold ,
301
+ ) as client :
302
+ with InternalTraceContext (internal_metrics ):
303
+ status , data = client .send_request (payload = payload , params = {"method" : "method2" })
293
304
294
305
assert status == 200
295
306
data = data .split (b"\n " )
296
307
sent_payload = data [- 1 ]
297
308
payload_byte_len = len (sent_payload )
298
-
299
309
internal_metrics = dict (internal_metrics .metrics ())
300
310
if client_cls is ApplicationModeClient :
301
- assert internal_metrics ["Supportability/Python/Collector/Output/Bytes/test " ][:2 ] == [
311
+ assert internal_metrics ["Supportability/Python/Collector/method1/ Output/Bytes" ][:2 ] == [
302
312
1 ,
303
- payload_byte_len ,
313
+ len (payload ),
314
+ ]
315
+ assert internal_metrics ["Supportability/Python/Collector/Output/Bytes" ][:2 ] == [
316
+ 2 ,
317
+ len (payload )* 2 ,
304
318
]
305
319
306
320
if threshold < 20 :
307
321
# Verify compression time is recorded
308
- assert internal_metrics ["Supportability/Python/Collector/ZLIB/Compress/test" ][0 ] == 1
309
- assert internal_metrics ["Supportability/Python/Collector/ZLIB/Compress/test" ][1 ] > 0
310
-
311
- # Verify the original payload length is recorded
312
- assert internal_metrics ["Supportability/Python/Collector/ZLIB/Bytes/test" ][:2 ] == [1 , len (payload )]
313
-
314
- assert len (internal_metrics ) == 3
322
+ assert internal_metrics ["Supportability/Python/Collector/method1/ZLIB/Compress" ][0 ] == 1
323
+ assert internal_metrics ["Supportability/Python/Collector/method1/ZLIB/Compress" ][1 ] > 0
324
+
325
+ # Verify the compressed payload length is recorded
326
+ assert internal_metrics ["Supportability/Python/Collector/method1/ZLIB/Bytes" ][:2 ] == [1 , payload_byte_len ]
327
+ assert internal_metrics ["Supportability/Python/Collector/ZLIB/Bytes" ][:2 ] == [2 , payload_byte_len * 2 ]
328
+
329
+ assert len (internal_metrics ) == 8
315
330
else :
316
331
# Verify no ZLIB compression metrics were sent
317
- assert len (internal_metrics ) == 1
332
+ assert len (internal_metrics ) == 3
318
333
else :
319
334
assert not internal_metrics
320
335
0 commit comments