File tree Expand file tree Collapse file tree 2 files changed +7
-6
lines changed
ddtrace/profiling/collector
tests/profiling/collector Expand file tree Collapse file tree 2 files changed +7
-6
lines changed Original file line number Diff line number Diff line change @@ -94,14 +94,15 @@ def snapshot(self) -> None:
9494 # DEV: This can happen if either _memalloc has not been started or has been stopped.
9595 LOG .debug ("Unable to collect heap events from process %d" , os .getpid (), exc_info = True )
9696
97- def snapshot_and_parse_pprof (self , output_filename : str ) -> Any :
97+ def snapshot_and_parse_pprof (self , output_filename : str , assert_samples : bool = True ) -> Any :
9898 """Export samples to profile, upload, and parse the pprof profile.
9999
100100 This is similar to test_snapshot() but exports to the profile and returns
101101 the parsed pprof profile instead of Python objects.
102102
103103 Args:
104104 output_filename: The pprof output filename prefix (without .pid.counter suffix)
105+ assert_samples: Whether to assert that the profile contains samples
105106
106107 Returns:
107108 Parsed pprof profile object (pprof_pb2.Profile)
@@ -123,4 +124,4 @@ def snapshot_and_parse_pprof(self, output_filename: str) -> Any:
123124 "pprof_utils is not available. snapshot_and_parse_pprof() is only available in test environment."
124125 )
125126
126- return pprof_utils .parse_newest_profile (output_filename )
127+ return pprof_utils .parse_newest_profile (output_filename , assert_samples = assert_samples )
Original file line number Diff line number Diff line change @@ -550,7 +550,7 @@ def test_memory_collector_python_interface_with_allocation_tracking(tmp_path):
550550 tmp_path , "test_memory_collector_python_interface_with_allocation_tracking"
551551 )
552552
553- mc = memalloc .MemoryCollector (heap_sample_size = 128 )
553+ mc = memalloc .MemoryCollector (heap_sample_size = 32 )
554554
555555 with mc :
556556 first_batch = []
@@ -623,11 +623,11 @@ def test_memory_collector_python_interface_with_allocation_tracking_no_deletion(
623623 tmp_path , "test_memory_collector_python_interface_with_allocation_tracking_no_deletion"
624624 )
625625
626- mc = memalloc .MemoryCollector (heap_sample_size = 128 )
626+ mc = memalloc .MemoryCollector (heap_sample_size = 32 )
627627
628628 with mc :
629- # Take initial snapshot to reset allocation tracking
630- mc .snapshot_and_parse_pprof (output_filename )
629+ # Take initial snapshot to reset allocation tracking (may have no samples)
630+ mc .snapshot_and_parse_pprof (output_filename , assert_samples = False )
631631
632632 first_batch = []
633633 for i in range (20 ):
You can’t perform that action at this time.
0 commit comments