buildbot@webrtc.org | 1567b8c | 2014-05-08 19:54:16 +0000 | [diff] [blame] | 1 | /* |
kjellander | b24317b | 2016-02-10 07:54:43 -0800 | [diff] [blame] | 2 | * Copyright 2014 The WebRTC project authors. All Rights Reserved. |
buildbot@webrtc.org | 1567b8c | 2014-05-08 19:54:16 +0000 | [diff] [blame] | 3 | * |
kjellander | b24317b | 2016-02-10 07:54:43 -0800 | [diff] [blame] | 4 | * Use of this source code is governed by a BSD-style license |
| 5 | * that can be found in the LICENSE file in the root of the source |
| 6 | * tree. An additional intellectual property rights grant can be found |
| 7 | * in the file PATENTS. All contributing project authors may |
| 8 | * be found in the AUTHORS file in the root of the source tree. |
buildbot@webrtc.org | 1567b8c | 2014-05-08 19:54:16 +0000 | [diff] [blame] | 9 | */ |
| 10 | |
| 11 | // This file contains enums related to IPv4/IPv6 metrics. |
| 12 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 13 | #ifndef API_UMAMETRICS_H_ |
| 14 | #define API_UMAMETRICS_H_ |
buildbot@webrtc.org | 1567b8c | 2014-05-08 19:54:16 +0000 | [diff] [blame] | 15 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 16 | #include "rtc_base/refcount.h" |
skvlad | 1d3c7e0 | 2017-01-11 17:50:30 -0800 | [diff] [blame] | 17 | |
buildbot@webrtc.org | 1567b8c | 2014-05-08 19:54:16 +0000 | [diff] [blame] | 18 | namespace webrtc { |
| 19 | |
Guo-wei Shieh | 3d564c1 | 2015-08-19 16:51:15 -0700 | [diff] [blame] | 20 | // Used to specify which enum counter type we're incrementing in |
| 21 | // MetricsObserverInterface::IncrementEnumCounter. |
| 22 | enum PeerConnectionEnumCounterType { |
| 23 | kEnumCounterAddressFamily, |
| 24 | // For the next 2 counters, we track them separately based on the "first hop" |
| 25 | // protocol used by the local candidate. "First hop" means the local candidate |
| 26 | // type in the case of non-TURN candidates, and the protocol used to connect |
| 27 | // to the TURN server in the case of TURN candidates. |
| 28 | kEnumCounterIceCandidatePairTypeUdp, |
| 29 | kEnumCounterIceCandidatePairTypeTcp, |
Guo-wei Shieh | 456696a | 2015-09-30 21:48:54 -0700 | [diff] [blame] | 30 | |
| 31 | kEnumCounterAudioSrtpCipher, |
| 32 | kEnumCounterAudioSslCipher, |
| 33 | kEnumCounterVideoSrtpCipher, |
| 34 | kEnumCounterVideoSslCipher, |
| 35 | kEnumCounterDataSrtpCipher, |
| 36 | kEnumCounterDataSslCipher, |
zhihuang | d82eee0 | 2016-08-26 11:25:05 -0700 | [diff] [blame] | 37 | kEnumCounterDtlsHandshakeError, |
Honghai Zhang | d93f50c | 2016-10-05 11:47:22 -0700 | [diff] [blame] | 38 | kEnumCounterIceRegathering, |
| 39 | kEnumCounterIceRestart, |
Harald Alvestrand | 194939b | 2018-01-24 16:04:13 +0100 | [diff] [blame] | 40 | kEnumCounterKeyProtocol, |
Harald Alvestrand | 5dbb586 | 2018-02-13 23:48:00 +0100 | [diff] [blame] | 41 | kEnumCounterSdpSemanticRequested, |
| 42 | kEnumCounterSdpSemanticNegotiated, |
Harald Alvestrand | f9d0f1d | 2018-03-02 14:15:26 +0100 | [diff] [blame] | 43 | kEnumCounterKeyProtocolMediaType, |
Steve Anton | 8e20f17 | 2018-03-06 10:55:04 -0800 | [diff] [blame] | 44 | kEnumCounterSdpFormatReceived, |
Steve Anton | db67ba1 | 2018-03-19 17:41:42 -0700 | [diff] [blame] | 45 | // The next 2 counters log the value of srtp_err_status_t defined in libsrtp. |
| 46 | kEnumCounterSrtpUnprotectError, |
| 47 | kEnumCounterSrtcpUnprotectError, |
Guo-wei Shieh | 3d564c1 | 2015-08-19 16:51:15 -0700 | [diff] [blame] | 48 | kPeerConnectionEnumCounterMax |
| 49 | }; |
| 50 | |
buildbot@webrtc.org | 1567b8c | 2014-05-08 19:54:16 +0000 | [diff] [blame] | 51 | // Currently this contains information related to WebRTC network/transport |
| 52 | // information. |
| 53 | |
Guo-wei Shieh | 3d564c1 | 2015-08-19 16:51:15 -0700 | [diff] [blame] | 54 | // The difference between PeerConnectionEnumCounter and |
| 55 | // PeerConnectionMetricsName is that the "EnumCounter" is only counting the |
guoweis@webrtc.org | 7169afd | 2014-12-04 17:59:29 +0000 | [diff] [blame] | 56 | // occurrences of events, while "Name" has a value associated with it which is |
| 57 | // used to form a histogram. |
| 58 | |
buildbot@webrtc.org | 1567b8c | 2014-05-08 19:54:16 +0000 | [diff] [blame] | 59 | // This enum is backed by Chromium's histograms.xml, |
| 60 | // chromium/src/tools/metrics/histograms/histograms.xml |
| 61 | // Existing values cannot be re-ordered and new enums must be added |
| 62 | // before kBoundary. |
Guo-wei Shieh | 3d564c1 | 2015-08-19 16:51:15 -0700 | [diff] [blame] | 63 | enum PeerConnectionAddressFamilyCounter { |
buildbot@webrtc.org | 1567b8c | 2014-05-08 19:54:16 +0000 | [diff] [blame] | 64 | kPeerConnection_IPv4, |
| 65 | kPeerConnection_IPv6, |
| 66 | kBestConnections_IPv4, |
| 67 | kBestConnections_IPv6, |
Guo-wei Shieh | 3d564c1 | 2015-08-19 16:51:15 -0700 | [diff] [blame] | 68 | kPeerConnectionAddressFamilyCounter_Max, |
buildbot@webrtc.org | 1567b8c | 2014-05-08 19:54:16 +0000 | [diff] [blame] | 69 | }; |
| 70 | |
guoweis@webrtc.org | 7169afd | 2014-12-04 17:59:29 +0000 | [diff] [blame] | 71 | // TODO(guoweis): Keep previous name here until all references are renamed. |
Guo-wei Shieh | 3d564c1 | 2015-08-19 16:51:15 -0700 | [diff] [blame] | 72 | #define kBoundary kPeerConnectionAddressFamilyCounter_Max |
guoweis@webrtc.org | 7169afd | 2014-12-04 17:59:29 +0000 | [diff] [blame] | 73 | |
| 74 | // TODO(guoweis): Keep previous name here until all references are renamed. |
Guo-wei Shieh | 3d564c1 | 2015-08-19 16:51:15 -0700 | [diff] [blame] | 75 | typedef PeerConnectionAddressFamilyCounter PeerConnectionUMAMetricsCounter; |
guoweis@webrtc.org | 7169afd | 2014-12-04 17:59:29 +0000 | [diff] [blame] | 76 | |
buildbot@webrtc.org | 1567b8c | 2014-05-08 19:54:16 +0000 | [diff] [blame] | 77 | // This enum defines types for UMA samples, which will have a range. |
guoweis@webrtc.org | 7169afd | 2014-12-04 17:59:29 +0000 | [diff] [blame] | 78 | enum PeerConnectionMetricsName { |
| 79 | kNetworkInterfaces_IPv4, // Number of IPv4 interfaces. |
| 80 | kNetworkInterfaces_IPv6, // Number of IPv6 interfaces. |
| 81 | kTimeToConnect, // In milliseconds. |
| 82 | kLocalCandidates_IPv4, // Number of IPv4 local candidates. |
| 83 | kLocalCandidates_IPv6, // Number of IPv6 local candidates. |
| 84 | kPeerConnectionMetricsName_Max |
buildbot@webrtc.org | 1567b8c | 2014-05-08 19:54:16 +0000 | [diff] [blame] | 85 | }; |
| 86 | |
guoweis@webrtc.org | 7169afd | 2014-12-04 17:59:29 +0000 | [diff] [blame] | 87 | // TODO(guoweis): Keep previous name here until all references are renamed. |
| 88 | typedef PeerConnectionMetricsName PeerConnectionUMAMetricsName; |
| 89 | |
Guo-wei Shieh | 3d564c1 | 2015-08-19 16:51:15 -0700 | [diff] [blame] | 90 | // The IceCandidatePairType has the format of |
| 91 | // <local_candidate_type>_<remote_candidate_type>. It is recorded based on the |
| 92 | // type of candidate pair used when the PeerConnection first goes to a completed |
| 93 | // state. When BUNDLE is enabled, only the first transport gets recorded. |
| 94 | enum IceCandidatePairType { |
Guo-wei Shieh | 3cc834a | 2015-09-04 15:52:14 -0700 | [diff] [blame] | 95 | // HostHost is deprecated. It was replaced with the set of types at the bottom |
| 96 | // to report private or public host IP address. |
Guo-wei Shieh | 3d564c1 | 2015-08-19 16:51:15 -0700 | [diff] [blame] | 97 | kIceCandidatePairHostHost, |
| 98 | kIceCandidatePairHostSrflx, |
| 99 | kIceCandidatePairHostRelay, |
| 100 | kIceCandidatePairHostPrflx, |
| 101 | kIceCandidatePairSrflxHost, |
| 102 | kIceCandidatePairSrflxSrflx, |
| 103 | kIceCandidatePairSrflxRelay, |
| 104 | kIceCandidatePairSrflxPrflx, |
| 105 | kIceCandidatePairRelayHost, |
| 106 | kIceCandidatePairRelaySrflx, |
| 107 | kIceCandidatePairRelayRelay, |
| 108 | kIceCandidatePairRelayPrflx, |
| 109 | kIceCandidatePairPrflxHost, |
| 110 | kIceCandidatePairPrflxSrflx, |
| 111 | kIceCandidatePairPrflxRelay, |
Guo-wei Shieh | 3cc834a | 2015-09-04 15:52:14 -0700 | [diff] [blame] | 112 | |
| 113 | // The following 4 types tell whether local and remote hosts have private or |
| 114 | // public IP addresses. |
| 115 | kIceCandidatePairHostPrivateHostPrivate, |
| 116 | kIceCandidatePairHostPrivateHostPublic, |
| 117 | kIceCandidatePairHostPublicHostPrivate, |
| 118 | kIceCandidatePairHostPublicHostPublic, |
Guo-wei Shieh | 3d564c1 | 2015-08-19 16:51:15 -0700 | [diff] [blame] | 119 | kIceCandidatePairMax |
| 120 | }; |
| 121 | |
Harald Alvestrand | 194939b | 2018-01-24 16:04:13 +0100 | [diff] [blame] | 122 | enum KeyExchangeProtocolType { |
| 123 | kEnumCounterKeyProtocolDtls, |
| 124 | kEnumCounterKeyProtocolSdes, |
| 125 | kEnumCounterKeyProtocolMax |
| 126 | }; |
| 127 | |
Harald Alvestrand | f9d0f1d | 2018-03-02 14:15:26 +0100 | [diff] [blame] | 128 | enum KeyExchangeProtocolMedia { |
| 129 | kEnumCounterKeyProtocolMediaTypeDtlsAudio, |
| 130 | kEnumCounterKeyProtocolMediaTypeDtlsVideo, |
| 131 | kEnumCounterKeyProtocolMediaTypeDtlsData, |
| 132 | kEnumCounterKeyProtocolMediaTypeSdesAudio, |
| 133 | kEnumCounterKeyProtocolMediaTypeSdesVideo, |
| 134 | kEnumCounterKeyProtocolMediaTypeSdesData, |
| 135 | kEnumCounterKeyProtocolMediaTypeMax |
| 136 | }; |
| 137 | |
Harald Alvestrand | 5dbb586 | 2018-02-13 23:48:00 +0100 | [diff] [blame] | 138 | enum SdpSemanticRequested { |
| 139 | kSdpSemanticRequestDefault, |
| 140 | kSdpSemanticRequestPlanB, |
| 141 | kSdpSemanticRequestUnifiedPlan, |
| 142 | kSdpSemanticRequestMax |
| 143 | }; |
| 144 | |
| 145 | enum SdpSemanticNegotiated { |
| 146 | kSdpSemanticNegotiatedNone, |
| 147 | kSdpSemanticNegotiatedPlanB, |
| 148 | kSdpSemanticNegotiatedUnifiedPlan, |
| 149 | kSdpSemanticNegotiatedMixed, |
| 150 | kSdpSemanticNegotiatedMax |
| 151 | }; |
| 152 | |
Steve Anton | 8e20f17 | 2018-03-06 10:55:04 -0800 | [diff] [blame] | 153 | // Metric which records the format of the received SDP for tracking how much the |
| 154 | // difference between Plan B and Unified Plan affect users. |
| 155 | enum SdpFormatReceived { |
| 156 | // No audio or video tracks. This is worth special casing since it seems to be |
| 157 | // the most common scenario (data-channel only). |
| 158 | kSdpFormatReceivedNoTracks, |
| 159 | // No more than one audio and one video track. Should be compatible with both |
| 160 | // Plan B and Unified Plan endpoints. |
| 161 | kSdpFormatReceivedSimple, |
| 162 | // More than one audio track or more than one video track in the Plan B format |
| 163 | // (e.g., one audio media section with multiple streams). |
| 164 | kSdpFormatReceivedComplexPlanB, |
| 165 | // More than one audio track or more than one video track in the Unified Plan |
| 166 | // format (e.g., two audio media sections). |
| 167 | kSdpFormatReceivedComplexUnifiedPlan, |
| 168 | kSdpFormatReceivedMax |
| 169 | }; |
| 170 | |
skvlad | 1d3c7e0 | 2017-01-11 17:50:30 -0800 | [diff] [blame] | 171 | class MetricsObserverInterface : public rtc::RefCountInterface { |
| 172 | public: |
skvlad | 1d3c7e0 | 2017-01-11 17:50:30 -0800 | [diff] [blame] | 173 | // |type| is the type of the enum counter to be incremented. |counter| |
| 174 | // is the particular counter in that type. |counter_max| is the next sequence |
| 175 | // number after the highest counter. |
| 176 | virtual void IncrementEnumCounter(PeerConnectionEnumCounterType type, |
| 177 | int counter, |
| 178 | int counter_max) {} |
| 179 | |
| 180 | // This is used to handle sparse counters like SSL cipher suites. |
| 181 | // TODO(guoweis): Remove the implementation once the dependency's interface |
| 182 | // definition is updated. |
| 183 | virtual void IncrementSparseEnumCounter(PeerConnectionEnumCounterType type, |
Steve Anton | f2737d2 | 2017-10-31 16:27:34 -0700 | [diff] [blame] | 184 | int counter); |
skvlad | 1d3c7e0 | 2017-01-11 17:50:30 -0800 | [diff] [blame] | 185 | |
| 186 | virtual void AddHistogramSample(PeerConnectionMetricsName type, |
| 187 | int value) = 0; |
skvlad | 1d3c7e0 | 2017-01-11 17:50:30 -0800 | [diff] [blame] | 188 | }; |
| 189 | |
| 190 | typedef MetricsObserverInterface UMAObserver; |
| 191 | |
buildbot@webrtc.org | 1567b8c | 2014-05-08 19:54:16 +0000 | [diff] [blame] | 192 | } // namespace webrtc |
| 193 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 194 | #endif // API_UMAMETRICS_H_ |