Browse Source

[desktop] Allow web metrics to be disabled

Erick Tryzelaar 10 years ago
parent
commit
9a5c191
2 changed files with 10 additions and 3 deletions
  1. 5 0
      desktop/core/src/desktop/conf.py
  2. 5 3
      desktop/core/src/desktop/urls.py

+ 5 - 0
desktop/core/src/desktop/conf.py

@@ -355,6 +355,11 @@ METRICS = ConfigSection(
   key='metrics',
   help=_("""Configuration options for metrics"""),
   members=dict(
+    ENABLE_WEB_METRICS=Config(
+      key='web_metrics',
+      help=_('Enable metrics url'),
+      default=True,
+      type=coerce_bool),
     LOCATION=Config(
       key='location',
       help=_('Write metrics to this location'),

+ 5 - 3
desktop/core/src/desktop/urls.py

@@ -40,6 +40,7 @@ from django.contrib import admin
 
 from desktop import appmanager
 from desktop import metrics
+from desktop.conf import METRICS
 
 # Django expects handler404 and handler500 to be defined.
 # django.conf.urls provides them. But we want to override them.
@@ -109,9 +110,10 @@ dynamic_patterns += patterns('useradmin.views',
 )
 
 # Metrics specific
-dynamic_patterns += patterns('',
-  (r'^desktop/metrics/', include('desktop.lib.metrics.urls'))
-)
+if METRICS.ENABLE_WEB_METRICS.get():
+  dynamic_patterns += patterns('',
+    (r'^desktop/metrics/', include('desktop.lib.metrics.urls'))
+  )
 
 dynamic_patterns += patterns('',
   (r'^admin/', include(admin.site.urls)),