Skip to content

Commit

Permalink
Added a generic try-except block to catch any datadog logging errors …
Browse files Browse the repository at this point in the history
…while running nice subprocess
  • Loading branch information
bigbitbus committed Dec 21, 2021
1 parent 07ae835 commit 2b4d0f0
Showing 1 changed file with 17 additions and 12 deletions.
29 changes: 17 additions & 12 deletions opta/nice_subprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,24 @@


def log_to_datadog(msg: str, severity: str) -> None:
msg = ansi_scrub(msg)
if hasattr(sys, "_called_from_test") or VERSION == DEV_VERSION or not VERSION:
if os.environ.get("OPTA_DEBUG", "") == "DATADOG_LOCAL":
print("Would have logged this string to DD:\n")
print(">>>>>>>>>>>>>>>>>>>>Datadog log start")
print(msg)
print("<<<<<<<<<<<<<<<<<<<<Datadog log end")
dd_handler.setLevel(logging.CRITICAL)
try:
msg = ansi_scrub(msg)
if hasattr(sys, "_called_from_test") or VERSION == DEV_VERSION or not VERSION:
if os.environ.get("OPTA_DEBUG", "") == "DATADOG_LOCAL":
print("Would have logged this string to DD:\n")
print(">>>>>>>>>>>>>>>>>>>>Datadog log start")
print(msg)
print("<<<<<<<<<<<<<<<<<<<<Datadog log end")
dd_handler.setLevel(logging.CRITICAL)

if severity == "ERROR":
nice_logger.error(msg)
else:
nice_logger.info(msg)
if severity == "ERROR":
nice_logger.error(msg)
else:
nice_logger.info(msg)
except: # noqa: E722
# Logging error to datadog SaaS, happens,
# not the end of world, silently fail
pass


def signal_all_child_processes(sig: int = signal.SIGINT) -> None:
Expand Down

0 comments on commit 2b4d0f0

Please sign in to comment.