WIP prometheus exporter in the queue runner

[?]
GwwtQk9iqB3LBBBpJcyucAv5oM5SrQL5f6P3ak9Uxfnx
Jan 20, 2022, 2:10 AM
7V4ILUL2QMPWYRWLE7AFGFMFYUNBOYS5P3FCVBLFGUMBNOP652BAC

Dependencies

  • [2] N3G7LLGE Get data needed by getBuildOutput() from the incoming NAR in a streaming fashion
  • [3] ZMICO7M6 Remove TokenServer in preparation of making NAR copying O(1) memory
  • [4] YSZQ3ORR Fix build
  • [5] MHVIT4JY Split hydra-queue-runner.cc more
  • [6] WV4SSAIY Build against nix-master
  • [7] 3YSJ3LYK Remove finally.hh
  • [8] EBJP3MNA Build against nix-master
  • [9] 24BMQDZA Start of single-process hydra-queue-runner
  • [10] WCXHTOWH Disable deprecation warnings
  • [*] GS4BE6TB Asynchronously compress build logs
  • [*] PLOZBRTR Add command ‘hydra-queue-runner --status’ to show current status

Change contents

  • edit in src/hydra-queue-runner/hydra-queue-runner.cc at line 8
    [12.713]
    [3.4915]
    #include <prometheus/counter.h>
    #include <prometheus/exposer.h>
    #include <prometheus/registry.h>
  • edit in src/hydra-queue-runner/hydra-queue-runner.cc at line 850
    [3.19112]
    [3.19112]
    using namespace prometheus;
    // create an http server running on port 8080
    Exposer exposer{"127.0.0.1:8080"};
    // create a metrics registry
    // @note it's the users responsibility to keep the object alive
    auto registry = std::make_shared<Registry>();
    // add a new counter family to the registry (families combine values with the
    // same name, but distinct label dimensions)
    //
    // @note please follow the metric-naming best-practices:
    // https://prometheus.io/docs/practices/naming/
    exposer.RegisterCollectable(registry);
    auto& packet_counter = BuildCounter()
    .Name("observed_packets_total")
    .Help("Number of observed packets")
    .Register(*registry);
    auto& tcp_rx_counter =
    packet_counter.Add({{"protocol", "tcp"}, {"direction", "rx"}});
    tcp_rx_counter.Increment();
  • edit in src/hydra-queue-runner/hydra-queue-runner.cc at line 908
    [3.19444]
    [13.4005]
    state.prometheus = registry;
  • replacement in src/hydra-queue-runner/Makefile.am at line 7
    [3.43][3.299:345](),[2.126][3.299:345](),[3.59][3.299:345]()
    hydra_queue_runner_LDADD = $(NIX_LIBS) -lpqxx
    [2.126]
    [3.92]
    hydra_queue_runner_LDADD = $(NIX_LIBS) -lpqxx -lprometheus-cpp-pull -lprometheus-cpp-core -lz