Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(670)

Side by Side Diff: remoting/webapp/crd/js/log_to_server.js

Issue 953223002: Include time elapsed since start of a remoting session in each log entry. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Calculate elapsed time for the signal strategy progress event as well. Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 /** 5 /**
6 * @fileoverview 6 * @fileoverview
7 * Module for sending log entries to the server. 7 * Module for sending log entries to the server.
8 */ 8 */
9 9
10 'use strict'; 10 'use strict';
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 */ 59 */
60 remoting.LogToServer.prototype.logClientSessionStateChange = 60 remoting.LogToServer.prototype.logClientSessionStateChange =
61 function(state, connectionError) { 61 function(state, connectionError) {
62 this.maybeExpireSessionId_(); 62 this.maybeExpireSessionId_();
63 // Set the session start time if we haven't done so already. 63 // Set the session start time if we haven't done so already.
64 if (remoting.LogToServer.isStartOfSession_(state)) { 64 if (remoting.LogToServer.isStartOfSession_(state)) {
65 if (this.sessionStartTime_ == 0) { 65 if (this.sessionStartTime_ == 0) {
66 this.sessionStartTime_ = new Date().getTime(); 66 this.sessionStartTime_ = new Date().getTime();
67 } 67 }
68 } 68 }
69 var elapsedTimeInMs = new Date().getTime() - this.sessionStartTime_;
70
69 // Log the session state change. 71 // Log the session state change.
70 var entry = remoting.ServerLogEntry.makeClientSessionStateChange( 72 var entry = remoting.ServerLogEntry.makeClientSessionStateChange(
71 state, connectionError, this.mode_); 73 state, connectionError, this.mode_);
72 entry.addHostFields(); 74 entry.addHostFields();
73 entry.addChromeVersionField(); 75 entry.addChromeVersionField();
74 entry.addWebappVersionField(); 76 entry.addWebappVersionField();
75 entry.addSessionIdField(this.sessionId_); 77 entry.addSessionIdField(this.sessionId_);
76 // Maybe clear the session start time, and log the session duration. 78 // Maybe clear the session start time, and log the session duration.
77 if (remoting.LogToServer.shouldAddDuration_(state) && 79 if (remoting.LogToServer.shouldAddDuration_(state) &&
78 (this.sessionStartTime_ != 0)) { 80 (this.sessionStartTime_ != 0)) {
79 entry.addSessionDurationField( 81 entry.addSessionDurationField(
80 (new Date().getTime() - this.sessionStartTime_) / 1000.0); 82 (new Date().getTime() - this.sessionStartTime_) / 1000.0);
81 if (remoting.LogToServer.isEndOfSession_(state)) { 83 if (remoting.LogToServer.isEndOfSession_(state)) {
82 this.sessionStartTime_ = 0; 84 this.sessionStartTime_ = 0;
83 } 85 }
84 } 86 }
87
88 // Log the time taken to get to this state from the time this session started.
89 entry.addElapsedTimeMs(elapsedTimeInMs);
Jamie 2015/02/27 02:24:46 This is still only being added for session state c
anandc 2015/02/27 21:49:29 Done. LogToServer is reset at the start of each s
85 this.log_(entry); 90 this.log_(entry);
86 // Don't accumulate connection statistics across state changes. 91 // Don't accumulate connection statistics across state changes.
87 this.logAccumulatedStatistics_(); 92 this.logAccumulatedStatistics_();
88 this.statsAccumulator_.empty(); 93 this.statsAccumulator_.empty();
89 // Maybe clear the session ID. 94 // Maybe clear the session ID.
90 if (remoting.LogToServer.isEndOfSession_(state)) { 95 if (remoting.LogToServer.isEndOfSession_(state)) {
91 this.clearSessionId_(); 96 this.clearSessionId_();
92 } 97 }
93 }; 98 };
94 99
95 /** 100 /**
96 * Set the connection type (direct, stun relay). 101 * Set the connection type (direct, stun relay).
97 * 102 *
98 * @param {string} connectionType 103 * @param {string} connectionType
99 */ 104 */
100 remoting.LogToServer.prototype.setConnectionType = function(connectionType) { 105 remoting.LogToServer.prototype.setConnectionType = function(connectionType) {
101 this.connectionType_ = connectionType; 106 this.connectionType_ = connectionType;
102 }; 107 };
103 108
104 /** 109 /**
105 * @param {remoting.SignalStrategy.Type} strategyType 110 * @param {remoting.SignalStrategy.Type} strategyType
106 * @param {remoting.FallbackSignalStrategy.Progress} progress 111 * @param {remoting.FallbackSignalStrategy.Progress} progress
107 * @param {number} elapsedTimeInMs
108 */ 112 */
109 remoting.LogToServer.prototype.logSignalStrategyProgress = 113 remoting.LogToServer.prototype.logSignalStrategyProgress =
110 function(strategyType, progress, elapsedTimeInMs) { 114 function(strategyType, progress) {
111 this.maybeExpireSessionId_(); 115 this.maybeExpireSessionId_();
112 var entry = remoting.ServerLogEntry.makeSignalStrategyProgress( 116 var entry = remoting.ServerLogEntry.makeSignalStrategyProgress(
113 this.sessionId_, strategyType, progress, elapsedTimeInMs); 117 this.sessionId_, strategyType, progress);
114 this.log_(entry); 118 this.log_(entry);
115 }; 119 };
116 120
117 /** 121 /**
118 * Whether a session state is one of the states that occurs at the start of 122 * Whether a session state is one of the states that occurs at the start of
119 * a session. 123 * a session.
120 * 124 *
121 * @private 125 * @private
122 * @param {remoting.ClientSession.State} state 126 * @param {remoting.ClientSession.State} state
123 * @return {boolean} 127 * @return {boolean}
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
270 remoting.LogToServer.generateSessionId_ = function() { 274 remoting.LogToServer.generateSessionId_ = function() {
271 var idArray = []; 275 var idArray = [];
272 for (var i = 0; i < remoting.LogToServer.SESSION_ID_LEN_; i++) { 276 for (var i = 0; i < remoting.LogToServer.SESSION_ID_LEN_; i++) {
273 var index = 277 var index =
274 Math.random() * remoting.LogToServer.SESSION_ID_ALPHABET_.length; 278 Math.random() * remoting.LogToServer.SESSION_ID_ALPHABET_.length;
275 idArray.push( 279 idArray.push(
276 remoting.LogToServer.SESSION_ID_ALPHABET_.slice(index, index + 1)); 280 remoting.LogToServer.SESSION_ID_ALPHABET_.slice(index, index + 1));
277 } 281 }
278 return idArray.join(''); 282 return idArray.join('');
279 }; 283 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698