1 /* 2 * Copyright (c) 2022 The WebRTC project authors. All Rights Reserved. 3 * 4 * 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. 9 */ 10 11 #ifndef API_TEST_METRICS_METRICS_SET_PROTO_FILE_EXPORTER_H_ 12 #define API_TEST_METRICS_METRICS_SET_PROTO_FILE_EXPORTER_H_ 13 14 #include <string> 15 16 #include "api/array_view.h" 17 #include "api/test/metrics/metric.h" 18 #include "api/test/metrics/metrics_exporter.h" 19 20 namespace webrtc { 21 namespace test { 22 23 // Exports all collected metrics to the proto file using 24 // `webrtc::test_metrics::MetricsSet` format. 25 class MetricsSetProtoFileExporter : public MetricsExporter { 26 public: 27 struct Options { 28 explicit Options(absl::string_view export_file_path); 29 Options(absl::string_view export_file_path, bool export_whole_time_series); 30 31 // File to export proto. 32 std::string export_file_path; 33 // If true will write all time series values to the output proto file, 34 // otherwise will write stats only. 35 bool export_whole_time_series = true; 36 }; 37 MetricsSetProtoFileExporter(const Options & options)38 explicit MetricsSetProtoFileExporter(const Options& options) 39 : options_(options) {} 40 41 MetricsSetProtoFileExporter(const MetricsSetProtoFileExporter&) = delete; 42 MetricsSetProtoFileExporter& operator=(const MetricsSetProtoFileExporter&) = 43 delete; 44 45 bool Export(rtc::ArrayView<const Metric> metrics) override; 46 47 private: 48 const Options options_; 49 }; 50 51 } // namespace test 52 } // namespace webrtc 53 54 #endif // API_TEST_METRICS_METRICS_SET_PROTO_FILE_EXPORTER_H_ 55