def send_log_to_datadog(data, dd_api_token, ingestion_endpoint=LOG_INGESTION_ENDPOINT): try: req = requests.request( "POST", "https://{url}/v1/input".format(url=ingestion_endpoint), headers={"Content-Type": "application/json", "DD-API-KEY": dd_api_token}, json=data, ) req.raise_for_status() except requests.exceptions.HTTPError as err: print("HTTP Error:", err) except requests.exceptions.ConnectionError as err: print("Error while connecting:", err) except requests.exceptions.Timeout as err: print("Request timed out:", err) except requests.exceptions.RequestException as err: print("Error while sending logs:", err)