5656]
5757
5858
59- def _init_ddup (test_name : str ) -> None :
60- """Initialize ddup for profiling tests.
61-
62- Must be called before using any lock collectors.
63- """
64- assert ddup .is_available , "ddup is not available"
65- ddup .config (
66- env = "test" ,
67- service = test_name ,
68- version = "1.0" ,
69- output_filename = "/tmp/" + test_name ,
70- )
71- ddup .start ()
72-
73-
7459# Module-level globals for testing global lock profiling
7560_test_global_lock : LockTypeInst
7661
@@ -438,18 +423,10 @@ def test_assertion_error_raised_with_enable_asserts():
438423 import mock
439424 import pytest
440425
441- from ddtrace .internal .datadog .profiling import ddup
442426 from ddtrace .profiling .collector .threading import ThreadingLockCollector
427+ from tests .profiling .collector .test_utils import init_ddup
443428
444- # Initialize ddup (required before using collectors)
445- assert ddup .is_available , "ddup is not available"
446- ddup .config (
447- env = "test" ,
448- service = "test_asserts" ,
449- version = "1.0" ,
450- output_filename = "/tmp/test_asserts" ,
451- )
452- ddup .start ()
429+ init_ddup ("test_asserts" )
453430
454431 with ThreadingLockCollector (capture_pct = 100 ):
455432 lock = threading .Lock ()
@@ -472,18 +449,10 @@ def test_all_exceptions_suppressed_by_default() -> None:
472449
473450 import mock
474451
475- from ddtrace .internal .datadog .profiling import ddup
476452 from ddtrace .profiling .collector .threading import ThreadingLockCollector
453+ from tests .profiling .collector .test_utils import init_ddup
477454
478- # Initialize ddup (required before using collectors)
479- assert ddup .is_available , "ddup is not available"
480- ddup .config (
481- env = "test" ,
482- service = "test_exceptions" ,
483- version = "1.0" ,
484- output_filename = "/tmp/test_exceptions" ,
485- )
486- ddup .start ()
455+ init_ddup ("test_exceptions" )
487456
488457 with ThreadingLockCollector (capture_pct = 100 ):
489458 lock = threading .Lock ()
@@ -511,7 +480,9 @@ def test_semaphore_and_bounded_semaphore_collectors_coexist() -> None:
511480 e.g. when BoundedSemaphore's c-tor calls Semaphore c-tor.
512481 We expect that the call to Semaphore c-tor goes to the unpatched version, and NOT our patched version.
513482 """
514- _init_ddup ("test_semaphore_and_bounded_semaphore_collectors_coexist" )
483+ from tests .profiling .collector .test_utils import init_ddup
484+
485+ init_ddup ("test_semaphore_and_bounded_semaphore_collectors_coexist" )
515486
516487 # Both collectors active at the same time - this triggers the inheritance case
517488 with ThreadingSemaphoreCollector (capture_pct = 100 ), ThreadingBoundedSemaphoreCollector (capture_pct = 100 ):
0 commit comments