Skip to content

Commit

Permalink
Remove counters functionality (which we weren't using anyway). (oppia…
Browse files Browse the repository at this point in the history
…#2513)

* Remove counters functionality (which we weren't using anyway).

* Fix backend test.
  • Loading branch information
seanlip authored Sep 27, 2016
1 parent 055fd4b commit b0f038d
Show file tree
Hide file tree
Showing 8 changed files with 5 additions and 197 deletions.
27 changes: 0 additions & 27 deletions core/controllers/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

import jinja2

from core import counters
from core import jobs
from core import jobs_registry
from core.controllers import base
Expand Down Expand Up @@ -58,32 +57,6 @@ class AdminPage(base.BaseHandler):
@require_super_admin
def get(self):
"""Handles GET requests."""
self.values['counters'] = [{
'name': counter.name,
'description': counter.description,
'value': counter.value
} for counter in counters.Registry.get_all_counters()]

if counters.HTML_RESPONSE_COUNT.value:
average_time = (
counters.HTML_RESPONSE_TIME_SECS.value /
counters.HTML_RESPONSE_COUNT.value)
self.values['counters'].append({
'name': 'average-html-response-time-secs',
'description': 'Average HTML response time in seconds',
'value': average_time
})

if counters.JSON_RESPONSE_COUNT.value:
average_time = (
counters.JSON_RESPONSE_TIME_SECS.value /
counters.JSON_RESPONSE_COUNT.value)
self.values['counters'].append({
'name': 'average-json-response-time-secs',
'description': 'Average JSON response time in seconds',
'value': average_time
})

demo_exploration_ids = feconf.DEMO_EXPLORATIONS.keys()

recent_job_data = jobs.get_data_for_recent_jobs()
Expand Down
2 changes: 0 additions & 2 deletions core/controllers/admin_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ def test_admin_page(self):
response = self.testapp.get('/admin')
self.assertEqual(response.status_int, 200)
response.mustcontain(
'Performance Counters',
'Total processing time for all JSON responses',
'Configuration',
'Reload a single exploration',
'three_balls')
Expand Down
15 changes: 0 additions & 15 deletions core/controllers/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
import webapp2
from google.appengine.api import users

from core import counters
from core.domain import config_domain
from core.domain import config_services
from core.domain import rights_manager
Expand Down Expand Up @@ -289,13 +288,6 @@ def render_json(self, values):
json_output = json.dumps(values, cls=utils.JSONEncoderForHTML)
self.response.write('%s%s' % (feconf.XSSI_PREFIX, json_output))

# Calculate the processing time of this request.
duration = datetime.datetime.utcnow() - self.start_time
processing_time = duration.seconds + duration.microseconds / 1E6

counters.JSON_RESPONSE_TIME_SECS.inc(increment=processing_time)
counters.JSON_RESPONSE_COUNT.inc()

def render_template(
self, filename, values=None, iframe_restriction='DENY',
redirect_url_on_logout=None):
Expand Down Expand Up @@ -389,13 +381,6 @@ def render_template(
self.response.write(self.jinja2_env.get_template(
filename).render(**values))

# Calculate the processing time of this request.
duration = datetime.datetime.utcnow() - self.start_time
processing_time = duration.seconds + duration.microseconds / 1E6

counters.HTML_RESPONSE_TIME_SECS.inc(increment=processing_time)
counters.HTML_RESPONSE_COUNT.inc()

def _render_exception(self, error_code, values):
assert error_code in [400, 401, 404, 500]
values['code'] = error_code
Expand Down
105 changes: 0 additions & 105 deletions core/counters.py

This file was deleted.

3 changes: 0 additions & 3 deletions core/platform/email/gae_email_services.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

"""Provides email services."""

from core import counters
import feconf

from google.appengine.api import mail
Expand Down Expand Up @@ -63,5 +62,3 @@ def send_mail(
mail.send_mail(
sender_email, recipient_email, subject, plaintext_body,
html=html_body)

counters.EMAILS_SENT.inc()
3 changes: 0 additions & 3 deletions core/platform/email/mailgun_email_services.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
"""Provides mailgun api to send email."""
import requests

from core import counters
import feconf

MAILGUN_PUBLIC_DOMAIN_URL = "https://api.mailgun.net/v3/address/validate"
Expand Down Expand Up @@ -92,5 +91,3 @@ def send_mail(
requests.post(
mailgun_domain_name, auth=('api', feconf.MAILGUN_API_KEY),
data=data)

counters.EMAILS_SENT.inc()
27 changes: 0 additions & 27 deletions core/platform/memcache/gae_memcache_services.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

"""Provides memcache services."""

from core import counters
from google.appengine.api import memcache


Expand All @@ -32,12 +31,6 @@ def get_multi(keys):
"""
assert isinstance(keys, list)
result = memcache.get_multi(keys)

if result is not None:
counters.MEMCACHE_HIT.inc()
else:
counters.MEMCACHE_MISS.inc()

return result


Expand All @@ -55,12 +48,6 @@ def set_multi(key_value_mapping):
"""
assert isinstance(key_value_mapping, dict)
unset_keys = memcache.set_multi(key_value_mapping)

if unset_keys:
counters.MEMCACHE_SET_FAILURE.inc()
else:
counters.MEMCACHE_SET_SUCCESS.inc()

return unset_keys


Expand All @@ -76,14 +63,6 @@ def delete(key):
"""
assert isinstance(key, basestring)
return_code = memcache.delete(key)

if return_code == 0:
counters.MEMCACHE_DELETE_FAILURE.inc()
elif return_code == 1:
counters.MEMCACHE_DELETE_MISSING.inc()
else:
counters.MEMCACHE_DELETE_SUCCESS.inc()

return return_code


Expand All @@ -99,10 +78,4 @@ def delete_multi(keys):
for key in keys:
assert isinstance(key, basestring)
return_value = memcache.delete_multi(keys)

if return_value is True:
counters.MEMCACHE_DELETE_SUCCESS.inc()
else:
counters.MEMCACHE_DELETE_FAILURE.inc()

return return_value
20 changes: 5 additions & 15 deletions core/templates/dev/head/pages/admin/admin.html
Original file line number Diff line number Diff line change
Expand Up @@ -337,21 +337,6 @@ <h3>Configuration properties</h3>
</div>
</md-card>

<md-card class="oppia-page-card oppia-long-text" style="max-width: 700px;" ng-if="currentTab === TAB_MISC">
<h3>Performance Counters</h3>
<ul>
{% for counter in counters %}
<li>
{{counter.description}} : {{counter.value}}
</li>
{% endfor %}
</ul>
</md-card>
<md-card class="oppia-page-card oppia-long-text" ng-if="currentTab === TAB_MISC" style="max-width: 700px">
<h3>Search Index</h3>

<button ng-click="clearSearchIndex()">Clear Search Index</button>
</md-card>
<md-card class="oppia-page-card oppia-long-text" ng-if="currentTab === TAB_MISC" style="max-width: 700px">
<h3>Topic Similarities</h3>
<div>
Expand All @@ -362,6 +347,11 @@ <h3>Topic Similarities</h3>
<button ng-click="downloadTopicSimilaritiesFile()">Download current topic similarities</button>
</div>
</md-card>

<md-card class="oppia-page-card oppia-long-text" ng-if="currentTab === TAB_MISC" style="max-width: 700px">
<h3>Search Index</h3>
<button ng-click="clearSearchIndex()">Clear Search Index</button>
</md-card>
</div>
</div>

Expand Down

0 comments on commit b0f038d

Please sign in to comment.