@@ -289,32 +289,47 @@ def test_http_payload_compression(server, client_cls, method, threshold):
289289 compression_threshold = threshold ,
290290 ) as client :
291291 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" })
293304
294305 assert status == 200
295306 data = data .split (b"\n " )
296307 sent_payload = data [- 1 ]
297308 payload_byte_len = len (sent_payload )
298-
299309 internal_metrics = dict (internal_metrics .metrics ())
300310 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 ] == [
302312 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 ,
304318 ]
305319
306320 if threshold < 20 :
307321 # 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
315330 else :
316331 # Verify no ZLIB compression metrics were sent
317- assert len (internal_metrics ) == 1
332+ assert len (internal_metrics ) == 3
318333 else :
319334 assert not internal_metrics
320335
0 commit comments