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-sdk import issue #15992

Closed
kuhball opened this issue May 7, 2024 · 3 comments · Fixed by #15998
Closed

sentry-sdk import issue #15992

kuhball opened this issue May 7, 2024 · 3 comments · Fixed by #15998
Assignees
Labels
severity: medium Results in substantial degraded or broken functionality for specfic workflows status: accepted This issue has been accepted for implementation type: bug A confirmed report of unexpected behavior in the application

Comments

@kuhball
Copy link

kuhball commented May 7, 2024

Deployment Type

Self-hosted

NetBox Version

v4.0.0

Python Version

3.12

Steps to Reproduce

  1. Create new netbox-docker instance
  2. Enable sentry via the following lines:
SENTRY_ENABLED = False
SENTRY_DSN =""
  1. Start netbox

Expected Behavior

Netbox should start with enabled sentry.

@tobiasge already looked into this within netbox slack. This is not an issue within netbox-docker, but rather an issue created via a redesign within sentry.

Observed Behavior

Traceroute:

netbox-1               | Traceback (most recent call last):
netbox-1               |   File "/opt/netbox/netbox/./manage.py", line 10, in <module>
netbox-1               |     execute_from_command_line(sys.argv)
netbox-1               |   File "/opt/netbox/venv/lib/python3.11/site-packages/django/core/management/__init__.py", line 442, in execute_from_command_line
netbox-1               |     utility.execute()
netbox-1               |   File "/opt/netbox/venv/lib/python3.11/site-packages/django/core/management/__init__.py", line 382, in execute
netbox-1               |     settings.INSTALLED_APPS
netbox-1               |   File "/opt/netbox/venv/lib/python3.11/site-packages/django/conf/__init__.py", line 89, in __getattr__
netbox-1               |     self._setup(name)
netbox-1               |   File "/opt/netbox/venv/lib/python3.11/site-packages/django/conf/__init__.py", line 76, in _setup
netbox-1               |     self._wrapped = Settings(settings_module)
netbox-1               |                     ^^^^^^^^^^^^^^^^^^^^^^^^^
netbox-1               |   File "/opt/netbox/venv/lib/python3.11/site-packages/django/conf/__init__.py", line 190, in __init__
netbox-1               |     mod = importlib.import_module(self.SETTINGS_MODULE)
netbox-1               |           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
netbox-1               |   File "/usr/lib/python3.11/importlib/__init__.py", line 126, in import_module
netbox-1               |     return _bootstrap._gcd_import(name[level:], package, level)
netbox-1               |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
netbox-1               |   File "<frozen importlib._bootstrap>", line 1204, in _gcd_import
netbox-1               |   File "<frozen importlib._bootstrap>", line 1176, in _find_and_load
netbox-1               |   File "<frozen importlib._bootstrap>", line 1147, in _find_and_load_unlocked
netbox-1               |   File "<frozen importlib._bootstrap>", line 690, in _load_unlocked
netbox-1               |   File "<frozen importlib._bootstrap_external>", line 940, in exec_module
netbox-1               |   File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
netbox-1               |   File "/opt/netbox/netbox/netbox/settings.py", line 525, in <module>
netbox-1               |     integrations=[sentry_sdk.integrations.django.DjangoIntegration()],
netbox-1               |                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
netbox-1               | AttributeError: module 'sentry_sdk.integrations' has no attribute 'django'
@kuhball kuhball added status: needs triage This issue is awaiting triage by a maintainer type: bug A confirmed report of unexpected behavior in the application labels May 7, 2024
@tobiasge
Copy link
Member

tobiasge commented May 7, 2024

Form our Slack conversation:
Could be fixed with this

diff --git a/netbox/netbox/settings.py b/netbox/netbox/settings.py
index 53eaffed5..355ff9f58 100644
--- a/netbox/netbox/settings.py
+++ b/netbox/netbox/settings.py
@@ -514,6 +514,7 @@ MAINTENANCE_EXEMPT_PATHS = (
 if SENTRY_ENABLED:
     try:
         import sentry_sdk
+        from sentry_sdk.integrations.django import DjangoIntegration
     except ModuleNotFoundError:
         raise ImproperlyConfigured("SENTRY_ENABLED is True but the sentry-sdk package is not installed.")
     if not SENTRY_DSN:
@@ -522,7 +523,7 @@ if SENTRY_ENABLED:
     sentry_sdk.init(
         dsn=SENTRY_DSN,
         release=VERSION,
-        integrations=[sentry_sdk.integrations.django.DjangoIntegration()],
+        integrations=[DjangoIntegration()],
         sample_rate=SENTRY_SAMPLE_RATE,
         traces_sample_rate=SENTRY_TRACES_SAMPLE_RATE,
         send_default_pii=True,

or by removing the integrations= completely.

@jeremystretch jeremystretch removed their assignment May 7, 2024
@jeremystretch jeremystretch added status: needs owner This issue is tentatively accepted pending a volunteer committed to its implementation severity: medium Results in substantial degraded or broken functionality for specfic workflows and removed status: needs triage This issue is awaiting triage by a maintainer labels May 7, 2024
@jeremystretch
Copy link
Member

jeremystretch commented May 7, 2024

Thanks for digging into this. I wasn't able to immediately track down the responsible change, but it's likely from the recent v2.0 release a couple weeks ago.

tobiasge added a commit to tobiasge/netbox that referenced this issue May 7, 2024
According to the Sentry Python SDK documentation setting the
integrations manually is only neede when the integration configuration
needs to be changed.

See: https://docs.sentry.io/platforms/python/integrations/django/#options
tobiasge added a commit to tobiasge/netbox that referenced this issue May 7, 2024
According to the Sentry Python SDK documentation setting the
integrations manually is only needed when the integration configuration
needs to be changed.

See: https://docs.sentry.io/platforms/python/integrations/django/#options
@tobiasge
Copy link
Member

tobiasge commented May 7, 2024

I created the PR #15998 to fix this.

@jeremystretch jeremystretch added status: accepted This issue has been accepted for implementation and removed status: needs owner This issue is tentatively accepted pending a volunteer committed to its implementation labels May 7, 2024
jeremystretch pushed a commit that referenced this issue May 7, 2024
According to the Sentry Python SDK documentation setting the
integrations manually is only needed when the integration configuration
needs to be changed.

See: https://docs.sentry.io/platforms/python/integrations/django/#options
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 6, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
severity: medium Results in substantial degraded or broken functionality for specfic workflows status: accepted This issue has been accepted for implementation type: bug A confirmed report of unexpected behavior in the application
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants