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 416ecf4
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions invenio_logging/sentry.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@

from flask import g

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

from . import config
from .ext import InvenioLoggingBase

Expand Down Expand Up @@ -66,12 +73,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 = {}
Expand Down Expand Up @@ -100,4 +101,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 416ecf4

Please sign in to comment.