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
f5d2741c
Unverified
Commit
f5d2741c
authored
Dec 04, 2017
by
Tyler Hallada
Committed by
GitHub
Dec 04, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #16744 from edx/thallada/highlights-logging
Schedules: more info logging and add exception logging
parents
de74279d
3425502a
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
34 additions
and
12 deletions
+34
-12
openedx/core/djangoapps/schedules/resolvers.py
+7
-3
openedx/core/djangoapps/schedules/tasks.py
+14
-4
openedx/core/djangoapps/schedules/tests/test_tasks.py
+4
-5
openedx/core/djangoapps/schedules/utils.py
+9
-0
No files found.
openedx/core/djangoapps/schedules/resolvers.py
View file @
f5d2741c
...
@@ -136,13 +136,13 @@ class BinnedSchedulesBaseResolver(PrefixedDebugLoggerMixin, RecipientResolver):
...
@@ -136,13 +136,13 @@ class BinnedSchedulesBaseResolver(PrefixedDebugLoggerMixin, RecipientResolver):
if
"read_replica"
in
settings
.
DATABASES
:
if
"read_replica"
in
settings
.
DATABASES
:
schedules
=
schedules
.
using
(
"read_replica"
)
schedules
=
schedules
.
using
(
"read_replica"
)
LOG
.
debug
(
'Query =
%
r'
,
schedules
.
query
.
sql_with_params
())
LOG
.
info
(
'Query =
%
r'
,
schedules
.
query
.
sql_with_params
())
with
function_trace
(
'schedule_query_set_evaluation'
):
with
function_trace
(
'schedule_query_set_evaluation'
):
# This will run the query and cache all of the results in memory.
# This will run the query and cache all of the results in memory.
num_schedules
=
len
(
schedules
)
num_schedules
=
len
(
schedules
)
LOG
.
debug
(
'Number of schedules =
%
d'
,
num_schedules
)
LOG
.
info
(
'Number of schedules =
%
d'
,
num_schedules
)
# This should give us a sense of the volume of data being processed by each task.
# This should give us a sense of the volume of data being processed by each task.
set_custom_metric
(
'num_schedules'
,
num_schedules
)
set_custom_metric
(
'num_schedules'
,
num_schedules
)
...
@@ -356,7 +356,11 @@ class CourseUpdateResolver(BinnedSchedulesBaseResolver):
...
@@ -356,7 +356,11 @@ class CourseUpdateResolver(BinnedSchedulesBaseResolver):
try
:
try
:
week_highlights
=
get_week_highlights
(
user
,
enrollment
.
course_id
,
week_num
)
week_highlights
=
get_week_highlights
(
user
,
enrollment
.
course_id
,
week_num
)
except
CourseUpdateDoesNotExist
:
except
CourseUpdateDoesNotExist
:
continue
LOG
.
exception
(
'Weekly highlights for user {} in week {} of course {} does not exist or is disabled'
.
format
(
user
,
week_num
,
enrollment
.
course_id
)
)
template_context
.
update
({
template_context
.
update
({
'course_name'
:
schedule
.
enrollment
.
course
.
display_name
,
'course_name'
:
schedule
.
enrollment
.
course
.
display_name
,
...
...
openedx/core/djangoapps/schedules/tasks.py
View file @
f5d2741c
...
@@ -64,18 +64,28 @@ class ScheduleMessageBaseTask(Task):
...
@@ -64,18 +64,28 @@ class ScheduleMessageBaseTask(Task):
@classmethod
@classmethod
def
log_debug
(
cls
,
message
,
*
args
,
**
kwargs
):
def
log_debug
(
cls
,
message
,
*
args
,
**
kwargs
):
"""
Wrapper around LOG.debug that prefixes the message.
"""
LOG
.
debug
(
cls
.
log_prefix
+
': '
+
message
,
*
args
,
**
kwargs
)
LOG
.
debug
(
cls
.
log_prefix
+
': '
+
message
,
*
args
,
**
kwargs
)
@classmethod
@classmethod
def
log_info
(
cls
,
message
,
*
args
,
**
kwargs
):
"""
Wrapper around LOG.info that prefixes the message.
"""
LOG
.
info
(
cls
.
log_prefix
+
': '
+
message
,
*
args
,
**
kwargs
)
@classmethod
def
enqueue
(
cls
,
site
,
current_date
,
day_offset
,
override_recipient_email
=
None
):
def
enqueue
(
cls
,
site
,
current_date
,
day_offset
,
override_recipient_email
=
None
):
current_date
=
resolvers
.
_get_datetime_beginning_of_day
(
current_date
)
current_date
=
resolvers
.
_get_datetime_beginning_of_day
(
current_date
)
if
not
cls
.
is_enqueue_enabled
(
site
):
if
not
cls
.
is_enqueue_enabled
(
site
):
cls
.
log_
debug
(
'Message queuing disabled for site
%
s'
,
site
.
domain
)
cls
.
log_
info
(
'Message queuing disabled for site
%
s'
,
site
.
domain
)
return
return
target_date
=
current_date
+
datetime
.
timedelta
(
days
=
day_offset
)
target_date
=
current_date
+
datetime
.
timedelta
(
days
=
day_offset
)
cls
.
log_
debug
(
'Target date =
%
s'
,
target_date
.
isoformat
())
cls
.
log_
info
(
'Target date =
%
s'
,
target_date
.
isoformat
())
for
bin
in
range
(
cls
.
num_bins
):
for
bin
in
range
(
cls
.
num_bins
):
task_args
=
(
task_args
=
(
site
.
id
,
site
.
id
,
...
@@ -84,7 +94,7 @@ class ScheduleMessageBaseTask(Task):
...
@@ -84,7 +94,7 @@ class ScheduleMessageBaseTask(Task):
bin
,
bin
,
override_recipient_email
,
override_recipient_email
,
)
)
cls
.
log_
debug
(
'Launching task with args =
%
r'
,
task_args
)
cls
.
log_
info
(
'Launching task with args =
%
r'
,
task_args
)
cls
.
apply_async
(
cls
.
apply_async
(
task_args
,
task_args
,
retry
=
False
,
retry
=
False
,
...
@@ -218,7 +228,7 @@ def _is_delivery_enabled(site, delivery_config_var, log_prefix):
...
@@ -218,7 +228,7 @@ def _is_delivery_enabled(site, delivery_config_var, log_prefix):
if
getattr
(
ScheduleConfig
.
current
(
site
),
delivery_config_var
,
False
):
if
getattr
(
ScheduleConfig
.
current
(
site
),
delivery_config_var
,
False
):
return
True
return
True
else
:
else
:
LOG
.
debug
(
'
%
s: Message delivery disabled for site
%
s'
,
log_prefix
,
site
.
domain
)
LOG
.
info
(
'
%
s: Message delivery disabled for site
%
s'
,
log_prefix
,
site
.
domain
)
def
_annotate_for_monitoring
(
message_type
,
site
,
bin_num
,
target_day_str
,
day_offset
):
def
_annotate_for_monitoring
(
message_type
,
site
,
bin_num
,
target_day_str
,
day_offset
):
...
...
openedx/core/djangoapps/schedules/tests/test_tasks.py
View file @
f5d2741c
...
@@ -29,7 +29,7 @@ class TestScheduleMessageBaseTask(CacheIsolationTestCase):
...
@@ -29,7 +29,7 @@ class TestScheduleMessageBaseTask(CacheIsolationTestCase):
with
patch
.
multiple
(
with
patch
.
multiple
(
self
.
basetask
,
self
.
basetask
,
is_enqueue_enabled
=
Mock
(
return_value
=
False
),
is_enqueue_enabled
=
Mock
(
return_value
=
False
),
log_
debug
=
DEFAULT
,
log_
info
=
DEFAULT
,
run
=
send
,
run
=
send
,
)
as
patches
:
)
as
patches
:
self
.
basetask
.
enqueue
(
self
.
basetask
.
enqueue
(
...
@@ -37,7 +37,7 @@ class TestScheduleMessageBaseTask(CacheIsolationTestCase):
...
@@ -37,7 +37,7 @@ class TestScheduleMessageBaseTask(CacheIsolationTestCase):
current_date
=
datetime
.
datetime
.
now
(),
current_date
=
datetime
.
datetime
.
now
(),
day_offset
=
2
day_offset
=
2
)
)
patches
[
'log_
debug
'
]
.
assert_called_once_with
(
patches
[
'log_
info
'
]
.
assert_called_once_with
(
'Message queuing disabled for site
%
s'
,
self
.
site
.
domain
)
'Message queuing disabled for site
%
s'
,
self
.
site
.
domain
)
send
.
apply_async
.
assert_not_called
()
send
.
apply_async
.
assert_not_called
()
...
@@ -48,7 +48,7 @@ class TestScheduleMessageBaseTask(CacheIsolationTestCase):
...
@@ -48,7 +48,7 @@ class TestScheduleMessageBaseTask(CacheIsolationTestCase):
with
patch
.
multiple
(
with
patch
.
multiple
(
self
.
basetask
,
self
.
basetask
,
is_enqueue_enabled
=
Mock
(
return_value
=
True
),
is_enqueue_enabled
=
Mock
(
return_value
=
True
),
log_
debug
=
DEFAULT
,
log_
info
=
DEFAULT
,
run
=
send
,
run
=
send
,
)
as
patches
:
)
as
patches
:
self
.
basetask
.
enqueue
(
self
.
basetask
.
enqueue
(
...
@@ -58,8 +58,7 @@ class TestScheduleMessageBaseTask(CacheIsolationTestCase):
...
@@ -58,8 +58,7 @@ class TestScheduleMessageBaseTask(CacheIsolationTestCase):
)
)
target_date
=
current_date
.
replace
(
hour
=
0
,
minute
=
0
,
second
=
0
,
microsecond
=
0
)
+
\
target_date
=
current_date
.
replace
(
hour
=
0
,
minute
=
0
,
second
=
0
,
microsecond
=
0
)
+
\
datetime
.
timedelta
(
day_offset
)
datetime
.
timedelta
(
day_offset
)
print
(
patches
[
'log_debug'
]
.
mock_calls
)
patches
[
'log_info'
]
.
assert_any_call
(
patches
[
'log_debug'
]
.
assert_any_call
(
'Target date =
%
s'
,
target_date
.
isoformat
())
'Target date =
%
s'
,
target_date
.
isoformat
())
assert
send
.
call_count
==
DEFAULT_NUM_BINS
assert
send
.
call_count
==
DEFAULT_NUM_BINS
...
...
openedx/core/djangoapps/schedules/utils.py
View file @
f5d2741c
...
@@ -14,4 +14,13 @@ class PrefixedDebugLoggerMixin(object):
...
@@ -14,4 +14,13 @@ class PrefixedDebugLoggerMixin(object):
self
.
log_prefix
=
self
.
__class__
.
__name__
self
.
log_prefix
=
self
.
__class__
.
__name__
def
log_debug
(
self
,
message
,
*
args
,
**
kwargs
):
def
log_debug
(
self
,
message
,
*
args
,
**
kwargs
):
"""
Wrapper around LOG.debug that prefixes the message.
"""
LOG
.
debug
(
self
.
log_prefix
+
': '
+
message
,
*
args
,
**
kwargs
)
LOG
.
debug
(
self
.
log_prefix
+
': '
+
message
,
*
args
,
**
kwargs
)
def
log_info
(
self
,
message
,
*
args
,
**
kwargs
):
"""
Wrapper around LOG.info that prefixes the message.
"""
LOG
.
info
(
self
.
log_prefix
+
': '
+
message
,
*
args
,
**
kwargs
)
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