Skip to content

Commit

Permalink
message-queue/cpp/src: wip postgres metrics
Browse files Browse the repository at this point in the history
refs #6
  • Loading branch information
jan-matejka committed Dec 16, 2024
1 parent cfec8c6 commit 3ce3305
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 1 deletion.
4 changes: 3 additions & 1 deletion message-queue/cpp/src/instance.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#include "./instance.hpp"

Instance::Instance() : prometheus(Prometheus(config)) {}
Instance::Instance()
: prometheus(Prometheus(config)), pg(Postgres(config))
{}

prometheus::Labels mk_labels(const Instance& app, const WorkerResult& wr, const SampleDesc& sdesc) {
Labels labels = app.runtime.Map();
Expand Down
2 changes: 2 additions & 0 deletions message-queue/cpp/src/instance.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <prometheus/labels.h>

#include "./config.hpp"
#include "./postgres.hpp"
#include "./primitives.hpp"
#include "./prometheus.hpp"
#include "./runtime.hpp"
Expand All @@ -15,6 +16,7 @@ class Instance {
Config config;
Runtime runtime;
Prometheus prometheus;
Postgres pg;
Instance();
};

Expand Down
5 changes: 5 additions & 0 deletions message-queue/cpp/src/postgres.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#include "postgres.hpp"

Postgres::Postgres(Config &c)
: conn(connection("postgres://mq@localhost/mq")) {
}
24 changes: 24 additions & 0 deletions message-queue/cpp/src/postgres.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#ifndef POSTGRES_CPP
#define POSTGRES_CPP

#include <optional>

#include <pqxx/pqxx>

#include "config.hpp"
#include "runtime.hpp"
#include "primitives.hpp"

using namespace std;
using namespace pqxx;

class Postgres {
connection conn;
optional<int> runtime_id = nullopt;

public:
Postgres(Config&);
void Push(Runtime&, SampleDesc&, Results&);
};

#endif
1 change: 1 addition & 0 deletions message-queue/cpp/src/runtime.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,5 @@ class Runtime {
return ss.str();
}
};

#endif

0 comments on commit 3ce3305

Please sign in to comment.