mirror of
				https://github.com/zulip/zulip.git
				synced 2025-11-03 21:43:21 +00:00 
			
		
		
		
	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:
		@@ -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);
 | 
			
		||||
 
 | 
			
		||||
@@ -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,
 | 
			
		||||
 
 | 
			
		||||
@@ -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'),
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user