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
f15f4fde
Commit
f15f4fde
authored
Aug 30, 2013
by
Will Daly
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #831 from edx/will/statsd-bulk-email
Instrument course email for DataDog
parents
1d1fc0df
1400271b
Show 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 @
f15f4fde
...
...
@@ -15,6 +15,7 @@ from django.http import Http404
from
celery
import
task
,
current_task
from
celery.utils.log
import
get_task_logger
from
django.core.urlresolvers
import
reverse
from
statsd
import
statsd
from
bulk_email.models
import
(
CourseEmail
,
Optout
,
CourseEmailTemplate
,
...
...
@@ -181,6 +182,9 @@ def course_email(email_id, to_list, course_title, course_url, image_url, throttl
try
:
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
)
num_sent
+=
1
except
SMTPDataError
as
exc
:
...
...
@@ -191,6 +195,9 @@ def course_email(email_id, to_list, course_title, course_url, image_url, throttl
else
:
# 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
)
statsd
.
increment
(
'course_email.error'
,
tags
=
[
_statsd_tag
(
course_title
)])
num_error
+=
1
to_list
.
pop
()
...
...
@@ -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
):
"""Return the formatted result of course_email sending."""
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