1 /* 2 * Copyright (C) 2021 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #ifndef ART_ODREFRESH_ODR_METRICS_RECORD_H_ 18 #define ART_ODREFRESH_ODR_METRICS_RECORD_H_ 19 20 #include <cstdint> 21 #include <iosfwd> // For forward-declaration of std::string. 22 23 namespace art { 24 namespace odrefresh { 25 26 // Default location for storing metrics from odrefresh. 27 constexpr const char* kOdrefreshMetricsFile = "/data/misc/odrefresh/odrefresh-metrics.txt"; 28 29 // MetricsRecord is a simpler container for Odrefresh metric values reported to statsd. The order 30 // and types of fields here mirror definition of `OdrefreshReported` in 31 // frameworks/proto_logging/stats/atoms.proto. 32 struct OdrMetricsRecord { 33 int64_t art_apex_version; 34 int32_t trigger; 35 int32_t stage_reached; 36 int32_t status; 37 int32_t primary_bcp_compilation_seconds; 38 int32_t secondary_bcp_compilation_seconds; 39 int32_t system_server_compilation_seconds; 40 int32_t cache_space_free_start_mib; 41 int32_t cache_space_free_end_mib; 42 }; 43 44 // Read a `MetricsRecord` from an `istream`. 45 // 46 // This method blocks istream related exceptions, the caller should check `is.fail()` is false after 47 // calling. 48 // 49 // Returns `is`. 50 std::istream& operator>>(std::istream& is, OdrMetricsRecord& record); 51 52 // Write a `MetricsRecord` to an `ostream`. 53 // 54 // This method blocks ostream related exceptions, the caller should check `os.fail()` is false after 55 // calling. 56 // 57 // Returns `os` 58 std::ostream& operator<<(std::ostream& os, const OdrMetricsRecord& record); 59 60 } // namespace odrefresh 61 } // namespace art 62 63 #endif // ART_ODREFRESH_ODR_METRICS_RECORD_H_ 64