mirror of
https://github.com/sartography/spiff-arena.git
synced 2025-01-12 18:44:14 +00:00
Squashed 'flask-bpmn/' changes from c8fd01df4..c7e2f98d1
c7e2f98d1 fixed sentry calls by moving the logger.exception call w/ burnettk git-subtree-dir: flask-bpmn git-subtree-split: c7e2f98d1c42e3ff90a989957a346f4f87e622b8
This commit is contained in:
parent
9b83ec1849
commit
b54299f28f
@ -14,7 +14,7 @@ from flask import g
|
||||
from flask import jsonify
|
||||
from flask import make_response
|
||||
from sentry_sdk import capture_exception
|
||||
from sentry_sdk import set_user
|
||||
from sentry_sdk import set_tag
|
||||
from SpiffWorkflow.bpmn.exceptions import WorkflowTaskExecException # type: ignore
|
||||
from SpiffWorkflow.exceptions import WorkflowException # type: ignore
|
||||
from SpiffWorkflow.specs.base import TaskSpec # type: ignore
|
||||
@ -165,13 +165,12 @@ def set_user_sentry_context() -> None:
|
||||
username = "Unknown"
|
||||
# This is for sentry logging into Slack
|
||||
sentry_sdk.set_context("User", {"user": username})
|
||||
set_user({"username": username})
|
||||
set_tag("username", username)
|
||||
|
||||
|
||||
@api_error_blueprint.app_errorhandler(Exception)
|
||||
def handle_exception(exception: Exception) -> flask.wrappers.Response:
|
||||
"""Handles unexpected exceptions."""
|
||||
current_app.logger.exception(exception)
|
||||
set_user_sentry_context()
|
||||
id = capture_exception(exception)
|
||||
|
||||
@ -183,6 +182,11 @@ def handle_exception(exception: Exception) -> flask.wrappers.Response:
|
||||
f"https://sentry.io/{organization_slug}/{project_slug}/events/{id}"
|
||||
)
|
||||
|
||||
# !!!NOTE!!!: do this after sentry stuff since calling logger.exception
|
||||
# seems to break the sentry sdk context where we no longer get back
|
||||
# an event id or send out tags like username
|
||||
current_app.logger.exception(exception)
|
||||
|
||||
# set api_exception like this to avoid confusing mypy
|
||||
# and what type the object is
|
||||
api_exception = None
|
||||
|
Loading…
x
Reference in New Issue
Block a user