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
7c9e1172
Commit
7c9e1172
authored
Jun 08, 2017
by
Christina Roberts
Committed by
GitHub
Jun 08, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #15279 from edx/christina/add-middleware-guid
Add GUID to memory middleware logs.
parents
efae2778
be0a5f3c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
5 deletions
+10
-5
openedx/core/djangoapps/monitoring_utils/middleware.py
+10
-5
No files found.
openedx/core/djangoapps/monitoring_utils/middleware.py
View file @
7c9e1172
...
...
@@ -10,6 +10,13 @@ request handlers which do not record custom metrics.
"""
import
logging
from
uuid
import
uuid4
import
psutil
import
request_cache
from
openedx.core.djangoapps.waffle_utils
import
WaffleSwitchNamespace
log
=
logging
.
getLogger
(
__name__
)
try
:
import
newrelic.agent
...
...
@@ -17,10 +24,6 @@ except ImportError:
log
.
warning
(
"Unable to load NewRelic agent module"
)
newrelic
=
None
# pylint: disable=invalid-name
import
psutil
import
request_cache
from
openedx.core.djangoapps.waffle_utils
import
WaffleSwitchNamespace
REQUEST_CACHE_KEY
=
'monitoring_custom_metrics'
WAFFLE_NAMESPACE
=
'monitoring_utils'
...
...
@@ -83,9 +86,11 @@ class MonitoringMemoryMiddleware(object):
Middleware for monitoring memory usage.
"""
memory_data_key
=
u'memory_data'
guid_key
=
u'guid_key'
def
process_request
(
self
,
request
):
if
self
.
_is_enabled
():
self
.
_cache
[
self
.
guid_key
]
=
unicode
(
uuid4
())
log_prefix
=
self
.
_log_prefix
(
u"Before"
,
request
)
self
.
_cache
[
self
.
memory_data_key
]
=
self
.
_memory_data
(
log_prefix
)
...
...
@@ -109,7 +114,7 @@ class MonitoringMemoryMiddleware(object):
"""
Returns a formatted prefix for logging for the given request.
"""
return
u"{} request '{} {}
'"
.
format
(
prefix
,
request
.
method
,
request
.
path
)
return
u"{} request '{} {}
{}'"
.
format
(
prefix
,
request
.
method
,
request
.
path
,
self
.
_cache
[
self
.
guid_key
]
)
def
_memory_data
(
self
,
log_prefix
):
"""
...
...
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