Python
This uses only the standard library.
import urllib.request
URL = "https://staging.crony.sh/ping/f3a1c6e2-8d4b-4c7a-9e15-2b6d0c9a7f31"
def ping(suffix="", body=None):
try:
urllib.request.urlopen(URL + suffix, data=body, timeout=10)
except OSError as error:
# A failed ping must not stop the job.
print(f"Ping failed: {error}")
ping("/start")
try:
run_backup()
except Exception as error:
ping("/fail", str(error).encode()[:10000])
raise
else:
ping()Passing data makes the request a POST, so the error message is stored with the failure.