Skip to content

Commit 80abbcb

Browse files
authoredMay 16, 2024
treestatus: convert logging of Treestatus API errors to info level (Bug 1897044) (#204)
The `error` and `exception` level logging calls cause Sentry to treat expected states as new issues. Lower the level to `info` to quiet down Sentry. Issues experienced by the Treestatus API will still show up in the LandoAPI logs, and at the `info` level we can still debug which code paths are taken by various requests.
1 parent be9d1e3 commit 80abbcb

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed
 

‎landoui/treestatus.py

+11-8
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ def update_treestatus(api: TreestatusAPI, update_trees_form: TreeStatusUpdateTre
141141
json=update_trees_form.to_submitted_json(),
142142
)
143143
except LandoAPIError as exc:
144-
logger.exception("Request to update trees status failed.")
144+
logger.info("Request to update trees status failed.")
145145
if not exc.detail:
146146
raise exc
147147

@@ -200,7 +200,7 @@ def new_tree_handler(api: TreestatusAPI, form: TreeStatusNewTreeForm):
200200
},
201201
)
202202
except LandoAPIError as exc:
203-
logger.exception(f"Could not create new tree {tree}.")
203+
logger.info(f"Could not create new tree {tree}.")
204204

205205
if not exc.detail:
206206
raise exc
@@ -226,14 +226,17 @@ def treestatus_tree(tree: str):
226226
if not exc.detail or not exc.status_code:
227227
raise
228228

229-
error = f"Error received from LandoAPI: {exc.detail}"
230-
logger.error(error)
231-
flash(error, "error")
229+
# Avoid displaying an error for a 404.
230+
if exc.status_code != 404:
231+
error = f"Error received from LandoAPI: {exc.detail}"
232+
logger.info(error)
233+
flash(error, "error")
234+
232235
return redirect(request.referrer, code=exc.status_code)
233236

234237
logs = logs_response.get("result")
235238
if not logs:
236-
logger.error(f"Could not retrieve logs for tree {tree}.")
239+
logger.info(f"Could not retrieve logs for tree {tree}.")
237240
flash(
238241
f"Could not retrieve status logs for {tree} from Lando, try again later.",
239242
"error",
@@ -294,7 +297,7 @@ def update_change(id: int):
294297
**action.request_args,
295298
)
296299
except LandoAPIError as exc:
297-
logger.exception(f"Stack entry {id} failed to update.")
300+
logger.info(f"Stack entry {id} failed to update.")
298301

299302
if not exc.detail:
300303
raise exc
@@ -340,7 +343,7 @@ def update_log(id: int):
340343
json=json_body,
341344
)
342345
except LandoAPIError as exc:
343-
logger.exception(f"Log entry {id} failed to update.")
346+
logger.info(f"Log entry {id} failed to update.")
344347

345348
if not exc.detail:
346349
raise exc

0 commit comments

Comments
 (0)
Failed to load comments.