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
1400271b
Commit
1400271b
authored
Aug 29, 2013
by
Will Daly
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Instrumented course email for DataDog
parent
fc5a24df
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
0 deletions
+15
-0
lms/djangoapps/bulk_email/tasks.py
+15
-0
No files found.
lms/djangoapps/bulk_email/tasks.py
View file @
1400271b
...
@@ -15,6 +15,7 @@ from django.http import Http404
...
@@ -15,6 +15,7 @@ from django.http import Http404
from
celery
import
task
,
current_task
from
celery
import
task
,
current_task
from
celery.utils.log
import
get_task_logger
from
celery.utils.log
import
get_task_logger
from
django.core.urlresolvers
import
reverse
from
django.core.urlresolvers
import
reverse
from
statsd
import
statsd
from
bulk_email.models
import
(
from
bulk_email.models
import
(
CourseEmail
,
Optout
,
CourseEmailTemplate
,
CourseEmail
,
Optout
,
CourseEmailTemplate
,
...
@@ -181,6 +182,9 @@ def course_email(email_id, to_list, course_title, course_url, image_url, throttl
...
@@ -181,6 +182,9 @@ def course_email(email_id, to_list, course_title, course_url, image_url, throttl
try
:
try
:
connection
.
send_messages
([
email_msg
])
connection
.
send_messages
([
email_msg
])
statsd
.
increment
(
'course_email.sent'
,
tags
=
[
_statsd_tag
(
course_title
)])
log
.
info
(
'Email with id
%
s sent to
%
s'
,
email_id
,
email
)
log
.
info
(
'Email with id
%
s sent to
%
s'
,
email_id
,
email
)
num_sent
+=
1
num_sent
+=
1
except
SMTPDataError
as
exc
:
except
SMTPDataError
as
exc
:
...
@@ -191,6 +195,9 @@ def course_email(email_id, to_list, course_title, course_url, image_url, throttl
...
@@ -191,6 +195,9 @@ def course_email(email_id, to_list, course_title, course_url, image_url, throttl
else
:
else
:
# This will fall through and not retry the message, since it will be popped
# This will fall through and not retry the message, since it will be popped
log
.
warning
(
'Email with id
%
s not delivered to
%
s due to error
%
s'
,
email_id
,
email
,
exc
.
smtp_error
)
log
.
warning
(
'Email with id
%
s not delivered to
%
s due to error
%
s'
,
email_id
,
email
,
exc
.
smtp_error
)
statsd
.
increment
(
'course_email.error'
,
tags
=
[
_statsd_tag
(
course_title
)])
num_error
+=
1
num_error
+=
1
to_list
.
pop
()
to_list
.
pop
()
...
@@ -226,3 +233,11 @@ def course_email(email_id, to_list, course_title, course_url, image_url, throttl
...
@@ -226,3 +233,11 @@ def course_email(email_id, to_list, course_title, course_url, image_url, throttl
def
course_email_result
(
num_sent
,
num_error
,
num_optout
):
def
course_email_result
(
num_sent
,
num_error
,
num_optout
):
"""Return the formatted result of course_email sending."""
"""Return the formatted result of course_email sending."""
return
"Sent {0}, Fail {1}, Optout {2}"
.
format
(
num_sent
,
num_error
,
num_optout
)
return
"Sent {0}, Fail {1}, Optout {2}"
.
format
(
num_sent
,
num_error
,
num_optout
)
def
_statsd_tag
(
course_title
):
"""
Calculate the tag we will use for DataDog.
"""
tag
=
"course_email:{0}"
.
format
(
course_title
)
return
tag
[:
200
]
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