lokinet/llarp/metrics/publishers.hpp

60 lines
1.0 KiB
C++
Raw Normal View History

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
2019-04-14 17:12:11 +00:00
directoryPublisher(const nlohmann::json& result, const fs::path& path);
2019-04-07 17:54:33 +00:00
};
2019-02-27 21:46:23 +00:00
} // namespace metrics
} // namespace llarp
#endif