Skip to content

1050: add telemetry tracing to FunctionMinimum #9

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 13 commits into
base: 1050
Choose a base branch
from
31 changes: 31 additions & 0 deletions src/metrics/collection_function.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

#include <cmath>

#include <phosphor-logging/log.hpp>
#include <iostream>
#include <tuple>


namespace metrics
{

Expand All @@ -11,6 +16,30 @@ class FunctionMinimum : public CollectionFunction
double calculate(const std::vector<ReadingItem>& readings,
Milliseconds) const override
{

std::cout << "calculate start" << std::endl;
int i=0;
for (auto kt = std::next(readings.begin()); kt != readings.end();
++kt)
{
const auto& [nextItemTimestamp, nextItemReading] = *(kt);
std::cout << "n=" << i << "kt: " << nextItemTimestamp << " and " << nextItemReading << std::endl;
i++;
}
std::cout << "count=" << i << std::endl;

std::cout << "result=" << std::min_element(
readings.begin(), readings.end(),
[](const auto& left, const auto& right) {
return std::make_tuple(!std::isfinite(left.second),
left.second) <
std::make_tuple(!std::isfinite(right.second),
right.second);
})
->second;
std::cout << std::endl;


return std::min_element(
readings.begin(), readings.end(),
[](const auto& left, const auto& right) {
Expand All @@ -25,6 +54,8 @@ class FunctionMinimum : public CollectionFunction
double calculateForStartupInterval(std::vector<ReadingItem>& readings,
Milliseconds timestamp) const override
{
std::cout << "calculateForStartupInterval: " << timestamp << std::endl;

readings.assign(
{ReadingItem(timestamp, calculate(readings, timestamp))});
return readings.back().second;
Expand Down