9 constexpr
auto storageSizeMetricName =
"kagome_storage_size";
16 std::shared_ptr<application::AppStateManager> app_state_manager,
18 std::shared_ptr<application::ChainSpec> chain_spec)
19 : storage_path_(app_config.databasePath(chain_spec->id())) {
20 BOOST_ASSERT(app_state_manager);
26 storageSizeMetricName,
"Consumption of disk space by storage");
30 app_state_manager->takeControl(*
this);
41 if (storage_size_res.has_value()) {
46 for (
auto i = 0; i < 30; ++i) {
47 std::this_thread::sleep_for(std::chrono::seconds(1));
48 if (shutdown_requested_)
break;
64 boost::system::error_code ec;
72 return boost::system::errc::invalid_argument;
75 uintmax_t total_size = 0;
76 for (fs::recursive_directory_iterator it(entry, ec);
77 it != fs::recursive_directory_iterator();
80 const auto &dir_entry = *it;
81 auto size = fs::file_size(dir_entry, ec);
88 return outcome::success(total_size);
outcome::result< uintmax_t > measure_storage_size()
virtual void set(double val)=0
Set the gauge to the given value.
MetricsWatcher(std::shared_ptr< application::AppStateManager > app_state_manager, const application::AppConfiguration &app_config, std::shared_ptr< application::ChainSpec > chain_spec)
metrics::RegistryPtr metrics_registry_
RegistryPtr createRegistry()
boost::filesystem::path storage_path_
metrics::Gauge * metric_storage_size_
volatile bool shutdown_requested_