Krzysztof Grobelny | c8e3a64 | 2020-10-23 12:29:16 +0200 | [diff] [blame] | 1 | #pragma once |
| 2 | |
Michal Orzel | b3e03d2 | 2024-06-28 13:55:47 +0200 | [diff] [blame] | 3 | #include "helpers.hpp" |
Wludzik, Jozef | e236279 | 2020-10-27 17:23:55 +0100 | [diff] [blame] | 4 | #include "report_manager.hpp" |
Krzysztof Grobelny | dcc4e19 | 2021-03-08 09:09:34 +0000 | [diff] [blame] | 5 | #include "types/report_types.hpp" |
Wludzik, Jozef | e236279 | 2020-10-27 17:23:55 +0100 | [diff] [blame] | 6 | |
Krzysztof Grobelny | c8e3a64 | 2020-10-23 12:29:16 +0200 | [diff] [blame] | 7 | #include <chrono> |
| 8 | #include <string> |
| 9 | |
| 10 | class ReportParams final |
| 11 | { |
| 12 | public: |
Szymon Dompke | 32305f1 | 2022-07-05 15:37:21 +0200 | [diff] [blame] | 13 | ReportParams& reportId(std::string_view val) |
Krzysztof Grobelny | b8cc78d | 2021-11-29 15:54:53 +0100 | [diff] [blame] | 14 | { |
Szymon Dompke | 32305f1 | 2022-07-05 15:37:21 +0200 | [diff] [blame] | 15 | reportIdProperty = val; |
Krzysztof Grobelny | b8cc78d | 2021-11-29 15:54:53 +0100 | [diff] [blame] | 16 | return *this; |
| 17 | } |
| 18 | |
| 19 | const std::string& reportId() const |
| 20 | { |
| 21 | return reportIdProperty; |
| 22 | } |
| 23 | |
Szymon Dompke | 32305f1 | 2022-07-05 15:37:21 +0200 | [diff] [blame] | 24 | ReportParams& reportName(std::string_view val) |
Krzysztof Grobelny | c8e3a64 | 2020-10-23 12:29:16 +0200 | [diff] [blame] | 25 | { |
Szymon Dompke | 32305f1 | 2022-07-05 15:37:21 +0200 | [diff] [blame] | 26 | reportNameProperty = val; |
Krzysztof Grobelny | c8e3a64 | 2020-10-23 12:29:16 +0200 | [diff] [blame] | 27 | return *this; |
| 28 | } |
| 29 | |
| 30 | const std::string& reportName() const |
| 31 | { |
| 32 | return reportNameProperty; |
| 33 | } |
| 34 | |
Krzysztof Grobelny | 51497a0 | 2021-11-09 14:56:22 +0100 | [diff] [blame] | 35 | ReportParams& reportingType(const ReportingType val) |
Krzysztof Grobelny | c8e3a64 | 2020-10-23 12:29:16 +0200 | [diff] [blame] | 36 | { |
Krzysztof Grobelny | 51497a0 | 2021-11-09 14:56:22 +0100 | [diff] [blame] | 37 | reportingTypeProperty = val; |
Krzysztof Grobelny | c8e3a64 | 2020-10-23 12:29:16 +0200 | [diff] [blame] | 38 | return *this; |
| 39 | } |
| 40 | |
Krzysztof Grobelny | 51497a0 | 2021-11-09 14:56:22 +0100 | [diff] [blame] | 41 | ReportingType reportingType() const |
Krzysztof Grobelny | c8e3a64 | 2020-10-23 12:29:16 +0200 | [diff] [blame] | 42 | { |
| 43 | return reportingTypeProperty; |
| 44 | } |
| 45 | |
Krzysztof Grobelny | 51497a0 | 2021-11-09 14:56:22 +0100 | [diff] [blame] | 46 | ReportParams& reportActions(std::vector<ReportAction> val) |
Wludzik, Jozef | e236279 | 2020-10-27 17:23:55 +0100 | [diff] [blame] | 47 | { |
Krzysztof Grobelny | 51497a0 | 2021-11-09 14:56:22 +0100 | [diff] [blame] | 48 | reportActionsProperty = std::move(val); |
Wludzik, Jozef | e236279 | 2020-10-27 17:23:55 +0100 | [diff] [blame] | 49 | return *this; |
| 50 | } |
| 51 | |
Krzysztof Grobelny | 51497a0 | 2021-11-09 14:56:22 +0100 | [diff] [blame] | 52 | std::vector<ReportAction> reportActions() const |
Wludzik, Jozef | e236279 | 2020-10-27 17:23:55 +0100 | [diff] [blame] | 53 | { |
Krzysztof Grobelny | 51497a0 | 2021-11-09 14:56:22 +0100 | [diff] [blame] | 54 | return reportActionsProperty; |
Wludzik, Jozef | e236279 | 2020-10-27 17:23:55 +0100 | [diff] [blame] | 55 | } |
| 56 | |
Krzysztof Grobelny | dcc4e19 | 2021-03-08 09:09:34 +0000 | [diff] [blame] | 57 | ReportParams& interval(Milliseconds val) |
Wludzik, Jozef | e236279 | 2020-10-27 17:23:55 +0100 | [diff] [blame] | 58 | { |
| 59 | intervalProperty = val; |
| 60 | return *this; |
| 61 | } |
| 62 | |
Krzysztof Grobelny | dcc4e19 | 2021-03-08 09:09:34 +0000 | [diff] [blame] | 63 | Milliseconds interval() const |
Wludzik, Jozef | e236279 | 2020-10-27 17:23:55 +0100 | [diff] [blame] | 64 | { |
| 65 | return intervalProperty; |
| 66 | } |
| 67 | |
Lukasz Kazmierczak | 7e098e9 | 2021-09-16 15:59:56 +0200 | [diff] [blame] | 68 | ReportParams& enabled(bool val) |
| 69 | { |
| 70 | enabledProperty = val; |
| 71 | return *this; |
| 72 | } |
| 73 | |
| 74 | bool enabled() const |
| 75 | { |
| 76 | return enabledProperty; |
| 77 | } |
| 78 | |
Szymon Dompke | 3eb5686 | 2021-09-20 15:32:04 +0200 | [diff] [blame] | 79 | ReportParams& appendLimit(uint64_t val) |
| 80 | { |
| 81 | appendLimitProperty = val; |
| 82 | return *this; |
| 83 | } |
| 84 | |
| 85 | uint64_t appendLimit() const |
| 86 | { |
| 87 | return appendLimitProperty; |
| 88 | } |
| 89 | |
Krzysztof Grobelny | 51497a0 | 2021-11-09 14:56:22 +0100 | [diff] [blame] | 90 | ReportParams& reportUpdates(ReportUpdates val) |
Szymon Dompke | 3eb5686 | 2021-09-20 15:32:04 +0200 | [diff] [blame] | 91 | { |
| 92 | reportUpdatesProperty = val; |
| 93 | return *this; |
| 94 | } |
| 95 | |
Krzysztof Grobelny | 51497a0 | 2021-11-09 14:56:22 +0100 | [diff] [blame] | 96 | ReportUpdates reportUpdates() const |
Szymon Dompke | 3eb5686 | 2021-09-20 15:32:04 +0200 | [diff] [blame] | 97 | { |
| 98 | return reportUpdatesProperty; |
| 99 | } |
| 100 | |
Krzysztof Grobelny | dcc4e19 | 2021-03-08 09:09:34 +0000 | [diff] [blame] | 101 | ReportParams& metricParameters(std::vector<LabeledMetricParameters> val) |
Wludzik, Jozef | e236279 | 2020-10-27 17:23:55 +0100 | [diff] [blame] | 102 | { |
Krzysztof Grobelny | dcc4e19 | 2021-03-08 09:09:34 +0000 | [diff] [blame] | 103 | metricParametersProperty = std::move(val); |
Wludzik, Jozef | e236279 | 2020-10-27 17:23:55 +0100 | [diff] [blame] | 104 | return *this; |
| 105 | } |
| 106 | |
Krzysztof Grobelny | dcc4e19 | 2021-03-08 09:09:34 +0000 | [diff] [blame] | 107 | const std::vector<LabeledMetricParameters>& metricParameters() const |
Wludzik, Jozef | e236279 | 2020-10-27 17:23:55 +0100 | [diff] [blame] | 108 | { |
Krzysztof Grobelny | dcc4e19 | 2021-03-08 09:09:34 +0000 | [diff] [blame] | 109 | return metricParametersProperty; |
Wludzik, Jozef | e236279 | 2020-10-27 17:23:55 +0100 | [diff] [blame] | 110 | } |
| 111 | |
Krzysztof Grobelny | 493e62e | 2022-02-14 10:55:50 +0100 | [diff] [blame] | 112 | ReportParams& readings(Readings val) |
| 113 | { |
| 114 | readingsProperty = std::move(val); |
| 115 | return *this; |
| 116 | } |
| 117 | |
| 118 | Readings readings() const |
| 119 | { |
| 120 | return readingsProperty; |
| 121 | } |
| 122 | |
Michal Orzel | b3e03d2 | 2024-06-28 13:55:47 +0200 | [diff] [blame] | 123 | friend void PrintTo(const ReportParams& params, std::ostream* os) |
| 124 | { |
| 125 | *os << "{ Id: \"" << params.reportIdProperty << "\", Name: \"" |
| 126 | << params.reportNameProperty << "\", ReportingType: \"" |
| 127 | << utils::enumToString(params.reportingTypeProperty) |
| 128 | << "\", ReportActions: "; |
| 129 | PrintTo(params.reportActionsProperty, os); |
| 130 | *os << ", Interval: " << params.intervalProperty |
| 131 | << ", Enabled: " << params.enabledProperty |
| 132 | << ", AppendLimit: " << std::to_string(params.appendLimitProperty) |
| 133 | << ", ReportUpdates: \"" |
| 134 | << utils::enumToString(params.reportUpdatesProperty) |
| 135 | << "\", MetricParameters: "; |
| 136 | PrintTo(params.metricParametersProperty, os); |
| 137 | *os << ", Readings: "; |
| 138 | PrintTo(params.readingsProperty, os); |
| 139 | *os << " }"; |
| 140 | } |
| 141 | |
Wludzik, Jozef | e236279 | 2020-10-27 17:23:55 +0100 | [diff] [blame] | 142 | private: |
Krzysztof Grobelny | b8cc78d | 2021-11-29 15:54:53 +0100 | [diff] [blame] | 143 | std::string reportIdProperty = "TestId"; |
Krzysztof Grobelny | c8e3a64 | 2020-10-23 12:29:16 +0200 | [diff] [blame] | 144 | std::string reportNameProperty = "TestReport"; |
Krzysztof Grobelny | 973b4bb | 2022-04-25 17:07:27 +0200 | [diff] [blame] | 145 | ReportingType reportingTypeProperty = ReportingType::onChange; |
Szymon Dompke | fdb06a1 | 2022-02-11 11:04:44 +0100 | [diff] [blame] | 146 | std::vector<ReportAction> reportActionsProperty = { |
| 147 | ReportAction::logToMetricReportsCollection}; |
Krzysztof Grobelny | 973b4bb | 2022-04-25 17:07:27 +0200 | [diff] [blame] | 148 | Milliseconds intervalProperty{}; |
Szymon Dompke | 3eb5686 | 2021-09-20 15:32:04 +0200 | [diff] [blame] | 149 | uint64_t appendLimitProperty = 123; |
Krzysztof Grobelny | 51497a0 | 2021-11-09 14:56:22 +0100 | [diff] [blame] | 150 | ReportUpdates reportUpdatesProperty = ReportUpdates::overwrite; |
Krzysztof Grobelny | dcc4e19 | 2021-03-08 09:09:34 +0000 | [diff] [blame] | 151 | std::vector<LabeledMetricParameters> metricParametersProperty{ |
| 152 | {LabeledMetricParameters{ |
Szymon Dompke | 94f71c5 | 2021-12-10 07:16:33 +0100 | [diff] [blame] | 153 | {LabeledSensorInfo{"Service", |
| 154 | "/xyz/openbmc_project/sensors/power/p1", |
| 155 | "metadata1"}}, |
Krzysztof Grobelny | 60fee07 | 2022-01-13 16:25:04 +0100 | [diff] [blame] | 156 | OperationType::avg, |
Krzysztof Grobelny | dcc4e19 | 2021-03-08 09:09:34 +0000 | [diff] [blame] | 157 | CollectionTimeScope::point, |
| 158 | CollectionDuration(Milliseconds(0u))}, |
| 159 | LabeledMetricParameters{ |
Szymon Dompke | 94f71c5 | 2021-12-10 07:16:33 +0100 | [diff] [blame] | 160 | {LabeledSensorInfo{"Service", |
| 161 | "/xyz/openbmc_project/sensors/power/p2", |
| 162 | "metadata2"}}, |
Krzysztof Grobelny | 60fee07 | 2022-01-13 16:25:04 +0100 | [diff] [blame] | 163 | OperationType::avg, |
Krzysztof Grobelny | dcc4e19 | 2021-03-08 09:09:34 +0000 | [diff] [blame] | 164 | CollectionTimeScope::point, |
| 165 | CollectionDuration(Milliseconds(0u))}}}; |
Lukasz Kazmierczak | 7e098e9 | 2021-09-16 15:59:56 +0200 | [diff] [blame] | 166 | bool enabledProperty = true; |
Krzysztof Grobelny | 493e62e | 2022-02-14 10:55:50 +0100 | [diff] [blame] | 167 | Readings readingsProperty = {}; |
Krzysztof Grobelny | d223819 | 2020-12-02 09:27:28 +0000 | [diff] [blame] | 168 | }; |