Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
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-platform
Commits
1e6d83b5
Commit
1e6d83b5
authored
Aug 18, 2015
by
Calen Pennington
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #9307 from cpennington/user-state-client-metrics
User state client metrics
parents
13ef9a62
3f9027d0
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
3 deletions
+13
-3
lms/djangoapps/courseware/user_state_client.py
+13
-3
No files found.
lms/djangoapps/courseware/user_state_client.py
View file @
1e6d83b5
...
...
@@ -40,7 +40,7 @@ class DjangoXBlockUserStateClient(XBlockUserStateClient):
"""
# Use this sample rate for DataDog events.
API_DATADOG_SAMPLE_RATE
=
0.
0
1
API_DATADOG_SAMPLE_RATE
=
0.1
class
ServiceUnavailable
(
XBlockUserStateClient
.
ServiceUnavailable
):
"""
...
...
@@ -139,11 +139,14 @@ class DjangoXBlockUserStateClient(XBlockUserStateClient):
modules
=
self
.
_get_student_modules
(
username
,
block_keys
)
for
module
,
usage_key
in
modules
:
if
module
.
state
is
None
:
self
.
_ddog_increment
(
evt_time
,
'get_many.empty_state'
)
continue
state
=
json
.
loads
(
module
.
state
)
state_length
+=
len
(
module
.
state
)
self
.
_ddog_histogram
(
evt_time
,
'get_many.block_size'
,
len
(
module
.
state
))
# If the state is the empty dict, then it has been deleted, and so
# conformant UserStateClients should treat it as if it doesn't exist.
if
state
==
{}:
...
...
@@ -161,7 +164,6 @@ class DjangoXBlockUserStateClient(XBlockUserStateClient):
# The rest of this method exists only to submit DataDog events.
# Remove it once we're no longer interested in the data.
self
.
_ddog_histogram
(
evt_time
,
'get_many.blks_out'
,
block_count
)
self
.
_ddog_histogram
(
evt_time
,
'get_many.blks_size'
,
state_length
)
def
set_many
(
self
,
username
,
block_keys_to_state
,
scope
=
Scope
.
user_state
):
"""
...
...
@@ -243,13 +245,21 @@ class DjangoXBlockUserStateClient(XBlockUserStateClient):
Arguments:
username: The name of the user whose state should be deleted
block_key
(UsageKey
): The UsageKey identifying which xblock state to delete.
block_key
s (list
): The UsageKey identifying which xblock state to delete.
scope (Scope): The scope to delete data from
fields: A list of fields to delete. If None, delete all stored fields.
"""
if
scope
!=
Scope
.
user_state
:
raise
ValueError
(
"Only Scope.user_state is supported"
)
evt_time
=
time
()
if
fields
is
None
:
self
.
_ddog_increment
(
evt_time
,
'delete_many.empty_state'
)
else
:
self
.
_ddog_histogram
(
evt_time
,
'delete_many.field_count'
,
len
(
fields
))
self
.
_ddog_histogram
(
evt_time
,
'delete_many.block_count'
,
len
(
block_keys
))
student_modules
=
self
.
_get_student_modules
(
username
,
block_keys
)
for
student_module
,
_
in
student_modules
:
if
fields
is
None
:
...
...
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