Skip to content

Commit

Permalink
Rename to MetricsConfig
Browse files Browse the repository at this point in the history
  • Loading branch information
G-D-Petrov committed Mar 13, 2024
1 parent 2b1db8f commit 3788c27
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 25 deletions.
6 changes: 3 additions & 3 deletions cpp/arcticdb/entity/metrics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@ 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;
}

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;
Expand All @@ -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;
Expand Down
28 changes: 14 additions & 14 deletions cpp/arcticdb/entity/metrics.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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;
Expand Down Expand Up @@ -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<prometheus::Histogram>* histogram;
Expand Down Expand Up @@ -152,14 +152,14 @@ inline void log_prometheus_counter(const std::string& metric_name, const std::st
} // Namespace arcticdb

template<>
struct fmt::formatter<arcticdb::PrometheusConfig> {
struct fmt::formatter<arcticdb::MetricsConfig> {

template<typename ParseContext>
constexpr auto parse(ParseContext &ctx) { return ctx.begin(); }

template<typename FormatContext>
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<int>(k.model_));
}
};
16 changes: 8 additions & 8 deletions cpp/arcticdb/python/python_module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -276,14 +276,14 @@ void register_metrics(py::module && m){

auto prometheus = m.def_submodule("prometheus");
py::class_<arcticdb::PrometheusInstance, std::shared_ptr<arcticdb::PrometheusInstance>>(prometheus, "Instance");
py::class_<arcticdb::PrometheusConfig, std::shared_ptr<arcticdb::PrometheusConfig>>(prometheus, "PrometheusConfig")
.def(py::init<const std::string&, const std::string&, const std::string&, const std::string&, const std::string&, const arcticdb::PrometheusConfig::Model>());

py::enum_<arcticdb::PrometheusConfig::Model>(prometheus, "PrometheusConfigModel")
.value("NO_INIT", arcticdb::PrometheusConfig::Model::NO_INIT)
.value("PUSH", arcticdb::PrometheusConfig::Model::PUSH)
.value("PULL", arcticdb::PrometheusConfig::Model::PULL)

py::class_<arcticdb::MetricsConfig, std::shared_ptr<arcticdb::MetricsConfig>>(prometheus, "MetricsConfig")
.def(py::init<const std::string&, const std::string&, const std::string&, const std::string&, const std::string&, const arcticdb::MetricsConfig::Model>());

py::enum_<arcticdb::MetricsConfig::Model>(prometheus, "MetricsConfigModel")
.value("NO_INIT", arcticdb::MetricsConfig::Model::NO_INIT)
.value("PUSH", arcticdb::MetricsConfig::Model::PUSH)
.value("PULL", arcticdb::MetricsConfig::Model::PULL)
.export_values()
;
}
Expand Down

0 comments on commit 3788c27

Please sign in to comment.