diff --git a/CHANGES.rst b/CHANGES.rst index 5c105b3..ca173fd 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -8,6 +8,10 @@ Changes ======= +Version 2.0.1 (released 2023-10-14) + +- set sentry_event_id + Version 2.0.0 (released 2023-10-12) - removes support for raven diff --git a/invenio_logging/__init__.py b/invenio_logging/__init__.py index 6813b40..09409cb 100644 --- a/invenio_logging/__init__.py +++ b/invenio_logging/__init__.py @@ -87,6 +87,6 @@ from __future__ import absolute_import, print_function -__version__ = "2.0.0" +__version__ = "2.0.1" __all__ = ("__version__",) diff --git a/invenio_logging/sentry.py b/invenio_logging/sentry.py index 0c6f372..053752d 100644 --- a/invenio_logging/sentry.py +++ b/invenio_logging/sentry.py @@ -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 @@ -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"]: @@ -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