From 5bff730f2c4378bda6bbb46b5274dd4004a28b97 Mon Sep 17 00:00:00 2001 From: Cole Helbling Date: Wed, 6 Apr 2022 11:41:04 -0700 Subject: [PATCH] WIP: I love it when they delete the assignment operator :) --- src/hydra-queue-runner/hydra-queue-runner.cc | 15 +++++++++++++++ src/hydra-queue-runner/queue-monitor.cc | 2 ++ src/hydra-queue-runner/state.hh | 6 +++++- 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/hydra-queue-runner/hydra-queue-runner.cc b/src/hydra-queue-runner/hydra-queue-runner.cc index 5ad1a9d9..f00049a1 100644 --- a/src/hydra-queue-runner/hydra-queue-runner.cc +++ b/src/hydra-queue-runner/hydra-queue-runner.cc @@ -49,7 +49,20 @@ State::State(std::optional metricsAddrOpt) , rootsDir(config->getStrOption("gc_roots_dir", fmt("%s/gcroots/per-user/%s/hydra-roots", settings.nixStateDir, getEnvOrDie("LOGNAME")))) , metricsAddr(config->getStrOption("queue_runner_metrics_address", std::string{"127.0.0.1:9198"})) , registry(std::make_shared()) + // , call_ctr_family(prometheus::BuildCounter().Name("queue_queued_builds_calls_total").Help("Number of times State::getQueuedBuilds() was called").Register(*registry)) + // , call_ctr(call_ctr_family.Add({})) { + // call_ctr_family(prometheus::BuildCounter().Name("queue_queued_builds_calls_total").Help("Number of times State::getQueuedBuilds() was called").Register(*registry)); + // call_ctr(call_ctr_family.Add({})); + auto& fam = prometheus::BuildCounter() + .Name("queue_queued_builds_calls_total") + .Help("Number of times State::getQueuedBuilds() was called") + .Register(*registry) + .Add({}); + + // call_ctr_family(fam); + // call_ctr(call_ctr_family.Add({})); + hydraData = getEnvOrDie("HYDRA_DATA"); logDir = canonPath(hydraData + "/build-logs"); @@ -58,6 +71,7 @@ State::State(std::optional metricsAddrOpt) metricsAddr = metricsAddrOpt.value(); } + /* handle deprecated store specification */ if (config->getStrOption("store_mode") != "") throw Error("store_mode in hydra.conf is deprecated, please use store_uri"); @@ -767,6 +781,7 @@ void State::run(BuildID buildOne) /* Set up simple exporter, to show that we're still alive. */ prometheus::Exposer promExposer{metricsAddr}; auto exposerPort = promExposer.GetListeningPorts().front(); + promExposer.RegisterCollectable(registry); std::cout << "Started the Prometheus exporter, listening on " diff --git a/src/hydra-queue-runner/queue-monitor.cc b/src/hydra-queue-runner/queue-monitor.cc index 49caf8e3..8fb06f45 100644 --- a/src/hydra-queue-runner/queue-monitor.cc +++ b/src/hydra-queue-runner/queue-monitor.cc @@ -82,6 +82,8 @@ struct PreviousFailure : public std::exception { bool State::getQueuedBuilds(Connection & conn, ref destStore, unsigned int & lastBuildId) { + call_ctr.Increment(); + printInfo("checking the queue for builds > %d...", lastBuildId); /* Grab the queued builds from the database, but don't process diff --git a/src/hydra-queue-runner/state.hh b/src/hydra-queue-runner/state.hh index a37548a3..9e89df52 100644 --- a/src/hydra-queue-runner/state.hh +++ b/src/hydra-queue-runner/state.hh @@ -7,6 +7,7 @@ #include #include +#include #include #include "db.hh" @@ -434,10 +435,13 @@ private: via gc_roots_dir. */ nix::Path rootsDir; - std::string metricsAddr;; + std::string metricsAddr; std::shared_ptr registry; + // prometheus::Family& call_ctr_family; + prometheus::Counter& call_ctr; + public: State(std::optional metricsAddrOpt);