Skip to content

Commit

Permalink
Address PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
G-D-Petrov committed Mar 13, 2024
1 parent 26f45f5 commit 2b1db8f
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 12 deletions.
4 changes: 2 additions & 2 deletions cpp/arcticdb/entity/metrics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ namespace arcticdb {

cfg_ = config;

if (cfg_.model == PrometheusConfig::Model::PUSH) {
if (cfg_.model_ == PrometheusConfig::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::WEB) {
} else if (cfg_.model_ == PrometheusConfig::Model::PULL) {

// create an http server ie "http://hostname:"+port()+"/metrics"
std::string endpoint = cfg_.host + ":" + cfg_.port;
Expand Down
19 changes: 10 additions & 9 deletions cpp/arcticdb/entity/metrics.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,29 +37,30 @@ const int SUMMARY_AGE_BUCKETS = 5;

class PrometheusConfig {
public:
enum Model {
NO_INIT = 0,
PUSH = 1,
WEB = 2
enum class Model {
NO_INIT,
PUSH,
PULL
};
PrometheusConfig() : model(Model::NO_INIT) {}
PrometheusConfig() : model_(Model::NO_INIT) {}

PrometheusConfig(const std::string& host,
const std::string& port,
const std::string& job_name,
const std::string& instance,
const std::string& prometheus_env,
const int model)
const Model model)
: host(host)
, port(port)
, job_name(job_name)
, instance(instance)
, prometheus_env(prometheus_env)
, model(static_cast<Model>(model)) {
, 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");
}

Expand All @@ -68,7 +69,7 @@ class PrometheusConfig {
std::string job_name;
std::string instance;
std::string prometheus_env;
Model model;
Model model_;
};

class PrometheusInstance {
Expand Down Expand Up @@ -159,6 +160,6 @@ struct fmt::formatter<arcticdb::PrometheusConfig> {
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={}",
k.host, k.port, k.job_name, k.instance, k.prometheus_env, k.model);
k.host, k.port, k.job_name, k.instance, k.prometheus_env, static_cast<int>(k.model_));
}
};
11 changes: 10 additions & 1 deletion cpp/arcticdb/python/python_module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -273,10 +273,19 @@ void register_instrumentation(py::module && m){
}

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 int>());
.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)
.export_values()
;
}

/// Register handling of non-trivial types. For more information @see arcticdb::TypeHandlerRegistry and
Expand Down

0 comments on commit 2b1db8f

Please sign in to comment.