diff options
author | anandc <anandc@chromium.org> | 2015-08-21 17:22:22 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-08-22 00:22:49 +0000 |
commit | 49b2fcd7c800c94961c5644b847639dabccdc7e7 (patch) | |
tree | c0afe5050b27d135b388c65198851a0d1391ee4f /remoting/webapp/base | |
parent | 7e277125ad1b99da6b51a711302a110b4d5d45a2 (diff) | |
download | chromium_src-49b2fcd7c800c94961c5644b847639dabccdc7e7.zip chromium_src-49b2fcd7c800c94961c5644b847639dabccdc7e7.tar.gz chromium_src-49b2fcd7c800c94961c5644b847639dabccdc7e7.tar.bz2 |
Add UMA stats for connection times and durations in the Chromoting plugin.
Also add UMA counters for each connection-state in the web-app.
BUG=502061
Review URL: https://codereview.chromium.org/1305453002
Cr-Commit-Position: refs/heads/master@{#344930}
Diffstat (limited to 'remoting/webapp/base')
-rw-r--r-- | remoting/webapp/base/js/client_session.js | 40 |
1 files changed, 39 insertions, 1 deletions
diff --git a/remoting/webapp/base/js/client_session.js b/remoting/webapp/base/js/client_session.js index 259f53e..c6d0340 100644 --- a/remoting/webapp/base/js/client_session.js +++ b/remoting/webapp/base/js/client_session.js @@ -135,8 +135,16 @@ remoting.ClientSession.EventHandler.prototype.onDisconnected = // // TODO(kelvinp): Merge this enum with remoting.ChromotingEvent.SessionState // once we have migrated away from XMPP-based logging (crbug.com/523423). +// NOTE: The enums here correspond to the Chromoting.Connections enumerated +// histogram defined in src/tools/metrics/histograms/histograms.xml. UMA +// histograms don't work well with negative values, so only non-negative values +// have been used for Chromoting.Connections. +// The maximum values for the UMA enumerated histogram is included here for use +// when uploading values to UMA. +// The 2 lists should be kept in sync, and any new enums should be append-only. /** @enum {number} */ remoting.ClientSession.State = { + MIN_STATE_ENUM: -3, CONNECTION_CANCELED: -3, // Connection closed (gracefully) before connecting. CONNECTION_DROPPED: -2, // Succeeded, but subsequently closed with an error. CREATED: -1, @@ -146,7 +154,8 @@ remoting.ClientSession.State = { AUTHENTICATED: 3, CONNECTED: 4, CLOSED: 5, - FAILED: 6 + FAILED: 6, + MAX_STATE_ENUM: 6, }; /** @@ -542,11 +551,40 @@ remoting.ClientSession.prototype.setState_ = function(newState) { } this.notifyStateChanges_(oldState, this.state_); + // Record state count in an UMA enumerated histogram. + recordState(this.state_); this.logger_.logClientSessionStateChange( this.state_, this.error_, this.xmppErrorCache_.getFirstError()); }; /** + * Records a Chromoting Connection State, stored in an UMA enumerated histogram. + * @param {remoting.ClientSession.State} state State identifier. + */ +function recordState(state) { + // According to src/base/metrics/histogram.h, for a UMA enumerated histogram, + // the upper limit should be 1 above the max-enum. Because SessionState's + // minimum enum value is negative, we'll just take the difference of the max + // and min enums. + var histogram_max = (remoting.ClientSession.State.MAX_STATE_ENUM - + remoting.ClientSession.State.MIN_STATE_ENUM); + + var metricDescription = { + metricName: 'Chromoting.Connections', + type: 'histogram-linear', + // According to histogram.h, minimum should be 1. Values less than minimum + // end up in the 0th bucket. + min: 1, + max: histogram_max, + // The # of buckets should include 1 for underflow. + buckets: histogram_max + 1 + }; + + chrome.metricsPrivate.recordValue(metricDescription, state - + remoting.ClientSession.State.MIN_STATE_ENUM); +} + +/** * @param {remoting.ClientSession.State} oldState The new state for the session. * @param {remoting.ClientSession.State} newState The new state for the session. * @private |