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

sentry: set sentry event id #71

Merged
merged 2 commits into from
Oct 14, 2023
Merged
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
4 changes: 4 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion invenio_logging/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,6 @@

from __future__ import absolute_import, print_function

__version__ = "2.0.0"
__version__ = "2.0.1"

__all__ = ("__version__",)
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
Loading