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

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: Record elapsed time every time we log something. 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';
11 11
12 /** @suppress {duplicate} */ 12 /** @suppress {duplicate} */
13 var remoting = remoting || {}; 13 var remoting = remoting || {};
14 14
15 /** 15 /**
16 * @param {remoting.SignalStrategy} signalStrategy Signal strategy. 16 * @param {remoting.SignalStrategy} signalStrategy Signal strategy.
17 * @param {remoting.DesktopConnectedView.Mode} mode The mode of this connection. 17 * @param {remoting.DesktopConnectedView.Mode} mode The mode of this connection.
18 * @constructor 18 * @constructor
19 */ 19 */
20 remoting.LogToServer = function(signalStrategy, mode) { 20 remoting.LogToServer = function(signalStrategy, mode) {
21 /** @private */ 21 /** @private */
22 this.statsAccumulator_ = new remoting.StatsAccumulator(); 22 this.statsAccumulator_ = new remoting.StatsAccumulator();
23 /** @private */ 23 /** @private */
24 this.sessionId_ = ''; 24 this.sessionId_ = '';
25 /** @private */ 25 /** @private */
26 this.sessionIdGenerationTime_ = 0; 26 this.sessionIdGenerationTime_ = 0;
27 /** @private */ 27 /** @private */
28 this.sessionStartTime_ = 0; 28 this.sessionStartTime_ = 0;
Jamie 2015/02/28 00:35:37 You need to initialize this to the current time. A
anandc 2015/02/28 01:20:27 Done. I tested the additional time doing it here a
29 /** @private */ 29 /** @private */
30 this.signalStrategy_ = signalStrategy; 30 this.signalStrategy_ = signalStrategy;
31 /** @private */ 31 /** @private */
32 this.mode_ = mode; 32 this.mode_ = mode;
33 /** @type {string} @private */ 33 /** @type {string} @private */
34 this.connectionType_ = ''; 34 this.connectionType_ = '';
35 35
36 this.setSessionId_(); 36 this.setSessionId_();
37 signalStrategy.sendConnectionSetupResults(this); 37 signalStrategy.sendConnectionSetupResults(this);
38 }; 38 };
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 state, connectionError, this.mode_); 71 state, connectionError, this.mode_);
72 entry.addHostFields(); 72 entry.addHostFields();
73 entry.addChromeVersionField(); 73 entry.addChromeVersionField();
74 entry.addWebappVersionField(); 74 entry.addWebappVersionField();
75 entry.addSessionIdField(this.sessionId_); 75 entry.addSessionIdField(this.sessionId_);
76 // Maybe clear the session start time, and log the session duration. 76 // Maybe clear the session start time, and log the session duration.
77 if (remoting.LogToServer.shouldAddDuration_(state) && 77 if (remoting.LogToServer.shouldAddDuration_(state) &&
78 (this.sessionStartTime_ != 0)) { 78 (this.sessionStartTime_ != 0)) {
79 entry.addSessionDurationField( 79 entry.addSessionDurationField(
80 (new Date().getTime() - this.sessionStartTime_) / 1000.0); 80 (new Date().getTime() - this.sessionStartTime_) / 1000.0);
81 if (remoting.LogToServer.isEndOfSession_(state)) {
82 this.sessionStartTime_ = 0;
83 }
84 } 81 }
82
85 this.log_(entry); 83 this.log_(entry);
86 // Don't accumulate connection statistics across state changes. 84 // Don't accumulate connection statistics across state changes.
87 this.logAccumulatedStatistics_(); 85 this.logAccumulatedStatistics_();
88 this.statsAccumulator_.empty(); 86 this.statsAccumulator_.empty();
89 // Maybe clear the session ID. 87 // Maybe clear the session ID.
90 if (remoting.LogToServer.isEndOfSession_(state)) { 88 if (remoting.LogToServer.isEndOfSession_(state)) {
91 this.clearSessionId_(); 89 this.clearSessionId_();
92 } 90 }
91
93 }; 92 };
94 93
95 /** 94 /**
96 * Set the connection type (direct, stun relay). 95 * Set the connection type (direct, stun relay).
97 * 96 *
98 * @param {string} connectionType 97 * @param {string} connectionType
99 */ 98 */
100 remoting.LogToServer.prototype.setConnectionType = function(connectionType) { 99 remoting.LogToServer.prototype.setConnectionType = function(connectionType) {
101 this.connectionType_ = connectionType; 100 this.connectionType_ = connectionType;
102 }; 101 };
103 102
104 /** 103 /**
105 * @param {remoting.SignalStrategy.Type} strategyType 104 * @param {remoting.SignalStrategy.Type} strategyType
106 * @param {remoting.FallbackSignalStrategy.Progress} progress 105 * @param {remoting.FallbackSignalStrategy.Progress} progress
107 * @param {number} elapsedTimeInMs
108 */ 106 */
109 remoting.LogToServer.prototype.logSignalStrategyProgress = 107 remoting.LogToServer.prototype.logSignalStrategyProgress =
110 function(strategyType, progress, elapsedTimeInMs) { 108 function(strategyType, progress) {
111 this.maybeExpireSessionId_(); 109 this.maybeExpireSessionId_();
112 var entry = remoting.ServerLogEntry.makeSignalStrategyProgress( 110 var entry = remoting.ServerLogEntry.makeSignalStrategyProgress(
113 this.sessionId_, strategyType, progress, elapsedTimeInMs); 111 this.sessionId_, strategyType, progress);
114 this.log_(entry); 112 this.log_(entry);
115 }; 113 };
116 114
117 /** 115 /**
118 * Whether a session state is one of the states that occurs at the start of 116 * Whether a session state is one of the states that occurs at the start of
119 * a session. 117 * a session.
120 * 118 *
121 * @private 119 * @private
122 * @param {remoting.ClientSession.State} state 120 * @param {remoting.ClientSession.State} state
123 * @return {boolean} 121 * @return {boolean}
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 this.statsAccumulator_.empty(); 194 this.statsAccumulator_.empty();
197 }; 195 };
198 196
199 /** 197 /**
200 * Sends a log entry to the server. 198 * Sends a log entry to the server.
201 * 199 *
202 * @private 200 * @private
203 * @param {remoting.ServerLogEntry} entry 201 * @param {remoting.ServerLogEntry} entry
204 */ 202 */
205 remoting.LogToServer.prototype.log_ = function(entry) { 203 remoting.LogToServer.prototype.log_ = function(entry) {
204 // Log the time taken to get to this point from the time this session started.
205 var elapsedTimeInMs = new Date().getTime() - this.sessionStartTime_;
206 entry.addElapsedTimeMs(elapsedTimeInMs);
207
206 // Send the stanza to the debug log. 208 // Send the stanza to the debug log.
207 console.log('Enqueueing log entry:'); 209 console.log('Enqueueing log entry:');
208 entry.toDebugLog(1); 210 entry.toDebugLog(1);
209 211
210 var stanza = '<cli:iq to="' + remoting.settings.DIRECTORY_BOT_JID + '" ' + 212 var stanza = '<cli:iq to="' + remoting.settings.DIRECTORY_BOT_JID + '" ' +
211 'type="set" xmlns:cli="jabber:client">' + 213 'type="set" xmlns:cli="jabber:client">' +
212 '<gr:log xmlns:gr="google:remoting">' + 214 '<gr:log xmlns:gr="google:remoting">' +
213 entry.toStanza() + 215 entry.toStanza() +
214 '</gr:log>' + 216 '</gr:log>' +
215 '</cli:iq>'; 217 '</cli:iq>';
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
270 remoting.LogToServer.generateSessionId_ = function() { 272 remoting.LogToServer.generateSessionId_ = function() {
271 var idArray = []; 273 var idArray = [];
272 for (var i = 0; i < remoting.LogToServer.SESSION_ID_LEN_; i++) { 274 for (var i = 0; i < remoting.LogToServer.SESSION_ID_LEN_; i++) {
273 var index = 275 var index =
274 Math.random() * remoting.LogToServer.SESSION_ID_ALPHABET_.length; 276 Math.random() * remoting.LogToServer.SESSION_ID_ALPHABET_.length;
275 idArray.push( 277 idArray.push(
276 remoting.LogToServer.SESSION_ID_ALPHABET_.slice(index, index + 1)); 278 remoting.LogToServer.SESSION_ID_ALPHABET_.slice(index, index + 1));
277 } 279 }
278 return idArray.join(''); 280 return idArray.join('');
279 }; 281 };
OLDNEW
« no previous file with comments | « remoting/webapp/crd/js/fallback_signal_strategy.js ('k') | remoting/webapp/crd/js/server_log_entry.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698