2019-02-27 21:46:23 +00:00
|
|
|
#ifndef LLARP_METRICS_PUBLISHERS_HPP
|
|
|
|
#define LLARP_METRICS_PUBLISHERS_HPP
|
|
|
|
|
|
|
|
#include <util/metrics_core.hpp>
|
|
|
|
|
2019-04-07 17:54:33 +00:00
|
|
|
#include <util/fs.hpp>
|
|
|
|
|
2019-02-27 21:46:23 +00:00
|
|
|
#include <iosfwd>
|
2019-04-07 17:54:33 +00:00
|
|
|
#include <nlohmann/json.hpp>
|
2019-02-27 21:46:23 +00:00
|
|
|
|
|
|
|
namespace llarp
|
|
|
|
{
|
|
|
|
namespace metrics
|
|
|
|
{
|
|
|
|
class StreamPublisher final : public Publisher
|
|
|
|
{
|
|
|
|
std::ostream& m_stream;
|
|
|
|
|
|
|
|
public:
|
|
|
|
StreamPublisher(std::ostream& stream) : m_stream(stream)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
~StreamPublisher()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
publish(const Sample& values) override;
|
|
|
|
};
|
2019-04-07 17:54:33 +00:00
|
|
|
|
|
|
|
class JsonPublisher final : public Publisher
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
using PublishFunction = std::function< void(const nlohmann::json&) >;
|
|
|
|
|
|
|
|
private:
|
|
|
|
PublishFunction m_publish;
|
|
|
|
|
|
|
|
public:
|
|
|
|
JsonPublisher(const PublishFunction& publish) : m_publish(publish)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
~JsonPublisher()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
publish(const Sample& values) override;
|
|
|
|
|
|
|
|
static void
|
|
|
|
directoryPublisher(const nlohmann::json& result, fs::path path);
|
|
|
|
};
|
2019-02-27 21:46:23 +00:00
|
|
|
} // namespace metrics
|
|
|
|
|
|
|
|
} // namespace llarp
|
|
|
|
|
|
|
|
#endif
|