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
dd7bae43
Commit
dd7bae43
authored
Apr 03, 2014
by
Julia Hansbrough
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3164 from edx/flowerhack/better-xmodule-metrics
XModule datadog metrics
parents
dfed60fa
aa41635f
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
52 additions
and
2 deletions
+52
-2
common/lib/xmodule/xmodule/tests/test_crowdsource_hinter.py
+2
-0
common/lib/xmodule/xmodule/x_module.py
+50
-2
No files found.
common/lib/xmodule/xmodule/tests/test_crowdsource_hinter.py
View file @
dd7bae43
...
...
@@ -11,6 +11,7 @@ from xmodule.vertical_module import VerticalModule, VerticalDescriptor
from
xblock.field_data
import
DictFieldData
from
xblock.fragment
import
Fragment
from
xblock.core
import
XBlock
from
xblock.fields
import
ScopeIds
from
.
import
get_test_system
...
...
@@ -216,6 +217,7 @@ class FakeChild(XBlock):
self
.
student_view
=
Mock
(
return_value
=
Fragment
(
self
.
get_html
()))
self
.
save
=
Mock
()
self
.
id
=
'i4x://this/is/a/fake/id'
self
.
scope_ids
=
ScopeIds
(
'fake_user_id'
,
'fake_block_type'
,
'fake_definition_id'
,
'fake_usage_id'
)
def
get_html
(
self
):
"""
...
...
common/lib/xmodule/xmodule/x_module.py
View file @
dd7bae43
...
...
@@ -27,10 +27,13 @@ from xmodule.modulestore import Location
from
xmodule.modulestore.exceptions
import
ItemNotFoundError
,
InsufficientSpecificationError
,
InvalidLocationError
from
xmodule.modulestore.locator
import
BlockUsageLocator
from
xmodule.exceptions
import
UndefinedContext
from
dogapi
import
dog_stats_api
log
=
logging
.
getLogger
(
__name__
)
XMODULE_METRIC_NAME
=
'edxapp.xmodule'
def
dummy_track
(
_event_type
,
_event
):
pass
...
...
@@ -926,7 +929,52 @@ def descriptor_global_local_resource_url(block, uri): # pylint: disable=invalid
raise
NotImplementedError
(
"Applications must monkey-patch this function before using local_resource_url for studio_view"
)
class
DescriptorSystem
(
ConfigurableFragmentWrapper
,
Runtime
):
# pylint: disable=abstract-method
class
MetricsMixin
(
object
):
"""
Mixin for adding metric logging for render and handle methods in the DescriptorSystem and ModuleSystem.
"""
def
render
(
self
,
block
,
view_name
,
context
=
None
):
try
:
status
=
"success"
return
super
(
MetricsMixin
,
self
)
.
render
(
block
,
view_name
,
context
=
context
)
except
:
status
=
"failure"
raise
finally
:
course_id
=
getattr
(
self
,
'course_id'
,
''
)
dog_stats_api
.
increment
(
XMODULE_METRIC_NAME
,
tags
=
[
u'view_name:{}'
.
format
(
view_name
),
u'action:render'
,
u'action_status:{}'
.
format
(
status
),
u'course_id:{}'
.
format
(
course_id
),
u'block_type:{}'
.
format
(
block
.
scope_ids
.
block_type
)
])
def
handle
(
self
,
block
,
handler_name
,
request
,
suffix
=
''
):
handle
=
None
try
:
status
=
"success"
return
super
(
MetricsMixin
,
self
)
.
handle
(
block
,
handler_name
,
request
,
suffix
=
suffix
)
except
:
status
=
"failure"
raise
finally
:
course_id
=
getattr
(
self
,
'course_id'
,
''
)
dog_stats_api
.
increment
(
XMODULE_METRIC_NAME
,
tags
=
[
u'handler_name:{}'
.
format
(
handler_name
),
u'action:handle'
,
u'action_status:{}'
.
format
(
status
),
u'course_id:{}'
.
format
(
course_id
),
u'block_type:{}'
.
format
(
block
.
scope_ids
.
block_type
)
])
class
DescriptorSystem
(
MetricsMixin
,
ConfigurableFragmentWrapper
,
Runtime
):
# pylint: disable=abstract-method
"""
Base class for :class:`Runtime`s to be used with :class:`XModuleDescriptor`s
"""
...
...
@@ -1086,7 +1134,7 @@ class XMLParsingSystem(DescriptorSystem):
self
.
process_xml
=
process_xml
class
ModuleSystem
(
ConfigurableFragmentWrapper
,
Runtime
):
# pylint: disable=abstract-method
class
ModuleSystem
(
MetricsMixin
,
ConfigurableFragmentWrapper
,
Runtime
):
# pylint: disable=abstract-method
"""
This is an abstraction such that x_modules can function independent
of the courseware (e.g. import into other types of courseware, LMS,
...
...
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