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.

55 lines
1.8 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. "success" events.
  7. ## Alerting Logic
  8. SITE_NAME applies an additional alerting rule for jobs that use the `/start` signal.
  9. If a job sends a "start" signal, but then does not send a "success"
  10. signal within its configured grace time, SITE_NAME will assume the job
  11. has failed. It will mark the job as "down" and send out alerts.
  12. ## Usage Example
  13. Below is a code example in Python:
  14. ```python
  15. import requests
  16. URL = "PING_URL"
  17. # "/start" kicks off a timer: if the job takes longer than
  18. # the configured grace time, the check will be marked as "down"
  19. try:
  20. requests.get(URL + "/start", timeout=5)
  21. except requests.exceptions.RequestException:
  22. # If the network request fails for any reason, we don't want
  23. # it to prevent the main job from running
  24. pass
  25. # TODO: run the job here
  26. fib = lambda n: n if n < 2 else fib(n - 1) + fib(n - 2)
  27. print("F(42) = %d" % fib(42))
  28. # Signal success:
  29. requests.get(URL)
  30. ```
  31. ## Viewing Measured Run Times
  32. When SITE_NAME receives a "start" signal followed by a regular ping or a "fail"
  33. signal, and the two events are less than 24 hours apart,
  34. you will see the time delta displayed in the list of checks. If the two events are
  35. more than 24 hours apart, they are assumed to be unrelated, and the time delta is
  36. not displayed.
  37. ![List of checks with durations](IMG_URL/checks_durations.png)
  38. You can also see durations of the previous runs when viewing an individual check:
  39. ![Log of received pings with durations](IMG_URL/details_durations.png)