blob: 081b515c7c9029995b755fb548576dff48875d45 [file] [log] [blame]
buildbot@webrtc.org1567b8c2014-05-08 19:54:16 +00001/*
kjellanderb24317b2016-02-10 07:54:43 -08002 * Copyright 2014 The WebRTC project authors. All Rights Reserved.
buildbot@webrtc.org1567b8c2014-05-08 19:54:16 +00003 *
kjellanderb24317b2016-02-10 07:54:43 -08004 * 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.org1567b8c2014-05-08 19:54:16 +00009 */
10
11// This file contains enums related to IPv4/IPv6 metrics.
12
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020013#ifndef API_UMAMETRICS_H_
14#define API_UMAMETRICS_H_
buildbot@webrtc.org1567b8c2014-05-08 19:54:16 +000015
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020016#include "rtc_base/refcount.h"
skvlad1d3c7e02017-01-11 17:50:30 -080017
buildbot@webrtc.org1567b8c2014-05-08 19:54:16 +000018namespace webrtc {
19
Guo-wei Shieh3d564c12015-08-19 16:51:15 -070020// Used to specify which enum counter type we're incrementing in
21// MetricsObserverInterface::IncrementEnumCounter.
22enum 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 Shieh456696a2015-09-30 21:48:54 -070030
31 kEnumCounterAudioSrtpCipher,
32 kEnumCounterAudioSslCipher,
33 kEnumCounterVideoSrtpCipher,
34 kEnumCounterVideoSslCipher,
35 kEnumCounterDataSrtpCipher,
36 kEnumCounterDataSslCipher,
zhihuangd82eee02016-08-26 11:25:05 -070037 kEnumCounterDtlsHandshakeError,
Honghai Zhangd93f50c2016-10-05 11:47:22 -070038 kEnumCounterIceRegathering,
39 kEnumCounterIceRestart,
Harald Alvestrand194939b2018-01-24 16:04:13 +010040 kEnumCounterKeyProtocol,
Harald Alvestrand5dbb5862018-02-13 23:48:00 +010041 kEnumCounterSdpSemanticRequested,
42 kEnumCounterSdpSemanticNegotiated,
Harald Alvestrandf9d0f1d2018-03-02 14:15:26 +010043 kEnumCounterKeyProtocolMediaType,
Steve Anton8e20f172018-03-06 10:55:04 -080044 kEnumCounterSdpFormatReceived,
Steve Antondb67ba12018-03-19 17:41:42 -070045 // The next 2 counters log the value of srtp_err_status_t defined in libsrtp.
46 kEnumCounterSrtpUnprotectError,
47 kEnumCounterSrtcpUnprotectError,
Harald Alvestrand8ebba742018-05-31 14:00:34 +020048 kEnumCounterUsagePattern,
Guo-wei Shieh3d564c12015-08-19 16:51:15 -070049 kPeerConnectionEnumCounterMax
50};
51
buildbot@webrtc.org1567b8c2014-05-08 19:54:16 +000052// Currently this contains information related to WebRTC network/transport
53// information.
54
Guo-wei Shieh3d564c12015-08-19 16:51:15 -070055// The difference between PeerConnectionEnumCounter and
56// PeerConnectionMetricsName is that the "EnumCounter" is only counting the
guoweis@webrtc.org7169afd2014-12-04 17:59:29 +000057// occurrences of events, while "Name" has a value associated with it which is
58// used to form a histogram.
59
buildbot@webrtc.org1567b8c2014-05-08 19:54:16 +000060// This enum is backed by Chromium's histograms.xml,
61// chromium/src/tools/metrics/histograms/histograms.xml
62// Existing values cannot be re-ordered and new enums must be added
63// before kBoundary.
Guo-wei Shieh3d564c12015-08-19 16:51:15 -070064enum PeerConnectionAddressFamilyCounter {
buildbot@webrtc.org1567b8c2014-05-08 19:54:16 +000065 kPeerConnection_IPv4,
66 kPeerConnection_IPv6,
67 kBestConnections_IPv4,
68 kBestConnections_IPv6,
Guo-wei Shieh3d564c12015-08-19 16:51:15 -070069 kPeerConnectionAddressFamilyCounter_Max,
buildbot@webrtc.org1567b8c2014-05-08 19:54:16 +000070};
71
guoweis@webrtc.org7169afd2014-12-04 17:59:29 +000072// TODO(guoweis): Keep previous name here until all references are renamed.
Guo-wei Shieh3d564c12015-08-19 16:51:15 -070073#define kBoundary kPeerConnectionAddressFamilyCounter_Max
guoweis@webrtc.org7169afd2014-12-04 17:59:29 +000074
75// TODO(guoweis): Keep previous name here until all references are renamed.
Guo-wei Shieh3d564c12015-08-19 16:51:15 -070076typedef PeerConnectionAddressFamilyCounter PeerConnectionUMAMetricsCounter;
guoweis@webrtc.org7169afd2014-12-04 17:59:29 +000077
buildbot@webrtc.org1567b8c2014-05-08 19:54:16 +000078// This enum defines types for UMA samples, which will have a range.
guoweis@webrtc.org7169afd2014-12-04 17:59:29 +000079enum PeerConnectionMetricsName {
80 kNetworkInterfaces_IPv4, // Number of IPv4 interfaces.
81 kNetworkInterfaces_IPv6, // Number of IPv6 interfaces.
82 kTimeToConnect, // In milliseconds.
83 kLocalCandidates_IPv4, // Number of IPv4 local candidates.
84 kLocalCandidates_IPv6, // Number of IPv6 local candidates.
85 kPeerConnectionMetricsName_Max
buildbot@webrtc.org1567b8c2014-05-08 19:54:16 +000086};
87
guoweis@webrtc.org7169afd2014-12-04 17:59:29 +000088// TODO(guoweis): Keep previous name here until all references are renamed.
89typedef PeerConnectionMetricsName PeerConnectionUMAMetricsName;
90
Guo-wei Shieh3d564c12015-08-19 16:51:15 -070091// The IceCandidatePairType has the format of
92// <local_candidate_type>_<remote_candidate_type>. It is recorded based on the
93// type of candidate pair used when the PeerConnection first goes to a completed
94// state. When BUNDLE is enabled, only the first transport gets recorded.
95enum IceCandidatePairType {
Guo-wei Shieh3cc834a2015-09-04 15:52:14 -070096 // HostHost is deprecated. It was replaced with the set of types at the bottom
97 // to report private or public host IP address.
Guo-wei Shieh3d564c12015-08-19 16:51:15 -070098 kIceCandidatePairHostHost,
99 kIceCandidatePairHostSrflx,
100 kIceCandidatePairHostRelay,
101 kIceCandidatePairHostPrflx,
102 kIceCandidatePairSrflxHost,
103 kIceCandidatePairSrflxSrflx,
104 kIceCandidatePairSrflxRelay,
105 kIceCandidatePairSrflxPrflx,
106 kIceCandidatePairRelayHost,
107 kIceCandidatePairRelaySrflx,
108 kIceCandidatePairRelayRelay,
109 kIceCandidatePairRelayPrflx,
110 kIceCandidatePairPrflxHost,
111 kIceCandidatePairPrflxSrflx,
112 kIceCandidatePairPrflxRelay,
Guo-wei Shieh3cc834a2015-09-04 15:52:14 -0700113
114 // The following 4 types tell whether local and remote hosts have private or
115 // public IP addresses.
116 kIceCandidatePairHostPrivateHostPrivate,
117 kIceCandidatePairHostPrivateHostPublic,
118 kIceCandidatePairHostPublicHostPrivate,
119 kIceCandidatePairHostPublicHostPublic,
Guo-wei Shieh3d564c12015-08-19 16:51:15 -0700120 kIceCandidatePairMax
121};
122
Harald Alvestrand194939b2018-01-24 16:04:13 +0100123enum KeyExchangeProtocolType {
124 kEnumCounterKeyProtocolDtls,
125 kEnumCounterKeyProtocolSdes,
126 kEnumCounterKeyProtocolMax
127};
128
Harald Alvestrandf9d0f1d2018-03-02 14:15:26 +0100129enum KeyExchangeProtocolMedia {
130 kEnumCounterKeyProtocolMediaTypeDtlsAudio,
131 kEnumCounterKeyProtocolMediaTypeDtlsVideo,
132 kEnumCounterKeyProtocolMediaTypeDtlsData,
133 kEnumCounterKeyProtocolMediaTypeSdesAudio,
134 kEnumCounterKeyProtocolMediaTypeSdesVideo,
135 kEnumCounterKeyProtocolMediaTypeSdesData,
136 kEnumCounterKeyProtocolMediaTypeMax
137};
138
Harald Alvestrand5dbb5862018-02-13 23:48:00 +0100139enum SdpSemanticRequested {
140 kSdpSemanticRequestDefault,
141 kSdpSemanticRequestPlanB,
142 kSdpSemanticRequestUnifiedPlan,
143 kSdpSemanticRequestMax
144};
145
146enum SdpSemanticNegotiated {
147 kSdpSemanticNegotiatedNone,
148 kSdpSemanticNegotiatedPlanB,
149 kSdpSemanticNegotiatedUnifiedPlan,
150 kSdpSemanticNegotiatedMixed,
151 kSdpSemanticNegotiatedMax
152};
153
Steve Anton8e20f172018-03-06 10:55:04 -0800154// Metric which records the format of the received SDP for tracking how much the
155// difference between Plan B and Unified Plan affect users.
156enum SdpFormatReceived {
157 // No audio or video tracks. This is worth special casing since it seems to be
158 // the most common scenario (data-channel only).
159 kSdpFormatReceivedNoTracks,
160 // No more than one audio and one video track. Should be compatible with both
161 // Plan B and Unified Plan endpoints.
162 kSdpFormatReceivedSimple,
163 // More than one audio track or more than one video track in the Plan B format
164 // (e.g., one audio media section with multiple streams).
165 kSdpFormatReceivedComplexPlanB,
166 // More than one audio track or more than one video track in the Unified Plan
167 // format (e.g., two audio media sections).
168 kSdpFormatReceivedComplexUnifiedPlan,
169 kSdpFormatReceivedMax
170};
171
skvlad1d3c7e02017-01-11 17:50:30 -0800172class MetricsObserverInterface : public rtc::RefCountInterface {
173 public:
skvlad1d3c7e02017-01-11 17:50:30 -0800174 // |type| is the type of the enum counter to be incremented. |counter|
175 // is the particular counter in that type. |counter_max| is the next sequence
176 // number after the highest counter.
177 virtual void IncrementEnumCounter(PeerConnectionEnumCounterType type,
178 int counter,
Qingsi Wang78fef762018-07-11 18:33:52 +0000179 int counter_max) {}
skvlad1d3c7e02017-01-11 17:50:30 -0800180
181 // This is used to handle sparse counters like SSL cipher suites.
182 // TODO(guoweis): Remove the implementation once the dependency's interface
183 // definition is updated.
184 virtual void IncrementSparseEnumCounter(PeerConnectionEnumCounterType type,
Qingsi Wang78fef762018-07-11 18:33:52 +0000185 int counter);
skvlad1d3c7e02017-01-11 17:50:30 -0800186
187 virtual void AddHistogramSample(PeerConnectionMetricsName type,
188 int value) = 0;
skvlad1d3c7e02017-01-11 17:50:30 -0800189};
190
191typedef MetricsObserverInterface UMAObserver;
192
buildbot@webrtc.org1567b8c2014-05-08 19:54:16 +0000193} // namespace webrtc
194
Mirko Bonadei92ea95e2017-09-15 06:47:31 +0200195#endif // API_UMAMETRICS_H_