Setting Raven Configuration in django app to log events in sentry

769 views
Skip to first unread message

Jaimin Patel

unread,
Apr 24, 2013, 10:51:42 AM4/24/13
to gets...@googlegroups.com
Running into following error on server after setting up raven configurations in to the django app -

Traceback (most recent call last):
  File "manage.py", line 11, in <module>
    import settings
  File "/home/hsparikh/webapps/tuvalabs_demo/tuvalabs/settings.py", line 4, in <module>
    from local_settings import * 
  File "/home/hsparikh/webapps/tuvalabs_demo/tuvalabs/local_settings.py", line 247, in <module>
    from raven.contrib.django.raven_compat.models import client
  File "/home/hsparikh/.virtualenvs/tl_demo/lib/python2.7/site-packages/raven/contrib/django/raven_compat/models.py", line 11, in <module>
    from raven.contrib.django.models import *  # NOQA
  File "/home/hsparikh/.virtualenvs/tl_demo/lib/python2.7/site-packages/raven/contrib/django/models.py", line 204, in <module>
    if ('raven.contrib.django' in django_settings.INSTALLED_APPS
  File "/home/hsparikh/webapps/tuvalabs_demo/lib/python2.7/django/utils/functional.py", line 184, in inner
    self._setup()
  File "/home/hsparikh/webapps/tuvalabs_demo/lib/python2.7/django/conf/__init__.py", line 40, in _setup
    raise ImportError("Settings cannot be imported, because environment variable %s is undefined." % ENVIRONMENT_VARIABLE)
ImportError: Settings cannot be imported, because environment variable DJANGO_SETTINGS_MODULE is undefined.

I see the django_settings_module is part of env. variable. any pointer will be helpful.

Thanks.

David Cramer

unread,
Apr 24, 2013, 1:31:12 PM4/24/13
to gets...@googlegroups.com
As far as I can tell you're forcing model validation in your settings import by importing the raven client.

This is probably not behavior you want.
--
You received this message because you are subscribed to the Google Groups "sentry" group.
To unsubscribe from this group and stop receiving emails from it, send an email to getsentry+...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Jaimin Patel

unread,
Apr 24, 2013, 1:38:44 PM4/24/13
to gets...@googlegroups.com
I am following instructions from here -

where following is the configuration in my config -

installed_app - 'raven.contrib.django.raven_compat',
raven_config - 
# Set your DSN value
RAVEN_CONFIG = {
}
from raven.contrib.django.raven_compat.models import client
client.captureException()

- logging config as mentioned in the link above.

If I dont add the import client, it complains on -
exceptions.ImproperlyConfigured('Error importing middleware %s: "%s"' % (mw_module, e))
[Wed Apr 24 12:34:15 2013] [error] [client 127.0.0.1] ImproperlyConfigured: Error importing middleware raven.contrib.django.raven_compat.middleware: "cannot import name after_setup_logger"

David Cramer

unread,
Apr 24, 2013, 1:40:02 PM4/24/13
to gets...@googlegroups.com
What version of Celery are you using? It looks like we have an incompatibility there.

You definitely do not want to import the client and call captureException in your settings. That's causing recursive imports and likely isn't desired behavior. The other error is valid.

Jaimin Patel

unread,
Apr 24, 2013, 1:46:17 PM4/24/13
to gets...@googlegroups.com
In django app its - 2.2.2 version


On Wednesday, April 24, 2013 1:40:02 PM UTC-4, David Cramer wrote:
What version of Celery are you using? It looks like we have an incompatibility there.

You definitely do not want to import the client and call captureException in your settings. That's causing recursive imports and likely isn't desired behavior. The other error is valid.

On Wednesday, April 24, 2013 at 10:38 AM, Jaimin Patel wrote:

I am following instructions from here -

where following is the configuration in my config -

installed_app - 'raven.contrib.django.raven_compat',
raven_config - 
# Set your DSN value
RAVEN_CONFIG = {

Jaimin Patel

unread,
Apr 24, 2013, 1:51:56 PM4/24/13
to gets...@googlegroups.com
In sentry app version of celery is - 3.0.19
In django app we are using celery and rabbitmq, in that celery version is - 2.2.2

David Cramer

unread,
Apr 24, 2013, 1:53:18 PM4/24/13
to gets...@googlegroups.com
Your version of Celery is unsupported, but Raven shouldn't error, so I've fixed that.

You'll need to install raven==3.3.4

Jaimin Patel

unread,
Apr 24, 2013, 2:02:35 PM4/24/13
to gets...@googlegroups.com
I had raven on 3.3.3 in django app, updated to 3.3.4

So if I update the version of celery, it should be fixed? as I tried to run after raven update, it no longer fails, still throws following error -
ERROR 2013-04-24 13:00:41,968 models 13235 -1208539456 Failed to install Celery error handler
Traceback (most recent call last):
...............
    from celery.signals import after_setup_logger, task_failure
ImportError: cannot import name after_setup_logger

David Cramer

unread,
Apr 24, 2013, 2:03:15 PM4/24/13
to gets...@googlegroups.com
That's not an error, it's just a log message saying it couldn't install.

Jaimin Patel

unread,
Apr 24, 2013, 2:07:44 PM4/24/13
to gets...@googlegroups.com
Thanks for your help Cramer. Its running fine now, I am able to log events.
Reply all
Reply to author
Forward
0 new messages