Commit 6a330f21 authored by Alessio Netti's avatar Alessio Netti
Browse files

Analytics: added observation counting to Aggregator plugin

- The "observations" operation simply counts the number of total queried
elements over the inputs of each unit
parent c5dadb3f
......@@ -627,7 +627,7 @@ Additionally, output sensors in analyzers of the Aggregator plugin accept the fo
| Value | Explanation |
|:----- |:----------- |
| operation | Operation to be performed over the input sensors. Can be "sum", "average", "maximum", "minimum", "std" or "percentiles".
| operation | Operation to be performed over the input sensors. Can be "sum", "average", "maximum", "minimum", "std", "percentiles" or "observations".
| percentile | Specific percentile to be computed when using the "percentiles" operation. Can be an integer in the (0,100) range.
## Job Aggregator Plugin <a name="jobaveragePlugin"></a>
......
......@@ -88,6 +88,9 @@ void AggregatorAnalyzer::compute_internal(U_Ptr unit, vector<reading_t> *buffer)
case AggregatorSensorBase::STD:
reading.value = computeStd(_buffer);
break;
case AggregatorSensorBase::OBS:
reading.value = computeObs(_buffer);
break;
default:
break;
}
......@@ -105,6 +108,10 @@ void AggregatorAnalyzer::compute_internal(U_Ptr unit, vector<reading_t> *buffer)
}
}
int64_t AggregatorAnalyzer::computeObs(vector<reading_t> *buffer) {
return buffer->size();
}
int64_t AggregatorAnalyzer::computeSum(vector<reading_t> *buffer) {
int64_t acc=0;
for(const auto& v : *buffer)
......
......@@ -60,6 +60,7 @@ protected:
void compute_internal(U_Ptr unit, vector<reading_t> *buffer);
// A separate method for each operation implies code redundancy, but also better efficiency and less useless
// variables used by specific operations lying around
int64_t computeObs(vector<reading_t> *buffer);
int64_t computeSum(vector<reading_t> *buffer);
int64_t computeAvg(vector<reading_t> *buffer);
int64_t computeMax(vector<reading_t> *buffer);
......
......@@ -51,6 +51,8 @@ void AggregatorConfigurator::sensorBase(AggregatorSensorBase& s, CFG_VAL config)
s.setOperation(AggregatorSensorBase::STD);
else if (opName == "percentiles")
s.setOperation(AggregatorSensorBase::QTL);
else if (opName == "observations")
s.setOperation(AggregatorSensorBase::OBS);
} else if (boost::iequals(val.first, "percentile")) {
size_t quantile = stoull(val.second.data());
if( quantile>0 && quantile<100 )
......
......@@ -47,7 +47,7 @@ class AggregatorSensorBase : public SensorBase {
public:
// Enum to identify aggregation operations
enum aggregationOps_t { SUM = 0, AVG = 1, MAX = 2, MIN = 3, STD = 4, QTL = 5 };
enum aggregationOps_t { SUM = 0, AVG = 1, MAX = 2, MIN = 3, STD = 4, QTL = 5, OBS = 6 };
// Constructor and destructor
AggregatorSensorBase(const std::string& name) : SensorBase(name) {
......@@ -100,6 +100,9 @@ protected:
case QTL:
opString = "percentiles";
break;
case OBS:
opString = "observations";
break;
default:
opString = "invalid";
break;
......
......@@ -51,6 +51,8 @@ void JobAggregatorConfigurator::sensorBase(AggregatorSensorBase& s, CFG_VAL conf
s.setOperation(AggregatorSensorBase::STD);
else if (opName == "percentiles")
s.setOperation(AggregatorSensorBase::QTL);
else if (opName == "observations")
s.setOperation(AggregatorSensorBase::OBS);
} else if (boost::iequals(val.first, "percentile")) {
size_t quantile = stoull(val.second.data());
if( quantile>0 && quantile<100 )
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment