Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/add-sentry #315

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file added openIMIS/a.out
Empty file.
2 changes: 1 addition & 1 deletion openIMIS/openIMIS/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ def SITE_URL():
}

MIDDLEWARE = [
'sentry_sdk.integrations.django.middleware.SentryMiddleware'
"django.middleware.security.SecurityMiddleware",
"whitenoise.middleware.WhiteNoiseMiddleware",
'core.middleware.GraphQLRateLimitMiddleware',
Expand Down Expand Up @@ -192,4 +193,3 @@ def SITE_URL():
# By default, the maximum upload size is 2.5Mb, which is a bit short for base64 picture upload
DATA_UPLOAD_MAX_MEMORY_SIZE = int(os.environ.get('DATA_UPLOAD_MAX_MEMORY_SIZE', 10 * 1024 * 1024))

FRONTEND_URL = os.environ.get("FRONTEND_URL", "")
14 changes: 3 additions & 11 deletions openIMIS/openIMIS/tracer.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from contextlib import contextmanager
from .settings import IS_SENTRY_ENABLED, DEBUG
import traceback
from graphql import GraphQLError

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -38,14 +39,5 @@ def resolve(self, next, root, info, **kwargs):
# Proceed with the next middleware or resolver
return next(root, info, **kwargs)
except Exception as e:
# Log the exception with its traceback
if DEBUG:
logger.error("An error occurred: %s", str(e))
logger.error("Traceback: %s", traceback.format_exc())

# Optionally add error information to the trace
span.set_tag("error", True)
span.log_kv({"exception": str(e), "traceback": traceback.format_exc()})

# Re-raise the exception to allow GraphQL to handle it
raise e
sentry_sdk.capture_exception(e)
raise GraphQLError(str(e))
Loading