/work/obj-fuzz/dist/include/mozilla/Telemetry.h
Line | Count | Source (jump to first uncovered line) |
1 | | /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2; -*- */ |
2 | | /* This Source Code Form is subject to the terms of the Mozilla Public |
3 | | * License, v. 2.0. If a copy of the MPL was not distributed with this |
4 | | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
5 | | |
6 | | #ifndef Telemetry_h__ |
7 | | #define Telemetry_h__ |
8 | | |
9 | | #include "mozilla/GuardObjects.h" |
10 | | #include "mozilla/TimeStamp.h" |
11 | | #include "mozilla/StartupTimeline.h" |
12 | | #include "nsTArray.h" |
13 | | #include "nsString.h" |
14 | | #include "nsXULAppAPI.h" |
15 | | |
16 | | #include "mozilla/TelemetryHistogramEnums.h" |
17 | | #include "mozilla/TelemetryScalarEnums.h" |
18 | | |
19 | | /****************************************************************************** |
20 | | * This implements the Telemetry system. |
21 | | * It allows recording into histograms as well some more specialized data |
22 | | * points and gives access to the data. |
23 | | * |
24 | | * For documentation on how to add and use new Telemetry probes, see: |
25 | | * https://developer.mozilla.org/en-US/docs/Mozilla/Performance/Adding_a_new_Telemetry_probe |
26 | | * |
27 | | * For more general information on Telemetry see: |
28 | | * https://wiki.mozilla.org/Telemetry |
29 | | *****************************************************************************/ |
30 | | |
31 | | namespace mozilla { |
32 | | namespace Telemetry { |
33 | | |
34 | | struct HistogramAccumulation; |
35 | | struct KeyedHistogramAccumulation; |
36 | | struct ScalarAction; |
37 | | struct KeyedScalarAction; |
38 | | struct ChildEventData; |
39 | | |
40 | | /** |
41 | | * Initialize the Telemetry service on the main thread at startup. |
42 | | */ |
43 | | void Init(); |
44 | | |
45 | | /** |
46 | | * Adds sample to a histogram defined in TelemetryHistogramEnums.h |
47 | | * |
48 | | * @param id - histogram id |
49 | | * @param sample - value to record. |
50 | | */ |
51 | | void Accumulate(HistogramID id, uint32_t sample); |
52 | | |
53 | | /** |
54 | | * Adds an array of samples to a histogram defined in TelemetryHistograms.h |
55 | | * @param id - histogram id |
56 | | * @param samples - values to record. |
57 | | */ |
58 | | void Accumulate(HistogramID id, const nsTArray<uint32_t>& samples); |
59 | | |
60 | | /** |
61 | | * Adds sample to a keyed histogram defined in TelemetryHistogramEnums.h |
62 | | * |
63 | | * @param id - keyed histogram id |
64 | | * @param key - the string key |
65 | | * @param sample - (optional) value to record, defaults to 1. |
66 | | */ |
67 | | void Accumulate(HistogramID id, const nsCString& key, uint32_t sample = 1); |
68 | | |
69 | | /** |
70 | | * Adds an array of samples to a histogram defined in TelemetryHistograms.h |
71 | | * @param id - histogram id |
72 | | * @param samples - values to record. |
73 | | * @param key - the string key |
74 | | */ |
75 | | void Accumulate(HistogramID id, const nsCString& key, const nsTArray<uint32_t>& samples); |
76 | | |
77 | | /** |
78 | | * Adds a sample to a histogram defined in TelemetryHistogramEnums.h. |
79 | | * This function is here to support telemetry measurements from Java, |
80 | | * where we have only names and not numeric IDs. You should almost |
81 | | * certainly be using the by-enum-id version instead of this one. |
82 | | * |
83 | | * @param name - histogram name |
84 | | * @param sample - value to record |
85 | | */ |
86 | | void Accumulate(const char* name, uint32_t sample); |
87 | | |
88 | | /** |
89 | | * Adds a sample to a histogram defined in TelemetryHistogramEnums.h. |
90 | | * This function is here to support telemetry measurements from Java, |
91 | | * where we have only names and not numeric IDs. You should almost |
92 | | * certainly be using the by-enum-id version instead of this one. |
93 | | * |
94 | | * @param name - histogram name |
95 | | * @param key - the string key |
96 | | * @param sample - sample - (optional) value to record, defaults to 1. |
97 | | */ |
98 | | void Accumulate(const char *name, const nsCString& key, uint32_t sample = 1); |
99 | | |
100 | | /** |
101 | | * Adds sample to a categorical histogram defined in TelemetryHistogramEnums.h |
102 | | * This is the typesafe - and preferred - way to use the categorical histograms |
103 | | * by passing values from the corresponding Telemetry::LABELS_* enum. |
104 | | * |
105 | | * @param enumValue - Label value from one of the Telemetry::LABELS_* enums. |
106 | | */ |
107 | | template<class E> |
108 | 0 | void AccumulateCategorical(E enumValue) { |
109 | 0 | static_assert(IsCategoricalLabelEnum<E>::value, |
110 | 0 | "Only categorical label enum types are supported."); |
111 | 0 | Accumulate(static_cast<HistogramID>(CategoricalLabelId<E>::value), |
112 | 0 | static_cast<uint32_t>(enumValue)); |
113 | 0 | }; Unexecuted instantiation: void mozilla::Telemetry::AccumulateCategorical<mozilla::Telemetry::LABELS_HTTP_SCHEME_UPGRADE_TYPE>(mozilla::Telemetry::LABELS_HTTP_SCHEME_UPGRADE_TYPE) Unexecuted instantiation: void mozilla::Telemetry::AccumulateCategorical<mozilla::Telemetry::LABELS_DNS_LOOKUP_DISPOSITION>(mozilla::Telemetry::LABELS_DNS_LOOKUP_DISPOSITION) Unexecuted instantiation: void mozilla::Telemetry::AccumulateCategorical<mozilla::Telemetry::LABELS_DNS_TRR_RACE2>(mozilla::Telemetry::LABELS_DNS_TRR_RACE2) Unexecuted instantiation: void mozilla::Telemetry::AccumulateCategorical<mozilla::Telemetry::LABELS_DNS_TRR_COMPARE>(mozilla::Telemetry::LABELS_DNS_TRR_COMPARE) Unexecuted instantiation: void mozilla::Telemetry::AccumulateCategorical<mozilla::Telemetry::LABELS_DNS_TRR_FIRST>(mozilla::Telemetry::LABELS_DNS_TRR_FIRST) Unexecuted instantiation: void mozilla::Telemetry::AccumulateCategorical<mozilla::Telemetry::LABELS_DNS_LOOKUP_ALGORITHM>(mozilla::Telemetry::LABELS_DNS_LOOKUP_ALGORITHM) Unexecuted instantiation: void mozilla::Telemetry::AccumulateCategorical<mozilla::Telemetry::LABELS_NETWORK_RACE_CACHE_VALIDATION>(mozilla::Telemetry::LABELS_NETWORK_RACE_CACHE_VALIDATION) Unexecuted instantiation: void mozilla::Telemetry::AccumulateCategorical<mozilla::Telemetry::LABELS_SCRIPT_BLOCK_INCORRECT_MIME_2>(mozilla::Telemetry::LABELS_SCRIPT_BLOCK_INCORRECT_MIME_2) Unexecuted instantiation: void mozilla::Telemetry::AccumulateCategorical<mozilla::Telemetry::LABELS_NETWORK_RACE_CACHE_WITH_NETWORK_USAGE_2>(mozilla::Telemetry::LABELS_NETWORK_RACE_CACHE_WITH_NETWORK_USAGE_2) Unexecuted instantiation: void mozilla::Telemetry::AccumulateCategorical<mozilla::Telemetry::LABELS_WEBRTC_SRTP_CIPHER>(mozilla::Telemetry::LABELS_WEBRTC_SRTP_CIPHER) Unexecuted instantiation: void mozilla::Telemetry::AccumulateCategorical<mozilla::Telemetry::LABELS_DOCUMENT_ANALYTICS_TRACKER_FASTBLOCKED>(mozilla::Telemetry::LABELS_DOCUMENT_ANALYTICS_TRACKER_FASTBLOCKED) Unexecuted instantiation: void mozilla::Telemetry::AccumulateCategorical<mozilla::Telemetry::LABELS_HIDDEN_VIEWPORT_OVERFLOW_TYPE>(mozilla::Telemetry::LABELS_HIDDEN_VIEWPORT_OVERFLOW_TYPE) Unexecuted instantiation: void mozilla::Telemetry::AccumulateCategorical<mozilla::Telemetry::LABELS_MEDIA_PLAY_PROMISE_RESOLUTION>(mozilla::Telemetry::LABELS_MEDIA_PLAY_PROMISE_RESOLUTION) Unexecuted instantiation: void mozilla::Telemetry::AccumulateCategorical<mozilla::Telemetry::LABELS_DOM_SCRIPT_KIND>(mozilla::Telemetry::LABELS_DOM_SCRIPT_KIND) Unexecuted instantiation: void mozilla::Telemetry::AccumulateCategorical<mozilla::Telemetry::LABELS_DOM_SCRIPT_LOADING_SOURCE>(mozilla::Telemetry::LABELS_DOM_SCRIPT_LOADING_SOURCE) Unexecuted instantiation: void mozilla::Telemetry::AccumulateCategorical<mozilla::Telemetry::LABELS_DOM_SCRIPT_PRELOAD_RESULT>(mozilla::Telemetry::LABELS_DOM_SCRIPT_PRELOAD_RESULT) Unexecuted instantiation: void mozilla::Telemetry::AccumulateCategorical<mozilla::Telemetry::LABELS_APPLICATION_REPUTATION_BINARY>(mozilla::Telemetry::LABELS_APPLICATION_REPUTATION_BINARY) Unexecuted instantiation: void mozilla::Telemetry::AccumulateCategorical<mozilla::Telemetry::LABELS_APPLICATION_REPUTATION_BINARY_ARCHIVE>(mozilla::Telemetry::LABELS_APPLICATION_REPUTATION_BINARY_ARCHIVE) Unexecuted instantiation: void mozilla::Telemetry::AccumulateCategorical<mozilla::Telemetry::LABELS_APPLICATION_REPUTATION_HASH_LENGTH>(mozilla::Telemetry::LABELS_APPLICATION_REPUTATION_HASH_LENGTH) Unexecuted instantiation: void mozilla::Telemetry::AccumulateCategorical<mozilla::Telemetry::LABELS_APPLICATION_REPUTATION_SERVER_2>(mozilla::Telemetry::LABELS_APPLICATION_REPUTATION_SERVER_2) Unexecuted instantiation: void mozilla::Telemetry::AccumulateCategorical<mozilla::Telemetry::LABELS_TELEMETRY_TEST_CATEGORICAL>(mozilla::Telemetry::LABELS_TELEMETRY_TEST_CATEGORICAL) |
114 | | |
115 | | /** |
116 | | * Adds an array of samples to categorical histograms defined in TelemetryHistogramEnums.h |
117 | | * This is the typesafe - and preferred - way to use the categorical histograms |
118 | | * by passing values from the corresponding Telemetry::LABELS_* enums. |
119 | | * |
120 | | * @param enumValues - Array of labels from Telemetry::LABELS_* enums. |
121 | | */ |
122 | | template<class E> |
123 | | void |
124 | | AccumulateCategorical(const nsTArray<E>& enumValues) |
125 | 0 | { |
126 | 0 | static_assert(IsCategoricalLabelEnum<E>::value, |
127 | 0 | "Only categorical label enum types are supported."); |
128 | 0 | nsTArray<uint32_t> intSamples(enumValues.Length()); |
129 | 0 |
|
130 | 0 | for (E aValue: enumValues){ |
131 | 0 | intSamples.AppendElement(static_cast<uint32_t>(aValue)); |
132 | 0 | } |
133 | 0 |
|
134 | 0 | HistogramID categoricalId = static_cast<HistogramID>(CategoricalLabelId<E>::value); |
135 | 0 |
|
136 | 0 | Accumulate(categoricalId, intSamples); |
137 | 0 | } |
138 | | |
139 | | /** |
140 | | * Adds sample to a keyed categorical histogram defined in TelemetryHistogramEnums.h |
141 | | * This is the typesafe - and preferred - way to use the keyed categorical histograms |
142 | | * by passing values from the corresponding Telemetry::LABELS_* enum. |
143 | | * |
144 | | * @param key - the string key |
145 | | * @param enumValue - Label value from one of the Telemetry::LABELS_* enums. |
146 | | */ |
147 | | template<class E> |
148 | 0 | void AccumulateCategoricalKeyed(const nsCString& key, E enumValue) { |
149 | 0 | static_assert(IsCategoricalLabelEnum<E>::value, |
150 | 0 | "Only categorical label enum types are supported."); |
151 | 0 | Accumulate(static_cast<HistogramID>(CategoricalLabelId<E>::value), |
152 | 0 | key, |
153 | 0 | static_cast<uint32_t>(enumValue)); |
154 | 0 | }; Unexecuted instantiation: void mozilla::Telemetry::AccumulateCategoricalKeyed<mozilla::Telemetry::LABELS_NETWORK_HTTP_REDIRECT_TO_SCHEME>(nsTString<char> const&, mozilla::Telemetry::LABELS_NETWORK_HTTP_REDIRECT_TO_SCHEME) Unexecuted instantiation: void mozilla::Telemetry::AccumulateCategoricalKeyed<mozilla::Telemetry::LABELS_HTTP_CHILD_OMT_STATS>(nsTString<char> const&, mozilla::Telemetry::LABELS_HTTP_CHILD_OMT_STATS) Unexecuted instantiation: void mozilla::Telemetry::AccumulateCategoricalKeyed<mozilla::Telemetry::LABELS_HTTP_CHANNEL_DISPOSITION_UPGRADE>(nsTString<char> const&, mozilla::Telemetry::LABELS_HTTP_CHANNEL_DISPOSITION_UPGRADE) Unexecuted instantiation: void mozilla::Telemetry::AccumulateCategoricalKeyed<mozilla::Telemetry::LABELS_CONTENT_SIGNATURE_VERIFICATION_ERRORS>(nsTString<char> const&, mozilla::Telemetry::LABELS_CONTENT_SIGNATURE_VERIFICATION_ERRORS) Unexecuted instantiation: void mozilla::Telemetry::AccumulateCategoricalKeyed<mozilla::Telemetry::LABELS_TELEMETRY_TEST_KEYED_CATEGORICAL>(nsTString<char> const&, mozilla::Telemetry::LABELS_TELEMETRY_TEST_KEYED_CATEGORICAL) |
155 | | |
156 | | /** |
157 | | * Adds an array of samples to a keyed categorical histogram defined in TelemetryHistogramEnums.h. |
158 | | * This is the typesafe - and preferred - way to use the keyed categorical histograms |
159 | | * by passing values from the corresponding Telemetry::LABELS_*enum. |
160 | | * |
161 | | * @param key - the string key |
162 | | * @param enumValue - Label value from one of the Telemetry::LABELS_* enums. |
163 | | */ |
164 | | template<class E> |
165 | 0 | void AccumulateCategoricalKeyed(const nsCString& key, const nsTArray<E>& enumValues) { |
166 | 0 | static_assert(IsCategoricalLabelEnum<E>::value, |
167 | 0 | "Only categorical label enum types are supported."); |
168 | 0 | nsTArray<uint32_t> intSamples(enumValues.Length()); |
169 | 0 |
|
170 | 0 | for (E aValue: enumValues){ |
171 | 0 | intSamples.AppendElement(static_cast<uint32_t>(aValue)); |
172 | 0 | } |
173 | 0 |
|
174 | 0 | Accumulate(static_cast<HistogramID>(CategoricalLabelId<E>::value), |
175 | 0 | key, |
176 | 0 | intSamples); |
177 | 0 | }; |
178 | | |
179 | | /** |
180 | | * Adds sample to a categorical histogram defined in TelemetryHistogramEnums.h |
181 | | * This string will be matched against the labels defined in Histograms.json. |
182 | | * If the string does not match a label defined for the histogram, nothing will |
183 | | * be recorded. |
184 | | * |
185 | | * @param id - The histogram id. |
186 | | * @param label - A string label value that is defined in Histograms.json for this histogram. |
187 | | */ |
188 | | void AccumulateCategorical(HistogramID id, const nsCString& label); |
189 | | |
190 | | /** |
191 | | * Adds an array of samples to a categorical histogram defined in Histograms.json |
192 | | * |
193 | | * @param id - The histogram id |
194 | | * @param labels - The array of labels to accumulate |
195 | | */ |
196 | | void AccumulateCategorical(HistogramID id, const nsTArray<nsCString>& labels); |
197 | | |
198 | | /** |
199 | | * Adds time delta in milliseconds to a histogram defined in TelemetryHistogramEnums.h |
200 | | * |
201 | | * @param id - histogram id |
202 | | * @param start - start time |
203 | | * @param end - end time |
204 | | */ |
205 | | void AccumulateTimeDelta(HistogramID id, TimeStamp start, TimeStamp end = TimeStamp::Now()); |
206 | | |
207 | | /** |
208 | | * Adds time delta in milliseconds to a keyed histogram defined in |
209 | | * TelemetryHistogramEnums.h |
210 | | * |
211 | | * @param id - histogram id |
212 | | * @param key - the string key |
213 | | * @param start - start time |
214 | | * @param end - end time |
215 | | */ |
216 | | void |
217 | | AccumulateTimeDelta(HistogramID id, |
218 | | const nsCString& key, |
219 | | TimeStamp start, |
220 | | TimeStamp end = TimeStamp::Now()); |
221 | | |
222 | | /** |
223 | | * Enable/disable recording for this histogram in this process at runtime. |
224 | | * Recording is enabled by default, unless listed at |
225 | | * kRecordingInitiallyDisabledIDs[]. id must be a valid telemetry enum, |
226 | | * |
227 | | * @param id - histogram id |
228 | | * @param enabled - whether or not to enable recording from now on. |
229 | | */ |
230 | | void SetHistogramRecordingEnabled(HistogramID id, bool enabled); |
231 | | |
232 | | const char* GetHistogramName(HistogramID id); |
233 | | |
234 | | class MOZ_RAII RuntimeAutoTimer |
235 | | { |
236 | | public: |
237 | | explicit RuntimeAutoTimer(Telemetry::HistogramID aId, |
238 | | TimeStamp aStart = TimeStamp::Now() |
239 | | MOZ_GUARD_OBJECT_NOTIFIER_PARAM) |
240 | | : id(aId) |
241 | | , start(aStart) |
242 | 0 | { |
243 | 0 | MOZ_GUARD_OBJECT_NOTIFIER_INIT; |
244 | 0 | } |
245 | | explicit RuntimeAutoTimer(Telemetry::HistogramID aId, |
246 | | const nsCString& aKey, |
247 | | TimeStamp aStart = TimeStamp::Now() |
248 | | MOZ_GUARD_OBJECT_NOTIFIER_PARAM) |
249 | | : id(aId) |
250 | | , key(aKey) |
251 | | , start(aStart) |
252 | 0 | { |
253 | 0 | MOZ_ASSERT(!aKey.IsEmpty(), "The key must not be empty."); |
254 | 0 | MOZ_GUARD_OBJECT_NOTIFIER_INIT; |
255 | 0 | } |
256 | | |
257 | | ~RuntimeAutoTimer() |
258 | 0 | { |
259 | 0 | if (key.IsEmpty()) { |
260 | 0 | AccumulateTimeDelta(id, start); |
261 | 0 | } else { |
262 | 0 | AccumulateTimeDelta(id, key, start); |
263 | 0 | } |
264 | 0 | } |
265 | | |
266 | | private: |
267 | | Telemetry::HistogramID id; |
268 | | const nsCString key; |
269 | | const TimeStamp start; |
270 | | MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER |
271 | | }; |
272 | | |
273 | | template<HistogramID id> |
274 | | class MOZ_RAII AutoTimer |
275 | | { |
276 | | public: |
277 | | explicit AutoTimer(TimeStamp aStart = TimeStamp::Now() MOZ_GUARD_OBJECT_NOTIFIER_PARAM) |
278 | | : start(aStart) |
279 | 0 | { |
280 | 0 | MOZ_GUARD_OBJECT_NOTIFIER_INIT; |
281 | 0 | } Unexecuted instantiation: mozilla::Telemetry::AutoTimer<(mozilla::Telemetry::HistogramID)467>::AutoTimer(mozilla::TimeStamp) Unexecuted instantiation: mozilla::Telemetry::AutoTimer<(mozilla::Telemetry::HistogramID)505>::AutoTimer(mozilla::TimeStamp) Unexecuted instantiation: mozilla::Telemetry::AutoTimer<(mozilla::Telemetry::HistogramID)507>::AutoTimer(mozilla::TimeStamp) Unexecuted instantiation: mozilla::Telemetry::AutoTimer<(mozilla::Telemetry::HistogramID)504>::AutoTimer(mozilla::TimeStamp) Unexecuted instantiation: mozilla::Telemetry::AutoTimer<(mozilla::Telemetry::HistogramID)287>::AutoTimer(mozilla::TimeStamp) Unexecuted instantiation: mozilla::Telemetry::AutoTimer<(mozilla::Telemetry::HistogramID)503>::AutoTimer(mozilla::TimeStamp) Unexecuted instantiation: mozilla::Telemetry::AutoTimer<(mozilla::Telemetry::HistogramID)502>::AutoTimer(mozilla::TimeStamp) Unexecuted instantiation: mozilla::Telemetry::AutoTimer<(mozilla::Telemetry::HistogramID)289>::AutoTimer(mozilla::TimeStamp) Unexecuted instantiation: mozilla::Telemetry::AutoTimer<(mozilla::Telemetry::HistogramID)501>::AutoTimer(mozilla::TimeStamp) Unexecuted instantiation: mozilla::Telemetry::AutoTimer<(mozilla::Telemetry::HistogramID)290>::AutoTimer(mozilla::TimeStamp) Unexecuted instantiation: mozilla::Telemetry::AutoTimer<(mozilla::Telemetry::HistogramID)288>::AutoTimer(mozilla::TimeStamp) Unexecuted instantiation: mozilla::Telemetry::AutoTimer<(mozilla::Telemetry::HistogramID)506>::AutoTimer(mozilla::TimeStamp) Unexecuted instantiation: mozilla::Telemetry::AutoTimer<(mozilla::Telemetry::HistogramID)508>::AutoTimer(mozilla::TimeStamp) Unexecuted instantiation: mozilla::Telemetry::AutoTimer<(mozilla::Telemetry::HistogramID)459>::AutoTimer(mozilla::TimeStamp) Unexecuted instantiation: mozilla::Telemetry::AutoTimer<(mozilla::Telemetry::HistogramID)461>::AutoTimer(mozilla::TimeStamp) Unexecuted instantiation: mozilla::Telemetry::AutoTimer<(mozilla::Telemetry::HistogramID)498>::AutoTimer(mozilla::TimeStamp) Unexecuted instantiation: mozilla::Telemetry::AutoTimer<(mozilla::Telemetry::HistogramID)736>::AutoTimer(mozilla::TimeStamp) Unexecuted instantiation: mozilla::Telemetry::AutoTimer<(mozilla::Telemetry::HistogramID)457>::AutoTimer(mozilla::TimeStamp) Unexecuted instantiation: mozilla::Telemetry::AutoTimer<(mozilla::Telemetry::HistogramID)452>::AutoTimer(mozilla::TimeStamp) Unexecuted instantiation: mozilla::Telemetry::AutoTimer<(mozilla::Telemetry::HistogramID)458>::AutoTimer(mozilla::TimeStamp) Unexecuted instantiation: mozilla::Telemetry::AutoTimer<(mozilla::Telemetry::HistogramID)1423>::AutoTimer(mozilla::TimeStamp) Unexecuted instantiation: mozilla::Telemetry::AutoTimer<(mozilla::Telemetry::HistogramID)510>::AutoTimer(mozilla::TimeStamp) Unexecuted instantiation: mozilla::Telemetry::AutoTimer<(mozilla::Telemetry::HistogramID)5>::AutoTimer(mozilla::TimeStamp) Unexecuted instantiation: mozilla::Telemetry::AutoTimer<(mozilla::Telemetry::HistogramID)520>::AutoTimer(mozilla::TimeStamp) Unexecuted instantiation: mozilla::Telemetry::AutoTimer<(mozilla::Telemetry::HistogramID)521>::AutoTimer(mozilla::TimeStamp) Unexecuted instantiation: mozilla::Telemetry::AutoTimer<(mozilla::Telemetry::HistogramID)517>::AutoTimer(mozilla::TimeStamp) Unexecuted instantiation: mozilla::Telemetry::AutoTimer<(mozilla::Telemetry::HistogramID)518>::AutoTimer(mozilla::TimeStamp) Unexecuted instantiation: mozilla::Telemetry::AutoTimer<(mozilla::Telemetry::HistogramID)513>::AutoTimer(mozilla::TimeStamp) Unexecuted instantiation: mozilla::Telemetry::AutoTimer<(mozilla::Telemetry::HistogramID)519>::AutoTimer(mozilla::TimeStamp) Unexecuted instantiation: mozilla::Telemetry::AutoTimer<(mozilla::Telemetry::HistogramID)522>::AutoTimer(mozilla::TimeStamp) Unexecuted instantiation: mozilla::Telemetry::AutoTimer<(mozilla::Telemetry::HistogramID)515>::AutoTimer(mozilla::TimeStamp) Unexecuted instantiation: mozilla::Telemetry::AutoTimer<(mozilla::Telemetry::HistogramID)512>::AutoTimer(mozilla::TimeStamp) |
282 | | |
283 | | explicit AutoTimer(const nsCString& aKey, TimeStamp aStart = TimeStamp::Now() MOZ_GUARD_OBJECT_NOTIFIER_PARAM) |
284 | | : start(aStart) |
285 | | , key(aKey) |
286 | 0 | { |
287 | 0 | MOZ_ASSERT(!aKey.IsEmpty(), "The key must not be empty."); |
288 | 0 | MOZ_GUARD_OBJECT_NOTIFIER_INIT; |
289 | 0 | } |
290 | | |
291 | 0 | ~AutoTimer() { |
292 | 0 | if (key.IsEmpty()) { |
293 | 0 | AccumulateTimeDelta(id, start); |
294 | 0 | } else { |
295 | 0 | AccumulateTimeDelta(id, key, start); |
296 | 0 | } |
297 | 0 | } Unexecuted instantiation: mozilla::Telemetry::AutoTimer<(mozilla::Telemetry::HistogramID)467>::~AutoTimer() Unexecuted instantiation: mozilla::Telemetry::AutoTimer<(mozilla::Telemetry::HistogramID)505>::~AutoTimer() Unexecuted instantiation: mozilla::Telemetry::AutoTimer<(mozilla::Telemetry::HistogramID)507>::~AutoTimer() Unexecuted instantiation: mozilla::Telemetry::AutoTimer<(mozilla::Telemetry::HistogramID)504>::~AutoTimer() Unexecuted instantiation: mozilla::Telemetry::AutoTimer<(mozilla::Telemetry::HistogramID)287>::~AutoTimer() Unexecuted instantiation: mozilla::Telemetry::AutoTimer<(mozilla::Telemetry::HistogramID)503>::~AutoTimer() Unexecuted instantiation: mozilla::Telemetry::AutoTimer<(mozilla::Telemetry::HistogramID)502>::~AutoTimer() Unexecuted instantiation: mozilla::Telemetry::AutoTimer<(mozilla::Telemetry::HistogramID)289>::~AutoTimer() Unexecuted instantiation: mozilla::Telemetry::AutoTimer<(mozilla::Telemetry::HistogramID)501>::~AutoTimer() Unexecuted instantiation: mozilla::Telemetry::AutoTimer<(mozilla::Telemetry::HistogramID)290>::~AutoTimer() Unexecuted instantiation: mozilla::Telemetry::AutoTimer<(mozilla::Telemetry::HistogramID)288>::~AutoTimer() Unexecuted instantiation: mozilla::Telemetry::AutoTimer<(mozilla::Telemetry::HistogramID)506>::~AutoTimer() Unexecuted instantiation: mozilla::Telemetry::AutoTimer<(mozilla::Telemetry::HistogramID)508>::~AutoTimer() Unexecuted instantiation: mozilla::Telemetry::AutoTimer<(mozilla::Telemetry::HistogramID)461>::~AutoTimer() Unexecuted instantiation: mozilla::Telemetry::AutoTimer<(mozilla::Telemetry::HistogramID)459>::~AutoTimer() Unexecuted instantiation: mozilla::Telemetry::AutoTimer<(mozilla::Telemetry::HistogramID)498>::~AutoTimer() Unexecuted instantiation: mozilla::Telemetry::AutoTimer<(mozilla::Telemetry::HistogramID)736>::~AutoTimer() Unexecuted instantiation: mozilla::Telemetry::AutoTimer<(mozilla::Telemetry::HistogramID)457>::~AutoTimer() Unexecuted instantiation: mozilla::Telemetry::AutoTimer<(mozilla::Telemetry::HistogramID)452>::~AutoTimer() Unexecuted instantiation: mozilla::Telemetry::AutoTimer<(mozilla::Telemetry::HistogramID)458>::~AutoTimer() Unexecuted instantiation: mozilla::Telemetry::AutoTimer<(mozilla::Telemetry::HistogramID)1423>::~AutoTimer() Unexecuted instantiation: mozilla::Telemetry::AutoTimer<(mozilla::Telemetry::HistogramID)510>::~AutoTimer() Unexecuted instantiation: mozilla::Telemetry::AutoTimer<(mozilla::Telemetry::HistogramID)5>::~AutoTimer() Unexecuted instantiation: mozilla::Telemetry::AutoTimer<(mozilla::Telemetry::HistogramID)520>::~AutoTimer() Unexecuted instantiation: mozilla::Telemetry::AutoTimer<(mozilla::Telemetry::HistogramID)521>::~AutoTimer() Unexecuted instantiation: mozilla::Telemetry::AutoTimer<(mozilla::Telemetry::HistogramID)517>::~AutoTimer() Unexecuted instantiation: mozilla::Telemetry::AutoTimer<(mozilla::Telemetry::HistogramID)518>::~AutoTimer() Unexecuted instantiation: mozilla::Telemetry::AutoTimer<(mozilla::Telemetry::HistogramID)513>::~AutoTimer() Unexecuted instantiation: mozilla::Telemetry::AutoTimer<(mozilla::Telemetry::HistogramID)514>::~AutoTimer() Unexecuted instantiation: mozilla::Telemetry::AutoTimer<(mozilla::Telemetry::HistogramID)519>::~AutoTimer() Unexecuted instantiation: mozilla::Telemetry::AutoTimer<(mozilla::Telemetry::HistogramID)522>::~AutoTimer() Unexecuted instantiation: mozilla::Telemetry::AutoTimer<(mozilla::Telemetry::HistogramID)515>::~AutoTimer() Unexecuted instantiation: mozilla::Telemetry::AutoTimer<(mozilla::Telemetry::HistogramID)512>::~AutoTimer() |
298 | | |
299 | | private: |
300 | | const TimeStamp start; |
301 | | const nsCString key; |
302 | | MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER |
303 | | }; |
304 | | |
305 | | class MOZ_RAII RuntimeAutoCounter |
306 | | { |
307 | | public: |
308 | | explicit RuntimeAutoCounter( |
309 | | HistogramID aId, |
310 | | uint32_t counterStart = 0 MOZ_GUARD_OBJECT_NOTIFIER_PARAM) |
311 | | : id(aId) |
312 | | , counter(counterStart) |
313 | 0 | { |
314 | 0 | MOZ_GUARD_OBJECT_NOTIFIER_INIT; |
315 | 0 | } |
316 | | |
317 | | ~RuntimeAutoCounter() |
318 | 0 | { |
319 | 0 | Accumulate(id, counter); |
320 | 0 | } |
321 | | |
322 | | // Prefix increment only, to encourage good habits. |
323 | | void operator++() |
324 | 0 | { |
325 | 0 | if (NS_WARN_IF(counter == std::numeric_limits<uint32_t>::max())) { |
326 | 0 | return; |
327 | 0 | } |
328 | 0 | ++counter; |
329 | 0 | } |
330 | | |
331 | | // Chaining doesn't make any sense, don't return anything. |
332 | | void operator+=(int increment) |
333 | 0 | { |
334 | 0 | if (NS_WARN_IF(increment > 0 && |
335 | 0 | static_cast<uint32_t>(increment) > |
336 | 0 | (std::numeric_limits<uint32_t>::max() - counter))) { |
337 | 0 | counter = std::numeric_limits<uint32_t>::max(); |
338 | 0 | return; |
339 | 0 | } |
340 | 0 | if (NS_WARN_IF(increment < 0 && |
341 | 0 | static_cast<uint32_t>(-increment) > counter)) { |
342 | 0 | counter = std::numeric_limits<uint32_t>::min(); |
343 | 0 | return; |
344 | 0 | } |
345 | 0 | counter += increment; |
346 | 0 | } |
347 | | |
348 | | private: |
349 | | HistogramID id; |
350 | | uint32_t counter; |
351 | | MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER |
352 | | }; |
353 | | |
354 | | template<HistogramID id> |
355 | | class MOZ_RAII AutoCounter { |
356 | | public: |
357 | | explicit AutoCounter(uint32_t counterStart = 0 MOZ_GUARD_OBJECT_NOTIFIER_PARAM) |
358 | | : counter(counterStart) |
359 | 0 | { |
360 | 0 | MOZ_GUARD_OBJECT_NOTIFIER_INIT; |
361 | 0 | } Unexecuted instantiation: mozilla::Telemetry::AutoCounter<(mozilla::Telemetry::HistogramID)402>::AutoCounter(unsigned int) Unexecuted instantiation: mozilla::Telemetry::AutoCounter<(mozilla::Telemetry::HistogramID)393>::AutoCounter(unsigned int) Unexecuted instantiation: mozilla::Telemetry::AutoCounter<(mozilla::Telemetry::HistogramID)394>::AutoCounter(unsigned int) Unexecuted instantiation: mozilla::Telemetry::AutoCounter<(mozilla::Telemetry::HistogramID)397>::AutoCounter(unsigned int) Unexecuted instantiation: mozilla::Telemetry::AutoCounter<(mozilla::Telemetry::HistogramID)401>::AutoCounter(unsigned int) Unexecuted instantiation: mozilla::Telemetry::AutoCounter<(mozilla::Telemetry::HistogramID)387>::AutoCounter(unsigned int) Unexecuted instantiation: mozilla::Telemetry::AutoCounter<(mozilla::Telemetry::HistogramID)411>::AutoCounter(unsigned int) Unexecuted instantiation: mozilla::Telemetry::AutoCounter<(mozilla::Telemetry::HistogramID)398>::AutoCounter(unsigned int) Unexecuted instantiation: mozilla::Telemetry::AutoCounter<(mozilla::Telemetry::HistogramID)412>::AutoCounter(unsigned int) Unexecuted instantiation: mozilla::Telemetry::AutoCounter<(mozilla::Telemetry::HistogramID)399>::AutoCounter(unsigned int) Unexecuted instantiation: mozilla::Telemetry::AutoCounter<(mozilla::Telemetry::HistogramID)413>::AutoCounter(unsigned int) Unexecuted instantiation: mozilla::Telemetry::AutoCounter<(mozilla::Telemetry::HistogramID)400>::AutoCounter(unsigned int) Unexecuted instantiation: mozilla::Telemetry::AutoCounter<(mozilla::Telemetry::HistogramID)799>::AutoCounter(unsigned int) |
362 | | |
363 | 0 | ~AutoCounter() { |
364 | 0 | Accumulate(id, counter); |
365 | 0 | } Unexecuted instantiation: mozilla::Telemetry::AutoCounter<(mozilla::Telemetry::HistogramID)402>::~AutoCounter() Unexecuted instantiation: mozilla::Telemetry::AutoCounter<(mozilla::Telemetry::HistogramID)393>::~AutoCounter() Unexecuted instantiation: mozilla::Telemetry::AutoCounter<(mozilla::Telemetry::HistogramID)394>::~AutoCounter() Unexecuted instantiation: mozilla::Telemetry::AutoCounter<(mozilla::Telemetry::HistogramID)397>::~AutoCounter() Unexecuted instantiation: mozilla::Telemetry::AutoCounter<(mozilla::Telemetry::HistogramID)401>::~AutoCounter() Unexecuted instantiation: mozilla::Telemetry::AutoCounter<(mozilla::Telemetry::HistogramID)387>::~AutoCounter() Unexecuted instantiation: mozilla::Telemetry::AutoCounter<(mozilla::Telemetry::HistogramID)411>::~AutoCounter() Unexecuted instantiation: mozilla::Telemetry::AutoCounter<(mozilla::Telemetry::HistogramID)398>::~AutoCounter() Unexecuted instantiation: mozilla::Telemetry::AutoCounter<(mozilla::Telemetry::HistogramID)412>::~AutoCounter() Unexecuted instantiation: mozilla::Telemetry::AutoCounter<(mozilla::Telemetry::HistogramID)399>::~AutoCounter() Unexecuted instantiation: mozilla::Telemetry::AutoCounter<(mozilla::Telemetry::HistogramID)413>::~AutoCounter() Unexecuted instantiation: mozilla::Telemetry::AutoCounter<(mozilla::Telemetry::HistogramID)400>::~AutoCounter() Unexecuted instantiation: mozilla::Telemetry::AutoCounter<(mozilla::Telemetry::HistogramID)799>::~AutoCounter() |
366 | | |
367 | | // Prefix increment only, to encourage good habits. |
368 | | void operator++() |
369 | 0 | { |
370 | 0 | if (NS_WARN_IF(counter == std::numeric_limits<uint32_t>::max())) { |
371 | 0 | return; |
372 | 0 | } |
373 | 0 | ++counter; |
374 | 0 | } Unexecuted instantiation: mozilla::Telemetry::AutoCounter<(mozilla::Telemetry::HistogramID)402>::operator++() Unexecuted instantiation: mozilla::Telemetry::AutoCounter<(mozilla::Telemetry::HistogramID)393>::operator++() Unexecuted instantiation: mozilla::Telemetry::AutoCounter<(mozilla::Telemetry::HistogramID)394>::operator++() Unexecuted instantiation: mozilla::Telemetry::AutoCounter<(mozilla::Telemetry::HistogramID)397>::operator++() Unexecuted instantiation: mozilla::Telemetry::AutoCounter<(mozilla::Telemetry::HistogramID)401>::operator++() Unexecuted instantiation: mozilla::Telemetry::AutoCounter<(mozilla::Telemetry::HistogramID)387>::operator++() Unexecuted instantiation: mozilla::Telemetry::AutoCounter<(mozilla::Telemetry::HistogramID)411>::operator++() Unexecuted instantiation: mozilla::Telemetry::AutoCounter<(mozilla::Telemetry::HistogramID)398>::operator++() Unexecuted instantiation: mozilla::Telemetry::AutoCounter<(mozilla::Telemetry::HistogramID)412>::operator++() Unexecuted instantiation: mozilla::Telemetry::AutoCounter<(mozilla::Telemetry::HistogramID)399>::operator++() Unexecuted instantiation: mozilla::Telemetry::AutoCounter<(mozilla::Telemetry::HistogramID)413>::operator++() Unexecuted instantiation: mozilla::Telemetry::AutoCounter<(mozilla::Telemetry::HistogramID)400>::operator++() |
375 | | |
376 | | // Chaining doesn't make any sense, don't return anything. |
377 | | void operator+=(int increment) |
378 | 0 | { |
379 | 0 | if (NS_WARN_IF(increment > 0 && |
380 | 0 | static_cast<uint32_t>(increment) > |
381 | 0 | (std::numeric_limits<uint32_t>::max() - counter))) { |
382 | 0 | counter = std::numeric_limits<uint32_t>::max(); |
383 | 0 | return; |
384 | 0 | } |
385 | 0 | if (NS_WARN_IF(increment < 0 && |
386 | 0 | static_cast<uint32_t>(-increment) > counter)) { |
387 | 0 | counter = std::numeric_limits<uint32_t>::min(); |
388 | 0 | return; |
389 | 0 | } |
390 | 0 | counter += increment; |
391 | 0 | } |
392 | | |
393 | | private: |
394 | | uint32_t counter; |
395 | | MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER |
396 | | }; |
397 | | |
398 | | /** |
399 | | * Indicates whether Telemetry base data recording is turned on. Added for future uses. |
400 | | */ |
401 | | bool CanRecordBase(); |
402 | | |
403 | | /** |
404 | | * Indicates whether Telemetry extended data recording is turned on. This is intended |
405 | | * to guard calls to Accumulate when the statistic being recorded is expensive to compute. |
406 | | */ |
407 | | bool CanRecordExtended(); |
408 | | |
409 | | /** |
410 | | * Indicates whether Telemetry release data recording is turned on. Usually true. |
411 | | * |
412 | | * @see nsITelemetry.canRecordReleaseData |
413 | | */ |
414 | | bool CanRecordReleaseData(); |
415 | | |
416 | | /** |
417 | | * Indicates whether Telemetry pre-release data recording is turned on. Tends |
418 | | * to be true on pre-release channels. |
419 | | * |
420 | | * @see nsITelemetry.canRecordPrereleaseData |
421 | | */ |
422 | | bool CanRecordPrereleaseData(); |
423 | | |
424 | | /** |
425 | | * Records slow SQL statements for Telemetry reporting. |
426 | | * |
427 | | * @param statement - offending SQL statement to record |
428 | | * @param dbName - DB filename |
429 | | * @param delay - execution time in milliseconds |
430 | | */ |
431 | | void RecordSlowSQLStatement(const nsACString &statement, |
432 | | const nsACString &dbName, |
433 | | uint32_t delay); |
434 | | |
435 | | /** |
436 | | * Record Webrtc ICE candidate type combinations in a 17bit bitmask |
437 | | * |
438 | | * @param iceCandidateBitmask - the bitmask representing local and remote ICE |
439 | | * candidate types present for the connection |
440 | | * @param success - did the peer connection connected |
441 | | */ |
442 | | void |
443 | | RecordWebrtcIceCandidates(const uint32_t iceCandidateBitmask, |
444 | | const bool success); |
445 | | /** |
446 | | * Initialize I/O Reporting |
447 | | * Initially this only records I/O for files in the binary directory. |
448 | | * |
449 | | * @param aXreDir - XRE directory |
450 | | */ |
451 | | void InitIOReporting(nsIFile* aXreDir); |
452 | | |
453 | | /** |
454 | | * Set the profile directory. Once called, files in the profile directory will |
455 | | * be included in I/O reporting. We can't use the directory |
456 | | * service to obtain this information because it isn't running yet. |
457 | | */ |
458 | | void SetProfileDir(nsIFile* aProfD); |
459 | | |
460 | | /** |
461 | | * Called to inform Telemetry that startup has completed. |
462 | | */ |
463 | | void LeavingStartupStage(); |
464 | | |
465 | | /** |
466 | | * Called to inform Telemetry that shutdown is commencing. |
467 | | */ |
468 | | void EnteringShutdownStage(); |
469 | | |
470 | | /** |
471 | | * Thresholds for a statement to be considered slow, in milliseconds |
472 | | */ |
473 | | const uint32_t kSlowSQLThresholdForMainThread = 50; |
474 | | const uint32_t kSlowSQLThresholdForHelperThreads = 100; |
475 | | |
476 | | class ProcessedStack; |
477 | | |
478 | | /** |
479 | | * Record the main thread's call stack after it hangs. |
480 | | * |
481 | | * @param aDuration - Approximate duration of main thread hang, in seconds |
482 | | * @param aStack - Array of PCs from the hung call stack |
483 | | * @param aSystemUptime - System uptime at the time of the hang, in minutes |
484 | | * @param aFirefoxUptime - Firefox uptime at the time of the hang, in minutes |
485 | | * @param aAnnotations - Any annotations to be added to the report |
486 | | */ |
487 | | #if defined(MOZ_GECKO_PROFILER) |
488 | | /** |
489 | | * Record the current thread's call stack on demand. Note that, the stack is |
490 | | * only captured once. Subsequent calls result in incrementing the capture |
491 | | * counter. |
492 | | * |
493 | | * @param aKey - A user defined key associated with the captured stack. |
494 | | * |
495 | | * NOTE: Unwinding call stacks is an expensive operation performance-wise. |
496 | | */ |
497 | | void CaptureStack(const nsCString& aKey); |
498 | | #endif |
499 | | |
500 | | /** |
501 | | * Record a failed attempt at locking the user's profile. |
502 | | * |
503 | | * @param aProfileDir The profile directory whose lock attempt failed |
504 | | */ |
505 | | void WriteFailedProfileLock(nsIFile* aProfileDir); |
506 | | |
507 | | /** |
508 | | * Adds the value to the given scalar. |
509 | | * |
510 | | * @param aId The scalar enum id. |
511 | | * @param aValue The value to add to the scalar. |
512 | | */ |
513 | | void ScalarAdd(mozilla::Telemetry::ScalarID aId, uint32_t aValue); |
514 | | |
515 | | /** |
516 | | * Sets the scalar to the given value. |
517 | | * |
518 | | * @param aId The scalar enum id. |
519 | | * @param aValue The value to set the scalar to. |
520 | | */ |
521 | | void ScalarSet(mozilla::Telemetry::ScalarID aId, uint32_t aValue); |
522 | | |
523 | | /** |
524 | | * Sets the scalar to the given value. |
525 | | * |
526 | | * @param aId The scalar enum id. |
527 | | * @param aValue The value to set the scalar to. |
528 | | */ |
529 | | void ScalarSet(mozilla::Telemetry::ScalarID aId, bool aValue); |
530 | | |
531 | | /** |
532 | | * Sets the scalar to the given value. |
533 | | * |
534 | | * @param aId The scalar enum id. |
535 | | * @param aValue The value to set the scalar to, truncated to |
536 | | * 50 characters if exceeding that length. |
537 | | */ |
538 | | void ScalarSet(mozilla::Telemetry::ScalarID aId, const nsAString& aValue); |
539 | | |
540 | | /** |
541 | | * Sets the scalar to the maximum of the current and the passed value. |
542 | | * |
543 | | * @param aId The scalar enum id. |
544 | | * @param aValue The value the scalar is set to if its greater |
545 | | * than the current value. |
546 | | */ |
547 | | void ScalarSetMaximum(mozilla::Telemetry::ScalarID aId, uint32_t aValue); |
548 | | |
549 | | /** |
550 | | * Adds the value to the given scalar. |
551 | | * |
552 | | * @param aId The scalar enum id. |
553 | | * @param aKey The scalar key. |
554 | | * @param aValue The value to add to the scalar. |
555 | | */ |
556 | | void ScalarAdd(mozilla::Telemetry::ScalarID aId, const nsAString& aKey, uint32_t aValue); |
557 | | |
558 | | /** |
559 | | * Sets the scalar to the given value. |
560 | | * |
561 | | * @param aId The scalar enum id. |
562 | | * @param aKey The scalar key. |
563 | | * @param aValue The value to set the scalar to. |
564 | | */ |
565 | | void ScalarSet(mozilla::Telemetry::ScalarID aId, const nsAString& aKey, uint32_t aValue); |
566 | | |
567 | | /** |
568 | | * Sets the scalar to the given value. |
569 | | * |
570 | | * @param aId The scalar enum id. |
571 | | * @param aKey The scalar key. |
572 | | * @param aValue The value to set the scalar to. |
573 | | */ |
574 | | void ScalarSet(mozilla::Telemetry::ScalarID aId, const nsAString& aKey, bool aValue); |
575 | | |
576 | | /** |
577 | | * Sets the scalar to the maximum of the current and the passed value. |
578 | | * |
579 | | * @param aId The scalar enum id. |
580 | | * @param aKey The scalar key. |
581 | | * @param aValue The value the scalar is set to if its greater |
582 | | * than the current value. |
583 | | */ |
584 | | void ScalarSetMaximum(mozilla::Telemetry::ScalarID aId, const nsAString& aKey, uint32_t aValue); |
585 | | |
586 | | } // namespace Telemetry |
587 | | } // namespace mozilla |
588 | | |
589 | | #endif // Telemetry_h__ |