Use forward declarations of prometheus-cpp types in telemetry::Manager

This commit is contained in:
Tim Wojtulewicz 2024-06-03 10:41:50 -07:00
parent dd0814c804
commit 9d6ba594b9
2 changed files with 12 additions and 3 deletions

View file

@ -6,6 +6,8 @@
// CivetServer is from the civetweb submodule in prometheus-cpp
#include <CivetServer.h>
#include <prometheus/exposer.h>
#include <prometheus/registry.h>
#include <rapidjson/document.h>
#include <rapidjson/writer.h>
#include <algorithm>
@ -25,6 +27,10 @@ namespace zeek::telemetry {
Manager::Manager() { prometheus_registry = std::make_shared<prometheus::Registry>(); }
// This can't be defined as =default because of the use of unique_ptr with a forward-declared type
// in Manager.h
Manager::~Manager() {}
void Manager::InitPostScript() {
// Metrics port setting is used to calculate a URL for prometheus scraping
std::string prometheus_url;

View file

@ -2,8 +2,6 @@
#pragma once
#include <prometheus/exposer.h>
#include <prometheus/registry.h>
#include <condition_variable>
#include <cstdint>
#include <initializer_list>
@ -24,6 +22,11 @@ class RecordVal;
using RecordValPtr = IntrusivePtr<RecordVal>;
} // namespace zeek
namespace prometheus {
class Exposer;
class Registry;
} // namespace prometheus
namespace zeek::telemetry {
/**
@ -37,7 +40,7 @@ public:
Manager& operator=(const Manager&) = delete;
~Manager() = default;
~Manager();
/**
* Initialization of the manager. This is called late during Zeek's