Commit f3ff6cf3 by Diana Huang

Merge pull request #3144 from edx/diana/monitor-xqueue-graders

Add in metric tracking to xqueue.
parents 4c23f928 9b3d68c2
...@@ -33,6 +33,8 @@ from sys import float_info ...@@ -33,6 +33,8 @@ from sys import float_info
from collections import namedtuple from collections import namedtuple
from shapely.geometry import Point, MultiPoint from shapely.geometry import Point, MultiPoint
from dogapi import dog_stats_api
# specific library imports # specific library imports
from calc import evaluator, UndefinedVariable from calc import evaluator, UndefinedVariable
from . import correctmap from . import correctmap
...@@ -1690,6 +1692,13 @@ class CodeResponse(LoncapaResponse): ...@@ -1690,6 +1692,13 @@ class CodeResponse(LoncapaResponse):
_ = self.capa_system.i18n.ugettext _ = self.capa_system.i18n.ugettext
dog_stats_api.increment(xqueue_interface.XQUEUE_METRIC_NAME, tags=[
'action:update_score',
'correct:{}'.format(correct)
])
dog_stats_api.histogram(xqueue_interface.XQUEUE_METRIC_NAME + '.update_score.points_earned', points)
if not valid_score_msg: if not valid_score_msg:
# Translators: 'grader' refers to the edX automatic code grader. # Translators: 'grader' refers to the edX automatic code grader.
error_msg = _('Invalid grader reply. Please contact the course staff.') error_msg = _('Invalid grader reply. Please contact the course staff.')
......
...@@ -5,11 +5,14 @@ import hashlib ...@@ -5,11 +5,14 @@ import hashlib
import json import json
import logging import logging
import requests import requests
from dogapi import dog_stats_api
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
dateformat = '%Y%m%d%H%M%S' dateformat = '%Y%m%d%H%M%S'
XQUEUE_METRIC_NAME = 'edxapp.xqueue'
def make_hashkey(seed): def make_hashkey(seed):
""" """
...@@ -80,6 +83,15 @@ class XQueueInterface(object): ...@@ -80,6 +83,15 @@ class XQueueInterface(object):
Returns (error_code, msg) where error_code != 0 indicates an error Returns (error_code, msg) where error_code != 0 indicates an error
""" """
# log the send to xqueue
header_info = json.loads(header)
queue_name = header_info.get('queue_name', u'')
dog_stats_api.increment(XQUEUE_METRIC_NAME, tags=[
u'action:send_to_queue',
u'queue:{}'.format(queue_name)
])
# Attempt to send to queue # Attempt to send to queue
(error, msg) = self._send_to_queue(header, body, files_to_upload) (error, msg) = self._send_to_queue(header, body, files_to_upload)
......
...@@ -4,6 +4,8 @@ from certificates.models import CertificateStatuses as status ...@@ -4,6 +4,8 @@ from certificates.models import CertificateStatuses as status
from django.views.decorators.csrf import csrf_exempt from django.views.decorators.csrf import csrf_exempt
from django.http import HttpResponse from django.http import HttpResponse
import json import json
from dogapi import dog_stats_api
from capa.xqueue_interface import XQUEUE_METRIC_NAME
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
...@@ -72,6 +74,12 @@ def update_certificate(request): ...@@ -72,6 +74,12 @@ def update_certificate(request):
'return_code': 1, 'return_code': 1,
'content': 'invalid cert status'}), 'content': 'invalid cert status'}),
mimetype='application/json') mimetype='application/json')
dog_stats_api.increment(XQUEUE_METRIC_NAME, tags=[
u'action:update_certificate',
u'course_id:{}'.format(cert.course_id)
])
cert.save() cert.save()
return HttpResponse(json.dumps({'return_code': 0}), return HttpResponse(json.dumps({'return_code': 0}),
mimetype='application/json') mimetype='application/json')
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment