@@ -856,17 +856,25 @@ def lambda_handler(event, context):
856856def test_profiling_enabled (monkeypatch ):
857857 importlib .reload (wrapper )
858858
859- original_Profiler_start = wrapper . profiler . Profiler . start
860- Profiler_start_calls = []
859+ Profiler_start_calls : list = []
860+ Profiler_stop_calls : list = []
861861
862- def Profiler_start (* args , ** kwargs ):
862+ real_Profiler_start = wrapper .profiler .Profiler .start
863+ real_Profiler_stop = wrapper .profiler .Profiler .stop
864+
865+ def Profiler_start (* args : object , ** kwargs : object ) -> None :
863866 Profiler_start_calls .append ((args , kwargs ))
864- return original_Profiler_start (* args , ** kwargs )
867+ return real_Profiler_start (* args , ** kwargs )
868+
869+ def Profiler_stop (* args : object , ** kwargs : object ) -> None :
870+ Profiler_stop_calls .append ((args , kwargs ))
871+ return real_Profiler_stop (* args , ** kwargs )
865872
866873 monkeypatch .setattr ("datadog_lambda.wrapper.is_new_sandbox" , lambda : True )
867874 monkeypatch .setattr (
868875 "datadog_lambda.wrapper.profiler.Profiler.start" , Profiler_start
869876 )
877+ monkeypatch .setattr ("datadog_lambda.wrapper.profiler.Profiler.stop" , Profiler_stop )
870878
871879 expected_response = {
872880 "statusCode" : 200 ,
@@ -882,6 +890,8 @@ def lambda_handler(event, context):
882890 assert response == expected_response
883891 assert len (Profiler_start_calls ) == 1
884892
893+ lambda_handler .prof .stop ()
894+
885895
886896@patch ("datadog_lambda.config.Config.llmobs_enabled" , True )
887897def test_llmobs_enabled (monkeypatch ):
0 commit comments