From 90f59fb3741745826c193c1afec9aeacf5ac56d0 Mon Sep 17 00:00:00 2001 From: Victor Ng Date: Fri, 28 Dec 2012 15:10:57 -0500 Subject: [PATCH] bug 822759 - more debugging patches to diagnose problem in -dev * re-enabled the tests for test_metlog_* * added double logging for each of the generate_error events that route through metlog. one through the default metlog instance, another through the local metlog client instance * bumped to metlog-py 0.9.10 to see the full client configuration as a JSON blob * pulled out all METLOG_CONF configuration from settings_base and just set it at once. This has to be done in settings_mkt.py and settings_addons.py --- apps/zadmin/forms.py | 42 ++++++++++++++++++++++------------ mkt/zadmin/tests/test_views.py | 5 ---- requirements/prod.txt | 2 +- sites/dev/settings_addons.py | 18 +++++++++++++-- sites/dev/settings_base.py | 12 ---------- sites/dev/settings_mkt.py | 17 +++++++++++--- 6 files changed, 58 insertions(+), 38 deletions(-) diff --git a/apps/zadmin/forms.py b/apps/zadmin/forms.py index 2d69673e6e..4f43547645 100644 --- a/apps/zadmin/forms.py +++ b/apps/zadmin/forms.py @@ -294,14 +294,6 @@ class GenerateErrorForm(happyforms.Form): from metlog.config import client_from_dict_config new_metlog = client_from_dict_config(settings.METLOG_CONF) - # The next two variables are captured by the raven client as local variables - # which are passed into the sentry server. - # They are needed to verify that the active metlog - # configuration is not the actual expected metlog - # configuration. - metlog_conf = settings.METLOG_CONF - active_metlog_conf = settings.METLOG._config - if error == 'zerodivisionerror': 1 / 0 elif error == 'iorequesterror': @@ -319,17 +311,37 @@ class GenerateErrorForm(happyforms.Form): 'cef.product': 'zamboni', 'cef': True} + settings.METLOG.cef('xx\nx|xx\rx', 5, environ, config, + username='me', ext1='ok=ok', ext2='ok\\ok', + logger_info='settings.METLOG') new_metlog.cef('xx\nx|xx\rx', 5, environ, config, - username='me', ext1='ok=ok', ext2='ok\\ok') + username='me', ext1='ok=ok', ext2='ok\\ok', + logger_info='new_metlog') elif error == 'metlog_statsd': - new_metlog.incr(name=LOGGER_NAME) + new_metlog.incr(name="new_metlog:" + LOGGER_NAME) + settings.METLOG.incr(name=LOGGER_NAME) elif error == 'metlog_json': new_metlog.metlog(type="metlog_json", - fields={'foo': 'bar', 'secret': 42}) + fields={'foo': 'bar', 'secret': 42, + 'logger_type': 'new_metlog'}) + settings.METLOG.metlog(type="metlog_json", + fields={'foo': 'bar', 'secret': 42, + 'logger_type': 'settings.METLOG'}) + elif error == 'metlog_sentry': - # If this works, we have some kind of import ordering - # problem + # Try to fire off two messages to verify that we don't + # have some kind of transient issue where settings.METLOG + # doesn't work try: - 1 / 0 + 2 / 0 except: - new_metlog.raven('metlog_sentry error triggered') + new_metlog.raven('new_metlog: metlog_sentry error triggered', + metlog_conf=settings.METLOG_CONF, + active_metlog_conf=settings.METLOG._config,) + finally: + try: + 1 / 0 + except: + settings.METLOG.raven('metlog_sentry error triggered', + metlog_conf=settings.METLOG_CONF, + active_metlog_conf=settings.METLOG._config,) diff --git a/mkt/zadmin/tests/test_views.py b/mkt/zadmin/tests/test_views.py index 05f1ddb407..bfc1d401b3 100644 --- a/mkt/zadmin/tests/test_views.py +++ b/mkt/zadmin/tests/test_views.py @@ -4,7 +4,6 @@ import json from django.conf import settings from nose.tools import eq_ -from nose import SkipTest from pyquery import PyQuery as pq import amo @@ -51,7 +50,6 @@ class TestGenerateError(amo.tests.TestCase): self.metlog.sender.msgs.clear() def test_metlog_statsd(self): - raise SkipTest("this always passes in test, but not on -dev") self.url = reverse('zadmin.generate-error') self.client.post(self.url, {'error': 'metlog_statsd'}) @@ -67,7 +65,6 @@ class TestGenerateError(amo.tests.TestCase): eq_(msg['fields']['name'], 'z.zadmin') def test_metlog_json(self): - raise SkipTest("this always passes in test, but not on -dev") self.url = reverse('zadmin.generate-error') self.client.post(self.url, {'error': 'metlog_json'}) @@ -81,7 +78,6 @@ class TestGenerateError(amo.tests.TestCase): eq_(msg['fields']['secret'], 42) def test_metlog_cef(self): - raise SkipTest("this always passes in test, but not on -dev") self.url = reverse('zadmin.generate-error') self.client.post(self.url, {'error': 'metlog_cef'}) @@ -93,7 +89,6 @@ class TestGenerateError(amo.tests.TestCase): eq_(msg['logger'], 'zamboni') def test_metlog_sentry(self): - raise SkipTest("this always passes in test, but not on -dev") self.url = reverse('zadmin.generate-error') self.client.post(self.url, {'error': 'metlog_sentry'}) diff --git a/requirements/prod.txt b/requirements/prod.txt index 65f388725a..753f30aa6c 100644 --- a/requirements/prod.txt +++ b/requirements/prod.txt @@ -44,7 +44,7 @@ html5lib==0.90 httplib2==0.7.6 importlib==1.0.2 kombu==2.1.2 -metlog-py==0.9.9 +metlog-py==0.9.10 metlog-cef==0.2 metlog-raven==0.3 mimeparse==0.1.3 diff --git a/sites/dev/settings_addons.py b/sites/dev/settings_addons.py index f41e725e47..a68cb5d52f 100644 --- a/sites/dev/settings_addons.py +++ b/sites/dev/settings_addons.py @@ -80,6 +80,20 @@ AMO_LANGUAGES = AMO_LANGUAGES + ('dbg',) LANGUAGES = lazy(lazy_langs, dict)(AMO_LANGUAGES) LANGUAGE_URL_MAP = dict([(i.lower(), i) for i in AMO_LANGUAGES]) -METLOG_CONF['logger'] = 'addons-dev' -METLOG_CONF['plugins']['raven'] = ('metlog_raven.raven_plugin:config_plugin', {'dsn': private_addons.SENTRY_DSN}) +METLOG_CONF = { + 'plugins': {'cef': ('metlog_cef.cef_plugin:config_plugin', {}), + 'raven': ( + 'metlog_raven.raven_plugin:config_plugin', {'dsn': private_addons.SENTRY_DSN}), + }, + 'sender': { + 'class': 'metlog.senders.UdpSender', + 'host': splitstrip(private.METLOG_CONF_SENDER_HOST), + 'port': private.METLOG_CONF_SENDER_PORT, + }, + 'logger': 'addons-dev', +} + METLOG = client_from_dict_config(METLOG_CONF) + +USE_METLOG_FOR_CEF = True +USE_METLOG_FOR_RAVEN = False diff --git a/sites/dev/settings_base.py b/sites/dev/settings_base.py index 45778754e0..4ef986767e 100644 --- a/sites/dev/settings_base.py +++ b/sites/dev/settings_base.py @@ -188,16 +188,4 @@ XSENDFILE_HEADER = 'X-Accel-Redirect' GEOIP_NOOP = 0 -METLOG_CONF = { - 'plugins': {'cef': ('metlog_cef.cef_plugin:config_plugin', {})}, - 'sender': { - 'class': 'metlog.senders.UdpSender', - 'host': splitstrip(private.METLOG_CONF_SENDER_HOST), - 'port': private.METLOG_CONF_SENDER_PORT, - }, -} - -USE_METLOG_FOR_CEF = True -USE_METLOG_FOR_RAVEN = False - ALLOW_SELF_REVIEWS = True diff --git a/sites/dev/settings_mkt.py b/sites/dev/settings_mkt.py index 548b733a0f..c890912119 100644 --- a/sites/dev/settings_mkt.py +++ b/sites/dev/settings_mkt.py @@ -146,10 +146,21 @@ SIGNED_APPS_SERVER = private_mkt.SIGNED_APPS_SERVER SIGNED_APPS_REVIEWER_SERVER_ACTIVE = True SIGNED_APPS_REVIEWER_SERVER = private_mkt.SIGNED_APPS_REVIEWER_SERVER -METLOG_CONF['logger'] = 'addons-marketplace-dev' -METLOG_CONF['plugins']['raven'] = ( - 'metlog_raven.raven_plugin:config_plugin', {'dsn': SENTRY_DSN}) +METLOG_CONF = { + 'plugins': {'cef': ('metlog_cef.cef_plugin:config_plugin', {}), + 'raven': ( + 'metlog_raven.raven_plugin:config_plugin', {'dsn': SENTRY_DSN}), + }, + 'sender': { + 'class': 'metlog.senders.UdpSender', + 'host': splitstrip(private.METLOG_CONF_SENDER_HOST), + 'port': private.METLOG_CONF_SENDER_PORT, + }, + 'logger': 'addons-marketplace-dev', +} METLOG = client_from_dict_config(METLOG_CONF) +USE_METLOG_FOR_CEF = True +USE_METLOG_FOR_RAVEN = False WEBTRENDS_USERNAME = private_mkt.WEBTRENDS_USERNAME WEBTRENDS_PASSWORD = private_mkt.WEBTRENDS_PASSWORD