cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

HTTP Monitor: how to pause/sleep between two steps

sylvain_baerisw
Newcomer

Hello,


I have a HTTP monitor use case where I would like to wait/sleep a few seconds between step 1 and 2

  • the first step does trigger a non-blocking asynchronous action taking several seconds to complete
  • so I need to wait enough before checking for the result with a 2nd API call

Is it possible to add in pre/post execution scripts kind of sleep(### seconds) or something equivalent ?

Thanks.


9 REPLIES 9

sebastian_kryst
DynaMight Leader
DynaMight Leader

You can use JS I think:

https://www.dynatrace.com/support/help/how-to-use-dynatrace/synthetic-monitoring/http-monitors/creat...

you can execute post execution script for the first step which for example will do:

setTimeout(function () {
   //you can paste some code here if you need
}, 5000);

I've never tested it, but should be fine 🙂

Sebastian


Thanks @Sebastian K., unfortunately it does not work. I tried something equivalent already (assuming we might be able to execute generic JS script) but it failed.

When I paste your content in a post-execution script, I get the following in log:

Post script execution failed due to: ReferenceError: "setTimeout" is not defined. (script#1)

Ok you're right. Here are possibilities you have:

https://www.dynatrace.com/support/help/how-to-use-dynatrace/synthetic-monitoring/http-monitors/pre-a...

I don't see anything that can be handy here.

As a really dirt workaround may be creating some page with setTimeout set that you may use as request in the middle which will takes amount of time defined in query parameter.

Sebastian


yes, me too. I reviewed this documentation already. That is why I posted on this forum. I was hoping for some hidden trick.

thanks anyway for your help.


Hi guys

Long shot but you should give it a try and use browser test where you can add wait after step and run JavaScripts.

HTH

Yos


dynatrace certificated professional - dynatrace primer partner - Matrix Soft Ware Division - Israel

unfortunately not for this specific use case as I am testing an API


Julius_Loman
DynaMight Guru
DynaMight Guru

Would a dummy API call to sleep for a given time solve your problem? For example, the postman echo service has such endpoint if you don't want to create your own.


This URL will, for example, wait 2 seconds between ending with a response:

https://postman-echo.com/delay/2

TEMPEST a.s., Slovakia, Dynatrace Master Partner

This is an interesting approach. Although I would prefer to avoid being dependent on a 3rd party API, I will definitely consider your idea.

Thanks a lot.


Agreed, but this is just an example. Sure you can deploy such API endpoint in your environment and it will be definitely the most simple one service you will have :-).


TEMPEST a.s., Slovakia, Dynatrace Master Partner