drogon
C++14/17-based HTTP application framework
Toggle main menu visibility
Loading...
Searching...
No Matches
PromExporter.h
Go to the documentation of this file.
1
13
14
#pragma once
15
#include <
drogon/plugins/Plugin.h
>
16
#include <drogon/utils/monitoring/Registry.h>
17
#include <drogon/utils/monitoring/Collector.h>
18
#include <memory>
19
#include <mutex>
20
21
namespace
drogon
22
{
23
namespace
plugin
24
{
54
class
DROGON_EXPORT PromExporter
55
:
public
drogon::Plugin
<PromExporter>,
56
public
std::enable_shared_from_this<PromExporter>,
57
public
drogon::monitoring::Registry
58
{
59
public
:
60
PromExporter()
61
{
62
}
63
64
void
initAndStart
(
const
Json::Value &config)
override
;
65
66
void
shutdown
()
override
67
{
68
}
69
70
~PromExporter
()
override
71
{
72
}
73
74
void
registerCollector(
75
const
std::shared_ptr<drogon::monitoring::CollectorBase> &collector)
76
override
;
77
78
std::shared_ptr<drogon::monitoring::CollectorBase> getCollector(
79
const
std::string &name)
const
noexcept
(
false
);
80
81
template
<
typename
T>
82
std::shared_ptr<drogon::monitoring::Collector<T>> getCollector(
83
const
std::string &name)
const
84
{
85
return
std::dynamic_pointer_cast<drogon::monitoring::Collector<T>>(
86
getCollector(name));
87
}
88
89
private
:
90
mutable
std::mutex mutex_;
91
std::unordered_map<std::string,
92
std::shared_ptr<drogon::monitoring::CollectorBase>>
93
collectors_;
94
std::string path_{
"/metrics"
};
95
std::string exportMetrics();
96
};
97
}
// namespace plugin
98
}
// namespace drogon
Plugin.h
drogon::Plugin
The reflection base class for plugins.
Definition
Plugin.h:132
drogon::plugin::PromExporter
The PromExporter plugin implements a prometheus exporter. The json configuration is as follows:
Definition
PromExporter.h:58
drogon::plugin::PromExporter::initAndStart
void initAndStart(const Json::Value &config) override
drogon::plugin::PromExporter::shutdown
void shutdown() override
Definition
PromExporter.h:66
drogon
Drogon Test is a minimal effort test framework developed because the major C++ test frameworks doesn'...
Definition
Attribute.h:23
lib
inc
drogon
plugins
PromExporter.h
Generated by
1.17.0