chore: increment statsd as warn (#23041)

This commit is contained in:
Elizabeth Thompson
2023-02-16 15:43:18 -08:00
committed by GitHub
parent 92b9c06e59
commit 434b445e31
5 changed files with 115 additions and 63 deletions

View File

@@ -45,7 +45,17 @@ def statsd_gauge(metric_prefix: Optional[str] = None) -> Callable[..., Any]:
current_app.config["STATS_LOGGER"].gauge(f"{metric_prefix_}.ok", 1)
return result
except Exception as ex:
current_app.config["STATS_LOGGER"].gauge(f"{metric_prefix_}.error", 1)
if (
hasattr(ex, "status")
and ex.status < 500 # type: ignore # pylint: disable=no-member
):
current_app.config["STATS_LOGGER"].gauge(
f"{metric_prefix_}.warning", 1
)
else:
current_app.config["STATS_LOGGER"].gauge(
f"{metric_prefix_}.error", 1
)
raise ex
return wrapped