Report end-to-end sending times as experienced by clients.

This should help with determining the prevalence of slow sends as
experienced by users.

(imported from commit f00797679315c928af3c87ad8fdf0112f1dfa900)
This commit is contained in:
Tim Abbott
2013-11-04 17:58:51 -05:00
parent 0bcc8db924
commit 792b283dcd
3 changed files with 22 additions and 2 deletions

View File

@@ -356,6 +356,15 @@ function send_message_ajax(request, success) {
});
}
function report_send_time(time) {
$.ajax({
dataType: 'json', // This seems to be ignored. We still get back an xhr.
url: '/json/report_send_time',
type: 'POST',
data: {"time": time}
});
}
var socket = new Socket("/sockjs");
// For debugging. The socket will eventually move out of this file anyway.
exports._socket = socket;
@@ -385,12 +394,15 @@ function send_message(request) {
var start_time = new Date();
function success() {
var send_time = (new Date() - start_time);
if (feature_flags.log_send_times) {
blueslip.log("send time: " + (new Date() - start_time));
blueslip.log("send time: " + send_time);
}
if (feature_flags.collect_send_times) {
exports.send_times_data.push((new Date() - start_time));
exports.send_times_data.push(send_time);
}
report_send_time(send_time.toString());
$("#new_message_content").val('').focus();
autosize_textarea();
$("#send-status").hide(0);

View File

@@ -2753,6 +2753,13 @@ if not (settings.DEBUG or settings.TEST_SUITE):
js_source_map = SourceMap(os.path.join(
settings.DEPLOY_ROOT, 'prod-static/source-map'))
@authenticated_json_post_view
@has_request_variables
def json_report_send_time(request, user_profile,
time=REQ(converter=to_non_negative_int)):
logging.info("End-to-end send time: %dms (%s)" % (time, user_profile.email))
return json_success()
@authenticated_json_post_view
@has_request_variables
def json_report_error(request, user_profile, message=REQ, stacktrace=REQ,

View File

@@ -125,6 +125,7 @@ urlpatterns += patterns('zerver.views',
url(r'^json/change_enter_sends$', 'json_change_enter_sends'),
url(r'^json/get_profile$', 'json_get_profile'),
url(r'^json/report_error$', 'json_report_error'),
url(r'^json/report_send_time$', 'json_report_send_time'),
url(r'^json/update_message_flags$', 'json_update_flags'),
url(r'^json/register$', 'json_events_register'),
url(r'^json/upload_file$', 'json_upload_file'),