Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-ora2
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-ora2
Commits
9dfb1928
Commit
9dfb1928
authored
Apr 02, 2014
by
Will Daly
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #249 from edx/will/accurate-answer-size-metric
Serialize answer dict before calculating size for datadog
parents
eee39004
4d8cddc2
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
3 deletions
+10
-3
apps/submissions/api.py
+10
-3
No files found.
apps/submissions/api.py
View file @
9dfb1928
...
...
@@ -4,11 +4,10 @@ Public interface for the submissions app.
"""
import
copy
import
logging
import
json
from
django.core.cache
import
cache
from
django.conf
import
settings
from
django.db
import
IntegrityError
,
DatabaseError
from
django.utils.encoding
import
force_unicode
from
dogapi
import
dog_stats_api
from
submissions.serializers
import
(
...
...
@@ -524,9 +523,17 @@ def _log_submission(submission, student_item):
u"item_id:{item_id}"
.
format
(
item_id
=
student_item
[
'item_id'
]),
u"item_type:{item_type}"
.
format
(
item_type
=
student_item
[
'item_type'
]),
]
dog_stats_api
.
histogram
(
'submissions.submission.size'
,
len
(
submission
[
'answer'
]),
tags
=
tags
)
dog_stats_api
.
increment
(
'submissions.submission.count'
,
tags
=
tags
)
# Submission answer is a JSON serializable, so we need to serialize it to measure its size in bytes
try
:
answer_size
=
len
(
json
.
dumps
(
submission
[
'answer'
]))
except
(
ValueError
,
TypeError
):
msg
=
u"Could not serialize submission answer to calculate its length: {}"
.
format
(
submission
[
'answer'
])
logger
.
exception
(
msg
)
else
:
dog_stats_api
.
histogram
(
'submissions.submission.size'
,
answer_size
,
tags
=
tags
)
def
_log_score
(
score
):
"""
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment