You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

48 lines
1.6 KiB

  1. # Measuring Script Run Time
  2. Append `/start` to a ping URL and use it to signal when a job starts.
  3. After receiving a start signal, Healthchecks.io will show the check as "Started."
  4. It will store the "start" events and display the job execution times. SITE_NAME
  5. calculates the job execution times as the time gaps between adjacent "start" and
  6. "complete" events.
  7. Signaling a start kicks off a separate timer: the job now **must** signal a
  8. success within its configured "Grace Time," or it will get marked as "down."
  9. Below is a code example in Python:
  10. ```python
  11. import requests
  12. URL = "PING_URL"
  13. # "/start" kicks off a timer: if the job takes longer than
  14. # the configured grace time, the check will be marked as "down"
  15. try:
  16. requests.get(URL + "/start", timeout=5)
  17. except requests.exceptions.RequestException:
  18. # If the network request fails for any reason, we don't want
  19. # it to prevent the main job from running
  20. pass
  21. # TODO: run the job here
  22. fib = lambda n: n if n < 2 else fib(n - 1) + fib(n - 2)
  23. print("F(42) = %d" % fib(42))
  24. # Signal success:
  25. requests.get(URL)
  26. ```
  27. ## Viewing Measured Run Times
  28. When SITE_NAME receives a "start" signal followed by a regular ping or a "fail"
  29. signal, and the two events are less than 24 hours apart,
  30. you will see the time delta displayed in the list of checks. If the two events are
  31. more than 24 hours apart, they are assumed to be unrelated, and the time delta is
  32. not displayed.
  33. ![List of checks with durations](IMG_URL/checks_durations.png)
  34. You can also see durations of the previous runs when viewing an individual check:
  35. ![Log of received pings with durations](IMG_URL/details_durations.png)