blob: c51259852331aa9d1e362336674213de7849fa79 [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,
Guo-wei Shieh3d564c12015-08-19 16:51:15 -070040 kPeerConnectionEnumCounterMax
41};
42
buildbot@webrtc.org1567b8c2014-05-08 19:54:16 +000043// Currently this contains information related to WebRTC network/transport
44// information.
45
Guo-wei Shieh3d564c12015-08-19 16:51:15 -070046// The difference between PeerConnectionEnumCounter and
47// PeerConnectionMetricsName is that the "EnumCounter" is only counting the
guoweis@webrtc.org7169afd2014-12-04 17:59:29 +000048// occurrences of events, while "Name" has a value associated with it which is
49// used to form a histogram.
50
buildbot@webrtc.org1567b8c2014-05-08 19:54:16 +000051// This enum is backed by Chromium's histograms.xml,
52// chromium/src/tools/metrics/histograms/histograms.xml
53// Existing values cannot be re-ordered and new enums must be added
54// before kBoundary.
Guo-wei Shieh3d564c12015-08-19 16:51:15 -070055enum PeerConnectionAddressFamilyCounter {
buildbot@webrtc.org1567b8c2014-05-08 19:54:16 +000056 kPeerConnection_IPv4,
57 kPeerConnection_IPv6,
58 kBestConnections_IPv4,
59 kBestConnections_IPv6,
Guo-wei Shieh3d564c12015-08-19 16:51:15 -070060 kPeerConnectionAddressFamilyCounter_Max,
buildbot@webrtc.org1567b8c2014-05-08 19:54:16 +000061};
62
guoweis@webrtc.org7169afd2014-12-04 17:59:29 +000063// TODO(guoweis): Keep previous name here until all references are renamed.
Guo-wei Shieh3d564c12015-08-19 16:51:15 -070064#define kBoundary kPeerConnectionAddressFamilyCounter_Max
guoweis@webrtc.org7169afd2014-12-04 17:59:29 +000065
66// TODO(guoweis): Keep previous name here until all references are renamed.
Guo-wei Shieh3d564c12015-08-19 16:51:15 -070067typedef PeerConnectionAddressFamilyCounter PeerConnectionUMAMetricsCounter;
guoweis@webrtc.org7169afd2014-12-04 17:59:29 +000068
buildbot@webrtc.org1567b8c2014-05-08 19:54:16 +000069// This enum defines types for UMA samples, which will have a range.
guoweis@webrtc.org7169afd2014-12-04 17:59:29 +000070enum PeerConnectionMetricsName {
71 kNetworkInterfaces_IPv4, // Number of IPv4 interfaces.
72 kNetworkInterfaces_IPv6, // Number of IPv6 interfaces.
73 kTimeToConnect, // In milliseconds.
74 kLocalCandidates_IPv4, // Number of IPv4 local candidates.
75 kLocalCandidates_IPv6, // Number of IPv6 local candidates.
76 kPeerConnectionMetricsName_Max
buildbot@webrtc.org1567b8c2014-05-08 19:54:16 +000077};
78
guoweis@webrtc.org7169afd2014-12-04 17:59:29 +000079// TODO(guoweis): Keep previous name here until all references are renamed.
80typedef PeerConnectionMetricsName PeerConnectionUMAMetricsName;
81
Guo-wei Shieh3d564c12015-08-19 16:51:15 -070082// The IceCandidatePairType has the format of
83// <local_candidate_type>_<remote_candidate_type>. It is recorded based on the
84// type of candidate pair used when the PeerConnection first goes to a completed
85// state. When BUNDLE is enabled, only the first transport gets recorded.
86enum IceCandidatePairType {
Guo-wei Shieh3cc834a2015-09-04 15:52:14 -070087 // HostHost is deprecated. It was replaced with the set of types at the bottom
88 // to report private or public host IP address.
Guo-wei Shieh3d564c12015-08-19 16:51:15 -070089 kIceCandidatePairHostHost,
90 kIceCandidatePairHostSrflx,
91 kIceCandidatePairHostRelay,
92 kIceCandidatePairHostPrflx,
93 kIceCandidatePairSrflxHost,
94 kIceCandidatePairSrflxSrflx,
95 kIceCandidatePairSrflxRelay,
96 kIceCandidatePairSrflxPrflx,
97 kIceCandidatePairRelayHost,
98 kIceCandidatePairRelaySrflx,
99 kIceCandidatePairRelayRelay,
100 kIceCandidatePairRelayPrflx,
101 kIceCandidatePairPrflxHost,
102 kIceCandidatePairPrflxSrflx,
103 kIceCandidatePairPrflxRelay,
Guo-wei Shieh3cc834a2015-09-04 15:52:14 -0700104
105 // The following 4 types tell whether local and remote hosts have private or
106 // public IP addresses.
107 kIceCandidatePairHostPrivateHostPrivate,
108 kIceCandidatePairHostPrivateHostPublic,
109 kIceCandidatePairHostPublicHostPrivate,
110 kIceCandidatePairHostPublicHostPublic,
Guo-wei Shieh3d564c12015-08-19 16:51:15 -0700111 kIceCandidatePairMax
112};
113
skvlad1d3c7e02017-01-11 17:50:30 -0800114class MetricsObserverInterface : public rtc::RefCountInterface {
115 public:
skvlad1d3c7e02017-01-11 17:50:30 -0800116 // |type| is the type of the enum counter to be incremented. |counter|
117 // is the particular counter in that type. |counter_max| is the next sequence
118 // number after the highest counter.
119 virtual void IncrementEnumCounter(PeerConnectionEnumCounterType type,
120 int counter,
121 int counter_max) {}
122
123 // This is used to handle sparse counters like SSL cipher suites.
124 // TODO(guoweis): Remove the implementation once the dependency's interface
125 // definition is updated.
126 virtual void IncrementSparseEnumCounter(PeerConnectionEnumCounterType type,
Steve Antonf2737d22017-10-31 16:27:34 -0700127 int counter);
skvlad1d3c7e02017-01-11 17:50:30 -0800128
129 virtual void AddHistogramSample(PeerConnectionMetricsName type,
130 int value) = 0;
skvlad1d3c7e02017-01-11 17:50:30 -0800131};
132
133typedef MetricsObserverInterface UMAObserver;
134
buildbot@webrtc.org1567b8c2014-05-08 19:54:16 +0000135} // namespace webrtc
136
Mirko Bonadei92ea95e2017-09-15 06:47:31 +0200137#endif // API_UMAMETRICS_H_