OLD | NEW |
1 // Copyright 2016 The Crashpad Authors. All rights reserved. | 1 // Copyright 2016 The Crashpad Authors. All rights reserved. |
2 // | 2 // |
3 // Licensed under the Apache License, Version 2.0 (the "License"); | 3 // Licensed under the Apache License, Version 2.0 (the "License"); |
4 // you may not use this file except in compliance with the License. | 4 // you may not use this file except in compliance with the License. |
5 // You may obtain a copy of the License at | 5 // You may obtain a copy of the License at |
6 // | 6 // |
7 // http://www.apache.org/licenses/LICENSE-2.0 | 7 // http://www.apache.org/licenses/LICENSE-2.0 |
8 // | 8 // |
9 // Unless required by applicable law or agreed to in writing, software | 9 // Unless required by applicable law or agreed to in writing, software |
10 // distributed under the License is distributed on an "AS IS" BASIS, | 10 // distributed under the License is distributed on an "AS IS" BASIS, |
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
12 // See the License for the specific language governing permissions and | 12 // See the License for the specific language governing permissions and |
13 // limitations under the License. | 13 // limitations under the License. |
14 | 14 |
15 #include "util/misc/metrics.h" | 15 #include "util/misc/metrics.h" |
16 | 16 |
17 #include "base/metrics/histogram_macros.h" | 17 #include "base/metrics/histogram_macros.h" |
18 #include "base/metrics/sparse_histogram.h" | 18 #include "base/metrics/sparse_histogram.h" |
19 #include "build/build_config.h" | 19 #include "build/build_config.h" |
20 | 20 |
| 21 #if defined(OS_MACOSX) |
| 22 #define METRICS_OS_NAME "Mac" |
| 23 #elif defined(OS_WIN) |
| 24 #define METRICS_OS_NAME "Win" |
| 25 #elif defined(OS_ANDROID) |
| 26 #define METRICS_OS_NAME "Android" |
| 27 #elif defined(OS_LINUX) |
| 28 #define METRICS_OS_NAME "Linux" |
| 29 #endif |
| 30 |
21 namespace crashpad { | 31 namespace crashpad { |
22 | 32 |
23 namespace { | 33 namespace { |
24 | 34 |
25 //! \brief Metrics values used to track the start and completion of a crash | 35 //! \brief Metrics values used to track the start and completion of a crash |
26 //! handling. These are used as metrics values directly, so | 36 //! handling. These are used as metrics values directly, so |
27 //! enumeration values so new values should always be added at the end. | 37 //! enumeration values so new values should always be added at the end. |
28 enum class ExceptionProcessingState { | 38 enum class ExceptionProcessingState { |
29 //! \brief Logged when exception processing is started. | 39 //! \brief Logged when exception processing is started. |
30 kStarted = 0, | 40 kStarted = 0, |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 // static | 82 // static |
73 void Metrics::ExceptionCaptureResult(CaptureResult result) { | 83 void Metrics::ExceptionCaptureResult(CaptureResult result) { |
74 ExceptionProcessing(ExceptionProcessingState::kFinished); | 84 ExceptionProcessing(ExceptionProcessingState::kFinished); |
75 UMA_HISTOGRAM_ENUMERATION("Crashpad.ExceptionCaptureResult", | 85 UMA_HISTOGRAM_ENUMERATION("Crashpad.ExceptionCaptureResult", |
76 static_cast<int32_t>(result), | 86 static_cast<int32_t>(result), |
77 static_cast<int32_t>(CaptureResult::kMaxValue)); | 87 static_cast<int32_t>(CaptureResult::kMaxValue)); |
78 } | 88 } |
79 | 89 |
80 // static | 90 // static |
81 void Metrics::ExceptionCode(uint32_t exception_code) { | 91 void Metrics::ExceptionCode(uint32_t exception_code) { |
82 #if defined(OS_WIN) | 92 UMA_HISTOGRAM_SPARSE_SLOWLY("Crashpad.ExceptionCode." METRICS_OS_NAME, |
83 static const char kExceptionCodeString[] = "Crashpad.ExceptionCode.Win"; | |
84 #elif defined(OS_MACOSX) | |
85 static const char kExceptionCodeString[] = "Crashpad.ExceptionCode.Mac"; | |
86 #endif | |
87 UMA_HISTOGRAM_SPARSE_SLOWLY(kExceptionCodeString, | |
88 static_cast<int32_t>(exception_code)); | 93 static_cast<int32_t>(exception_code)); |
89 } | 94 } |
90 | 95 |
91 // static | 96 // static |
92 void Metrics::ExceptionEncountered() { | 97 void Metrics::ExceptionEncountered() { |
93 ExceptionProcessing(ExceptionProcessingState::kStarted); | 98 ExceptionProcessing(ExceptionProcessingState::kStarted); |
94 } | 99 } |
95 | 100 |
96 void Metrics::HandlerCrashed(uint32_t exception_code) { | 101 void Metrics::HandlerCrashed(uint32_t exception_code) { |
97 #if defined(OS_WIN) | 102 UMA_HISTOGRAM_SPARSE_SLOWLY( |
98 static const char kExceptionCodeString[] = | 103 "Crashpad.HandlerCrash.ExceptionCode." METRICS_OS_NAME, |
99 "Crashpad.HandlerCrash.ExceptionCode.Win"; | 104 static_cast<int32_t>(exception_code)); |
100 #elif defined(OS_MACOSX) | |
101 static const char kExceptionCodeString[] = | |
102 "Crashpad.HandlerCrash.ExceptionCode.Mac"; | |
103 #endif | |
104 UMA_HISTOGRAM_SPARSE_SLOWLY(kExceptionCodeString, | |
105 static_cast<int32_t>(exception_code)); | |
106 } | 105 } |
107 | 106 |
108 } // namespace crashpad | 107 } // namespace crashpad |
OLD | NEW |