|
9 | 9 | // granted to it by virtue of its status as an Intergovernmental Organization |
10 | 10 | // or submit itself to any jurisdiction. |
11 | 11 |
|
| 12 | +#include <fmt/core.h> |
| 13 | +#include <unordered_map> |
12 | 14 | #include <vector> |
13 | 15 | #include <algorithm> |
| 16 | +#include <chrono> |
| 17 | +#include <fmt/format.h> |
| 18 | +#include <fmt/chrono.h> |
14 | 19 |
|
15 | 20 | #include "Framework/ConcreteDataMatcher.h" |
16 | 21 | #include "Framework/InputRecordWalker.h" |
@@ -148,8 +153,31 @@ uint64_t calib_processing_helper::processRawData(o2::framework::InputRecord& inp |
148 | 153 | } |
149 | 154 |
|
150 | 155 | } catch (const std::exception& e) { |
151 | | - LOGP(alarm, "EXCEPTIION in processRawData: {} -> skipping part:{}/{} of spec:{}/{}/{}, size:{}", e.what(), dh->splitPayloadIndex, dh->splitPayloadParts, |
152 | | - dh->dataOrigin, dh->dataDescription, subSpecification, payloadSize); |
| 156 | + // error message throtteling |
| 157 | + using namespace std::literals::chrono_literals; |
| 158 | + static std::unordered_map<uint32_t, size_t> nErrorPerSubspec; |
| 159 | + static std::chrono::time_point<std::chrono::steady_clock> lastReport = std::chrono::steady_clock::now(); |
| 160 | + const auto now = std::chrono::steady_clock::now(); |
| 161 | + static size_t reportedErrors = 0; |
| 162 | + const size_t MAXERRORS = 10; |
| 163 | + const auto sleepTime = 10min; |
| 164 | + ++nErrorPerSubspec[subSpecification]; |
| 165 | + |
| 166 | + if ((now - lastReport) < sleepTime) { |
| 167 | + if (reportedErrors < MAXERRORS) { |
| 168 | + ++reportedErrors; |
| 169 | + std::string sleepInfo; |
| 170 | + if (reportedErrors == MAXERRORS) { |
| 171 | + sleepInfo = fmt::format(", maximum error count ({}) reached, not reporting for the next {}", MAXERRORS, sleepTime); |
| 172 | + } |
| 173 | + LOGP(alarm, "EXCEPTIION in processRawData: {} -> skipping part:{}/{} of spec:{}/{}/{}, size:{}, error count for subspec: {}{}", e.what(), dh->splitPayloadIndex, dh->splitPayloadParts, |
| 174 | + dh->dataOrigin, dh->dataDescription, subSpecification, payloadSize, nErrorPerSubspec.at(subSpecification), sleepInfo); |
| 175 | + lastReport = now; |
| 176 | + } |
| 177 | + } else { |
| 178 | + lastReport = now; |
| 179 | + reportedErrors = 0; |
| 180 | + } |
153 | 181 | errorCount++; |
154 | 182 | continue; |
155 | 183 | } |
|
0 commit comments