blob: e9e87f3b8443996f0a910e7ead50e6b60bcf0142 [file] [log] [blame]
#ifndef THIRD_PARTY_MILOTIC_EXTERNAL_CC_TLBMC_COLLECTOR_COLLECTOR_H_
#define THIRD_PARTY_MILOTIC_EXTERNAL_CC_TLBMC_COLLECTOR_COLLECTOR_H_
#include <climits>
#include <cstdint>
#include <string>
#include "absl/status/status.h"
#include "nlohmann/json.hpp"
namespace milotic_tlbmc {
// Interface for collecting telemetry data.
// Each concrete collector shall be responsible for collecting telemetry data
// for a specific resource type.
// Example: FruCollector collects FRU data, SensorCollector collects sensor
// data etc.
// Collected data shall be written to the data store or stored locally
class Collector {
public:
enum class Type : uint8_t {
kFru = 0,
kSensor,
};
// Config parameters for the collector.
struct Config {
// The sampling interval of the collector.
int sampling_interval_ms = INT_MIN;
int max_batch_size = INT_MIN;
// The key of the resource to be collected.
std::string key;
};
virtual ~Collector() = default;
virtual nlohmann::json ToJson() const = 0;
// Returns the scheduler stats for the collector.
virtual nlohmann::json GetSchedulerStats() const = 0;
// Configures the collector.
//
// Config::key is used to identify the resource to configure. If not provided,
// all resources are configured.
//
// Config::sampling_interval_ms is used to configure the sampling interval of
// the resource. If set to INT_MIN, no change is made to the sampling
// interval. If set to 0, the sampling interval is reset to the default value.
//
// Config::max_batch_size is used to configure the max batch size of the
// resource. If set to INT_MIN, no change is made to the batch size. If set to
// 0, the batch size is reset to the default value.
virtual absl::Status ConfigureCollection(
[[maybe_unused]] const Config& config) const {
return absl::UnimplementedError(
"ConfigureCollection is not implemented for "
"this collector.");
}
};
} // namespace milotic_tlbmc
#endif // THIRD_PARTY_MILOTIC_EXTERNAL_CC_TLBMC_COLLECTOR_COLLECTOR_H_