Skip to content

Commit

Permalink
sentry: set sentry event id
Browse files Browse the repository at this point in the history
  • Loading branch information
zzacharo committed Oct 14, 2023
1 parent 8cf126b commit 61a2fb9
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions invenio_logging/sentry.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,13 @@

import logging

import sentry_sdk
from flask import g
from sentry_sdk import configure_scope
from sentry_sdk.integrations.celery import CeleryIntegration
from sentry_sdk.integrations.flask import FlaskIntegration
from sentry_sdk.integrations.redis import RedisIntegration
from sentry_sdk.integrations.sqlalchemy import SqlalchemyIntegration

from . import config
from .ext import InvenioLoggingBase
Expand Down Expand Up @@ -66,13 +72,6 @@ def install_handler(self, app):

def install_sentry_sdk_handler(self, app, logging_exclusions, level):
"""Install sentry-python sdk log handler."""
import sentry_sdk
from sentry_sdk import configure_scope
from sentry_sdk.integrations.celery import CeleryIntegration
from sentry_sdk.integrations.flask import FlaskIntegration
from sentry_sdk.integrations.redis import RedisIntegration
from sentry_sdk.integrations.sqlalchemy import SqlalchemyIntegration

integrations = [FlaskIntegration()]
init_kwargs = {}
if app.config["LOGGING_SENTRY_CELERY"]:
Expand Down Expand Up @@ -100,4 +99,7 @@ def add_request_id_sentry_python(self, event, hint):
tags = event.get("tags") or []
tags.append(["request_id", g.request_id])
event["tags"] = tags
event_id = sentry_sdk.last_event_id()
if event_id is not None:
g.sentry_event_id = event_id
return event

0 comments on commit 61a2fb9

Please sign in to comment.