From 3788c271148ec5ba97d753482264e0379f3e27ec Mon Sep 17 00:00:00 2001 From: Georgi Petrov Date: Wed, 13 Mar 2024 17:23:17 +0200 Subject: [PATCH] Rename to MetricsConfig --- cpp/arcticdb/entity/metrics.cpp | 6 +++--- cpp/arcticdb/entity/metrics.hpp | 28 +++++++++++++-------------- cpp/arcticdb/python/python_module.cpp | 16 +++++++-------- 3 files changed, 25 insertions(+), 25 deletions(-) diff --git a/cpp/arcticdb/entity/metrics.cpp b/cpp/arcticdb/entity/metrics.cpp index 949367296c..8b21ec8e05 100644 --- a/cpp/arcticdb/entity/metrics.cpp +++ b/cpp/arcticdb/entity/metrics.cpp @@ -31,7 +31,7 @@ namespace arcticdb { arcticdb::log::version().info("PrometheusInstance created"); } - void PrometheusInstance::configure(const PrometheusConfig& config, const bool reconfigure) { + void PrometheusInstance::configure(const MetricsConfig& config, const bool reconfigure) { if (configured_ && !reconfigure) { arcticdb::log::version().warn("Prometheus already configured"); return; @@ -39,7 +39,7 @@ namespace arcticdb { cfg_ = config; - if (cfg_.model_ == PrometheusConfig::Model::PUSH) { + if (cfg_.model_ == MetricsConfig::Model::PUSH) { // IMP: This is the GROUPING_KEY - every push overwrites the previous grouping key auto labels = prometheus::Gateway::GetInstanceLabel(getHostName()); mongo_instance_ = cfg_.instance; @@ -51,7 +51,7 @@ namespace arcticdb { arcticdb::log::version().info("Prometheus Push created with settings {}", cfg_); - } else if (cfg_.model_ == PrometheusConfig::Model::PULL) { + } else if (cfg_.model_ == MetricsConfig::Model::PULL) { // create an http server ie "http://hostname:"+port()+"/metrics" std::string endpoint = cfg_.host + ":" + cfg_.port; diff --git a/cpp/arcticdb/entity/metrics.hpp b/cpp/arcticdb/entity/metrics.hpp index 6c6448e34c..e6a6e3509d 100644 --- a/cpp/arcticdb/entity/metrics.hpp +++ b/cpp/arcticdb/entity/metrics.hpp @@ -35,16 +35,16 @@ const std::string PROMETHEUS_ENV_LABEL = "env"; const int SUMMARY_MAX_AGE = 30; const int SUMMARY_AGE_BUCKETS = 5; -class PrometheusConfig { +class MetricsConfig { public: enum class Model { NO_INIT, PUSH, PULL }; - PrometheusConfig() : model_(Model::NO_INIT) {} + MetricsConfig() : model_(Model::NO_INIT) {} - PrometheusConfig(const std::string& host, + MetricsConfig(const std::string& host, const std::string& port, const std::string& job_name, const std::string& instance, @@ -56,12 +56,12 @@ class PrometheusConfig { , instance(instance) , prometheus_env(prometheus_env) , model_(model) { - util::check(!host.empty(), "PrometheusConfig: host is empty"); - util::check(!port.empty(), "PrometheusConfig: port is empty"); - util::check(!job_name.empty(), "PrometheusConfig: job_name is empty"); - util::check(!instance.empty(), "PrometheusConfig: instance is empty"); - util::check(!prometheus_env.empty(), "PrometheusConfig: instance is empty"); - util::check(!prometheus_env.empty(), "PrometheusConfig: prometheus_env is empty"); + util::check(!host.empty(), "MetricsConfig: host is empty"); + util::check(!port.empty(), "MetricsConfig: port is empty"); + util::check(!job_name.empty(), "MetricsConfig: job_name is empty"); + util::check(!instance.empty(), "MetricsConfig: instance is empty"); + util::check(!prometheus_env.empty(), "MetricsConfig: instance is empty"); + util::check(!prometheus_env.empty(), "MetricsConfig: prometheus_env is empty"); } std::string host; @@ -104,11 +104,11 @@ class PrometheusInstance { int push(); - void configure(const PrometheusConfig& config, const bool reconfigure = false); + void configure(const MetricsConfig& config, const bool reconfigure = false); private: - PrometheusConfig cfg_; + MetricsConfig cfg_; struct HistogramInfo { prometheus::Family* histogram; @@ -152,14 +152,14 @@ inline void log_prometheus_counter(const std::string& metric_name, const std::st } // Namespace arcticdb template<> -struct fmt::formatter { +struct fmt::formatter { template constexpr auto parse(ParseContext &ctx) { return ctx.begin(); } template - auto format(const arcticdb::PrometheusConfig k, FormatContext &ctx) const { - return fmt::format_to(ctx.out(), "PrometheusConfig: host={}, port={}, job_name={}, instance={}, prometheus_env={}, model={}", + auto format(const arcticdb::MetricsConfig k, FormatContext &ctx) const { + return fmt::format_to(ctx.out(), "MetricsConfig: host={}, port={}, job_name={}, instance={}, prometheus_env={}, model={}", k.host, k.port, k.job_name, k.instance, k.prometheus_env, static_cast(k.model_)); } }; \ No newline at end of file diff --git a/cpp/arcticdb/python/python_module.cpp b/cpp/arcticdb/python/python_module.cpp index ad3af1e63e..30c219795b 100644 --- a/cpp/arcticdb/python/python_module.cpp +++ b/cpp/arcticdb/python/python_module.cpp @@ -276,14 +276,14 @@ void register_metrics(py::module && m){ auto prometheus = m.def_submodule("prometheus"); py::class_>(prometheus, "Instance"); - - py::class_>(prometheus, "PrometheusConfig") - .def(py::init()); - - py::enum_(prometheus, "PrometheusConfigModel") - .value("NO_INIT", arcticdb::PrometheusConfig::Model::NO_INIT) - .value("PUSH", arcticdb::PrometheusConfig::Model::PUSH) - .value("PULL", arcticdb::PrometheusConfig::Model::PULL) + + py::class_>(prometheus, "MetricsConfig") + .def(py::init()); + + py::enum_(prometheus, "MetricsConfigModel") + .value("NO_INIT", arcticdb::MetricsConfig::Model::NO_INIT) + .value("PUSH", arcticdb::MetricsConfig::Model::PUSH) + .value("PULL", arcticdb::MetricsConfig::Model::PULL) .export_values() ; }